// ServiceWithCommand sets the command to use for the service
496822
func ServiceWithCommand(cmd []string) ServiceSpecOpt {
	return func(spec *swarmtypes.ServiceSpec) {
		ensureContainerSpec(spec)
		spec.TaskTemplate.ContainerSpec.Command = cmd
	}
}
1038684
func ServiceWithConfig(configRef *swarmtypes.ConfigReference) ServiceSpecOpt {
	return func(spec *swarmtypes.ServiceSpec) {
		ensureContainerSpec(spec)
		spec.TaskTemplate.ContainerSpec.Configs = append(spec.TaskTemplate.ContainerSpec.Configs, configRef)
	}
}
215854
func Service() (c *ServiceController) {
	return &ServiceController{
		List:       serviceList,
		Detail:     serviceDetail,
		Raw:        serviceRaw,
		Logs:       serviceLogs,
		FetchLogs:  serviceFetchLogs,
		Delete:     serviceDelete,
		New:        serviceNew,
		Create:     serviceCreate,
		Edit:       serviceEdit,
		Update:     serviceUpdate,
		Scale:      serviceScale,
		Rollback:   serviceRollback,
		Restart:    serviceRestart,
		PermEdit:   servicePermEdit,
		PermUpdate: permUpdate("service", "name"),
		Stats:      serviceStats,
	}
}
1075852
func (c *ServicedCli) cmdServiceStop(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "stop")
		c.exit(1)
		return
	}

	serviceIDs := make([]string, len(args))
	for i, svcID := range args {
		svc, _, err := c.searchForService(svcID, ctx.Bool("no-prefix-match"))
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			c.exit(1)
			return
		}

		serviceIDs[i] = svc.ID
	}

	if affected, err := c.driver.StopService(api.SchedulerConfig{serviceIDs, ctx.Bool("auto-launch"), ctx.Bool("sync")}); err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
	} else if affected == 0 {
		fmt.Println("Service(s) already stopped")
	} else {
		fmt.Printf("Scheduled %d service(s) to stop\n", affected)
	}
	return
}
315807
func SubcommandTokenWithParams(params CommandParams) *subcommands.Command {
	return &subcommands.Command{
		Advanced:  params.Advanced,
		UsageLine: params.Name,
		ShortDesc: "prints an access token",
		LongDesc:  "Generates an access token if requested and prints it.",
		CommandRun: func() subcommands.CommandRun {
			c := &tokenRun{}
			c.params = &params
			c.registerBaseFlags()
			c.Flags.DurationVar(
				&c.lifetime, "lifetime", time.Minute,
				"Minimum token lifetime. If existing token expired and refresh token or service account is not present, returns nothing.",
			)
			c.Flags.StringVar(
				&c.jsonOutput, "json-output", "",
				"Destination file to print token and expiration time in JSON. \"-\" for standard output.")
			return c
		},
	}
}
620685
func (f *Flaeg) findCommandWithCommandArgs() (*Command, []string, error) {
	var commandName string
	commandName, f.commandArgs = splitArgs(f.args)
	if len(commandName) > 0 {
		for _, command := range f.commands {
			if commandName == command.Name {
				f.calledCommand = command
				return f.calledCommand, f.commandArgs, nil
			}
		}
		return nil, []string{}, fmt.Errorf("command %s not found", commandName)
	}

	f.calledCommand = f.commands[0]
	return f.calledCommand, f.commandArgs, nil
}
1066809
func (n *ExecNode) execCommand() *exec.Cmd {
	return &exec.Cmd{
		Path: reexec.Self(),
		Args: []string{"p2p-node", strings.Join(n.Config.Node.Services, ","), n.ID.String()},
	}
}
719706
func LoadWithCommand(cmd *Command, cmdArgs []string, customParsers map[reflect.Type]parse.Parser, subCommand []*Command) error {
	parsers, err := parse.LoadParsers(customParsers)
	if err != nil {
		return err
	}

	tagsMap := make(map[string]reflect.StructField)
	if err := getTypesRecursive(reflect.ValueOf(cmd.Config), tagsMap, ""); err != nil {
		return err
	}
	defaultValMap := make(map[string]reflect.Value)
	if err := getDefaultValue(reflect.ValueOf(cmd.Config), reflect.ValueOf(cmd.DefaultPointersConfig), defaultValMap, ""); err != nil {
		return err
	}

	valMap, errParseArgs := parseArgs(cmdArgs, tagsMap, parsers)
	if errParseArgs != nil && errParseArgs != ErrParserNotFound {
		return PrintErrorWithCommand(errParseArgs, tagsMap, defaultValMap, parsers, cmd, subCommand)
	}

	if err := fillStructRecursive(reflect.ValueOf(cmd.Config), defaultValMap, valMap, ""); err != nil {
		return err
	}

	if errParseArgs == ErrParserNotFound {
		return errParseArgs
	}

	return nil
}
703975
func (h *HealthCheck) SetCommand(c Command) *HealthCheck {
	h.Command = &c
	return h
}
1131213
func AddCommand(cmd string, format int, post PostProcessor, desc, usage string) {
	pprofCommands[cmd] = &command{format, post, nil, false, desc, usage}
}
361631
func BaseCommand(serviceName, shortDescription string) *cobra.Command {
	command := &cobra.Command{
		Use:   serviceName,
		Short: shortDescription,
	}

	command.PersistentFlags().StringVar(&service.Config.Host, "grpc_host", "0.0.0.0", "gRPC service hostname")
	command.PersistentFlags().IntVar(&service.Config.Port, "grpc_port", 8000, "gRPC port")
	command.PersistentFlags().StringVar(&service.PrometheusConfig.Host, "prometheus_host", "0.0.0.0", "Prometheus metrics hostname")
	command.PersistentFlags().IntVar(&service.PrometheusConfig.Port, "prometheus_port", 9000, "Prometheus metrics port")

	return command
}
1051801
func WithContainerService(containerService containersapi.ContainersClient) ServicesOpt {
	return func(s *services) {
		s.containerStore = NewRemoteContainerStore(containerService)
	}
}
15195
func WithTaskService(taskService tasks.TasksClient) ServicesOpt {
	return func(s *services) {
		s.taskService = taskService
	}
}
1210946
func UnpauseCommand(factory app.ProjectFactory) cli.Command {
	return cli.Command{
		Name:  "unpause",
		Usage: "Unpause services.",
		// ArgsUsage: "[SERVICE...]",
		Action: app.WithProject(factory, app.ProjectUnpause),
	}
}
396100
func ContextWithServiceDescriptor(ctx context.Context, service *ServiceDescriptor) context.Context {
	return context.WithValue(ctx, serviceContextKey, service)
}
639646
func (c *ServicedCli) serviceCommands(id string) (data []string) {
	svc, err := c.driver.GetService(id)
	if err != nil || svc == nil {
		c.exit(1)
		return
	}

	data = make([]string, len(svc.Commands))
	i := 0
	for r := range svc.Commands {
		data[i] = r
		i++
	}

	return
}
1305697
func (_m *DBClient) AddCommand(c models.Command) (string, error) {
	ret := _m.Called(c)

	var r0 string
	if rf, ok := ret.Get(0).(func(models.Command) string); ok {
		r0 = rf(c)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(models.Command) error); ok {
		r1 = rf(c)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}