// ====== service operations
485210
func (s *FeedService) list(req *restful.Request, resp *restful.Response) {
	// TODO (m0sth8): check if this user has access to feed items
	mgr := s.Manager()
	defer mgr.Close()

	query, err := fltr.FromRequest(req, manager.FeedItemFltr{})
	if err != nil {
		resp.WriteServiceError(http.StatusBadRequest, services.NewBadReq(err.Error()))
		return
	}
	skip := 0
	if p := req.QueryParameter("skip"); p != "" {
		if val, err := strconv.Atoi(p); err != nil {
			resp.WriteServiceError(http.StatusBadRequest, services.NewBadReq(fmt.Sprintf("skip: %s", err.Error())))
			return
		} else {
			skip = val
		}
	}
	limit := 20
	if p := req.QueryParameter("limit"); p != "" {
		if val, err := strconv.Atoi(p); err != nil {
			resp.WriteServiceError(http.StatusBadRequest, services.NewBadReq(fmt.Sprintf("limit: %s", err.Error())))
			return
		} else {
			limit = val
		}
	}
	sort := []string{"-updated"}
	results, count, err := mgr.Feed.FilterByQuery(query, mgr.Opts(skip, limit, sort))
	if err != nil {
		logrus.Error(stackerr.Wrap(err))
		resp.WriteServiceError(http.StatusInternalServerError, services.DbErr)
		return
	}

	result := &feed.Feed{
		Meta:    pagination.Meta{Count: count},
		Results: results,
	}
	resp.WriteEntity(result)
}
1037209
func (s *ServiceController) enqueueService(obj interface{}) {
	key, err := controller.KeyFunc(obj)
	if err != nil {
		klog.Errorf("Couldn't get key for object %#v: %v", obj, err)
		return
	}
	s.queue.Add(key)
}
453762
func (c *ServicedCli) initService() {

	c.app.Commands = append(c.app.Commands, cli.Command{
		Name:        "service",
		Usage:       "Administers services",
		Description: "",
		Subcommands: []cli.Command{
			{
				Name:         "list",
				Usage:        "Lists all services",
				Description:  "serviced service list [SERVICEID]",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceList,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "verbose, v",
						Usage: "Show JSON format",
					},
					cli.BoolFlag{
						Name:  "ascii, a",
						Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
					},
					cli.StringFlag{
						Name:  "format",
						Value: "",
						Usage: "format the output using the given go template",
					},
					cli.StringFlag{
						Name:  "show-fields",
						Value: "Name,ServiceID,Inst,ImageID,Pool,DState,Launch,DepID",
						Usage: "Comma-delimited list describing which fields to display",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:        "status",
				Usage:       "Displays the status of deployed services",
				Description: "serviced service status { SERVICEID | SERVICENAME | [POOL/]...PARENTNAME.../SERVICENAME }",
				Action:      c.cmdServiceStatus,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "ascii, a",
						Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
					},
					cli.StringFlag{
						Name:  "show-fields",
						Value: "Name,ServiceID,Status,HC Fail,Healthcheck,Healthcheck Status,Uptime,RAM,Cur/Max/Avg,Hostname,InSync,DockerID",
						Usage: "Comma-delimited list describing which fields to display",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:        "add",
				Usage:       "Adds a new service",
				Description: "serviced service add NAME IMAGEID COMMAND",
				Action:      c.cmdServiceAdd,
				Flags: []cli.Flag{
					cli.GenericFlag{
						Name:  "p",
						Value: &api.PortMap{},
						Usage: "Expose a port for this service (e.g. -p tcp:3306:mysql)",
					},
					cli.GenericFlag{
						Name:  "q",
						Value: &api.PortMap{},
						Usage: "Map a remote service port (e.g. -q tcp:3306:mysql)",
					},
					cli.StringFlag{
						Name:  "parent-id",
						Value: "",
						Usage: "Parent service ID for which this service relates",
					},
				},
			}, {
				Name:        "clone",
				Usage:       "Clones a new service",
				Description: "serviced service clone { SERVICEID | SERVICENAME | [DEPLOYMENTID/]...PARENTNAME.../SERVICENAME }",
				Action:      c.cmdServiceClone,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "suffix",
						Value: "",
						Usage: "name to append to service name, volumes, endpoints",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "remove",
				ShortName:    "rm",
				Usage:        "Removes an existing service",
				Description:  "serviced service remove SERVICEID",
				BashComplete: c.printServicesAll,
				Action:       c.cmdServiceRemove,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "edit",
				Usage:        "Edits an existing service in a text editor",
				Description:  "serviced service edit SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceEdit,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "editor, e",
						Value: os.Getenv("EDITOR"),
						Usage: "Editor used to update the service definition",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "assign-ip",
				Usage:        "Assigns an IP address to a service's endpoints requiring an explicit IP address",
				Description:  "serviced service assign-ip SERVICEID [IPADDRESS]",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceAssignIP,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "start",
				Usage:        "Starts one or more services",
				Description:  "serviced service start SERVICEID ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceStart,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "restart",
				Usage:        "Restarts one or more services",
				Description:  "serviced service restart { SERVICEID | INSTANCEID } ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceRestart,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "rebalance",
						Usage: "Stops all instances before restarting them, instead of performing a rolling restart",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "stop",
				Usage:        "Stops one or more services",
				Description:  "serviced service stop SERVICEID ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceStop,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "pause",
				Usage:        "Pauses one or more services",
				Description:  "serviced service pause SERVICEID ...",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServicePause,
				Flags: []cli.Flag{
					cli.BoolTFlag{
						Name:  "auto-launch",
						Usage: "Recursively schedules child services",
					},
					cli.BoolFlag{
						Name:  "sync, s",
						Usage: "Schedules services synchronously",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "shell",
				Usage:        "Starts a service instance",
				Description:  "serviced service shell SERVICEID [COMMAND]",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceShell,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "saveas, s",
						Value: "",
						Usage: "saves the service instance with the given name",
					},
					cli.BoolFlag{
						Name:  "interactive, i",
						Usage: "runs the service instance as a tty",
					},
					cli.StringSliceFlag{
						Name:  "mount",
						Value: &cli.StringSlice{},
						Usage: "bind mount: HOST_PATH[,CONTAINER_PATH]",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "run",
				Usage:        "Runs a service command in a service instance",
				Description:  "serviced service run SERVICEID COMMAND [ARGS]",
				BashComplete: c.printServiceRun,
				Before:       c.cmdServiceRun,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "interactive, i",
						Usage: "runs the service instance as a tty",
					},
					cli.BoolFlag{
						Name:  "logtostderr",
						Usage: "enable/disable detailed serviced run logging (false by default)",
					},
					cli.BoolTFlag{
						Name:  "logstash",
						Usage: "enable/disable log stash (true by default)",
					},
					cli.StringFlag{
						Name:  "logstash-settle-time",
						Value: "5s",
						Usage: "time duration to wait for logstash to flush log messages before closing",
					},
					cli.StringSliceFlag{
						Name:  "mount",
						Value: &cli.StringSlice{},
						Usage: "bind mount: HOST_PATH[,CONTAINER_PATH]",
					},
					cli.StringFlag{
						Name:  "user",
						Value: "",
						Usage: "container username used to run command",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "attach",
				Usage:        "Run an arbitrary command in a running service container",
				Description:  "serviced service attach { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME/INSTANCE } [COMMAND]",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceAttach,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "action",
				Usage:        "Run a predefined action in a running service container",
				Description:  "serviced service action { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME/INSTANCE } ACTION",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceAction,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "logs",
				Usage:        "Output the logs of a running service container - calls docker logs",
				Description:  "serviced service logs { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME/INSTANCE }",
				BashComplete: c.printServicesFirst,
				Before:       c.cmdServiceLogs,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "list-snapshots",
				Usage:        "Lists the snapshots for a service",
				Description:  "serviced service list-snapshots SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceListSnapshots,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "show-tags, t",
						Usage: "shows the tags associated with each snapshot",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "snapshot",
				Usage:        "Takes a snapshot of the service",
				Description:  "serviced service snapshot SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceSnapshot,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "description, d",
						Value: "",
						Usage: "a description of the snapshot",
					},
					cli.StringFlag{
						Name:  "tag, t",
						Value: "",
						Usage: "a unique tag for the snapshot",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:         "endpoints",
				Usage:        "List the endpoints defined for the service",
				Description:  "serviced service endpoints SERVICEID",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceEndpoints,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "imports, i",
						Usage: "include only imported endpoints",
					},
					cli.BoolFlag{
						Name:  "all, a",
						Usage: "include all endpoints (imports and exports)",
					},
					cli.BoolFlag{
						Name:  "verify, v",
						Usage: "verify endpoints",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			}, {
				Name:        "public-endpoints",
				Usage:       "Manage public endpoints for a service",
				Description: "serviced service public-endpoints",
				Subcommands: []cli.Command{
					{
						Name:        "list",
						Usage:       "Lists public endpoints for a service",
						Description: "serviced service public-endpoints list [SERVICEID] [ENDPOINTNAME]",
						Action:      c.cmdPublicEndpointsListAll,
						Flags: []cli.Flag{
							cli.BoolFlag{
								Name:  "ascii, a",
								Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
							},
							cli.BoolFlag{
								Name:  "ports",
								Usage: "Show port public endpoints",
							},
							cli.BoolFlag{
								Name:  "vhosts",
								Usage: "Show vhost public endpoints",
							},
							cli.StringFlag{
								Name:  "show-fields",
								Value: "Service,ServiceID,Endpoint,Type,Protocol,Name,Enabled",
								Usage: "Comma-delimited list describing which fields to display",
							},
							cli.BoolFlag{
								Name:  "verbose, v",
								Usage: "Show JSON format",
							},
							cli.BoolFlag{
								Name:  "no-prefix-match, np",
								Usage: "Make SERVICEID matches on name strict 'ends with' matches",
							},
						},
					},
					{
						Name:        "port",
						Usage:       "Manages port public endpoints for a service",
						Description: "serviced service public-endpoints port",
						Subcommands: []cli.Command{
							{
								Name:        "list",
								Usage:       "List port public endpoints for a service",
								Description: "serviced service public-endpoints port list [SERVICEID] [ENDPOINTNAME]",
								Action:      c.cmdPublicEndpointsPortList,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "ascii, a",
										Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
									},
									cli.StringFlag{
										Name:  "show-fields",
										Value: "Service,ServiceID,Endpoint,Type,Protocol,Name,Enabled",
										Usage: "Comma-delimited list describing which fields to display",
									},
									cli.BoolFlag{
										Name:  "verbose, v",
										Usage: "Show JSON format",
									},
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "add",
								Usage:       "Add a port public endpoint to a service",
								Description: "serviced service public-endpoints port add <SERVICEID> <ENDPOINTNAME> <PORTADDR> <PROTOCOL> <ENABLED>",
								Action:      c.cmdPublicEndpointsPortAdd,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "restart, r",
										Usage: "Restart the service after adding the port if the service is currently running",
									},
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "remove",
								ShortName:   "rm",
								Usage:       "Remove a port public endpoint from a service",
								Description: "serviced service public-endpoints port remove <SERVICEID> <ENDPOINTNAME> <PORTADDR>",
								Action:      c.cmdPublicEndpointsPortRemove,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "enable",
								Usage:       "Enable/Disable a port public endpoint for a service",
								Description: "serviced service public-endpoints port enable <SERVICEID> <ENDPOINTNAME> <PORTADDR> true|false",
								Action:      c.cmdPublicEndpointsPortEnable,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
						},
					},
					{
						Name:        "vhost",
						Usage:       "Manages vhost public endpoints for a service",
						Description: "serviced service public-endpoints vhost",
						Subcommands: []cli.Command{
							{
								Name:        "list",
								Usage:       "List vhost public endpoints for a service",
								Description: "serviced service public-endpoints vhost list [SERVICEID] [ENDPOINTNAME]",
								Action:      c.cmdPublicEndpointsVHostList,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "ascii, a",
										Usage: "use ascii characters for service tree (env SERVICED_TREE_ASCII=1 will default to ascii)",
									},
									cli.StringFlag{
										Name:  "show-fields",
										Value: "Service,ServiceID,Endpoint,Type,Protocol,Name,Enabled",
										Usage: "Comma-delimited list describing which fields to display",
									},
									cli.BoolFlag{
										Name:  "verbose, v",
										Usage: "Show JSON format",
									},
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "add",
								Usage:       "Add a vhost public endpoint to a service",
								Description: "serviced service public-endpoints vhost add <SERVICEID> <ENDPOINTNAME> <VHOST> <ENABLED>",
								Action:      c.cmdPublicEndpointsVHostAdd,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "remove",
								ShortName:   "rm",
								Usage:       "Remove a vhost public endpoint from a service",
								Description: "serviced service public-endpoints vhost remove <SERVICEID> <ENDPOINTNAME> <VHOST>",
								Action:      c.cmdPublicEndpointsVHostRemove,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
							{
								Name:        "enable",
								Usage:       "Enable/Disable a vhost public endpoint for a service",
								Description: "serviced service public-endpoints vhost enable <SERVICEID> <ENDPOINTNAME> <VHOST> true|false",
								Action:      c.cmdPublicEndpointsVHostEnable,
								Flags: []cli.Flag{
									cli.BoolFlag{
										Name:  "no-prefix-match, np",
										Usage: "Make SERVICEID matches on name strict 'ends with' matches",
									},
								},
							},
						},
					},
				},
			},
			{
				Name:         "clear-emergency",
				Usage:        "Clears the 'emergency shutdown' state for a service and all child services",
				Description:  "serviced service clear-emergency { SERVICEID | SERVICENAME | DEPLOYMENTID/...PARENTNAME.../SERVICENAME }",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceClearEmergency,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:         "remove-ip",
				Usage:        "Remove the IP assignment of a service's endpoints",
				Description:  "serviced service remove-ip <SERVICEID> <ENDPOINTNAME>",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceRemoveIP,
				Flags: []cli.Flag{
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:         "set-ip",
				Usage:        "Setting an IP address to a service's endpoints requiring an explicit IP address. If ip is not provided it does an automatic assignment",
				Description:  "serviced service set-ip <SERVICEID> <ENDPOINTNAME> [ADDRESS] [--port=PORT] [--proto=PROTOCOL]",
				BashComplete: c.printServicesFirst,
				Action:       c.cmdServiceSetIP,
				Flags: []cli.Flag{
					cli.IntFlag{
						Name:  "port",
						Usage: "determine the port your service will use",
					},
					cli.StringFlag{
						Name:  "proto",
						Usage: "determine the port protocol your service will use",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:        "tune",
				Usage:       "Adjust instance count, RAM commitment, or RAM threshold for a service",
				Description: "serviced service tune SERVICEID",
				Action:      c.cmdServiceTune,
				Flags: []cli.Flag{
					cli.IntFlag{
						Name:  "instances",
						Usage: "Instance count for this service",
					},
					cli.StringFlag{
						Name:  "ramCommitment",
						Usage: "RAM Commitment for this service",
					},
					cli.StringFlag{
						Name:  "ramThreshold",
						Usage: "RAM Threshold for this service",
					},
					cli.BoolFlag{
						Name:  "no-prefix-match, np",
						Usage: "Make SERVICEID matches on name strict 'ends with' matches",
					},
				},
			},
			{
				Name:        "config",
				Usage:       "Manage config files for services",
				Description: "serviced service config",
				Subcommands: []cli.Command{
					{
						Name:        "list",
						Usage:       "List all config files for a given service, or the contents of one named file",
						Description: "serviced service config list SERVICEID [FILENAME]",
						Action:      c.cmdServiceConfigList,
						Flags: []cli.Flag{
							cli.BoolFlag{
								Name:  "no-prefix-match, np",
								Usage: "Make SERVICEID matches on name strict 'ends with' matches",
							},
						},
					},
					{
						Name:        "edit",
						Usage:       "Edit one config file for a given service",
						Description: "serviced service config edit SERVICEID FILENAME",
						Action:      c.cmdServiceConfigEdit,
						Flags: []cli.Flag{
							cli.StringFlag{
								Name:  "editor, e",
								Value: os.Getenv("EDITOR"),
								Usage: "Editor used to update the config file",
							},
							cli.BoolFlag{
								Name:  "no-prefix-match, np",
								Usage: "Make SERVICEID matches on name strict 'ends with' matches",
							},
						},
					},
				},
			},
			{
				Name:        "variable",
				Usage:       "Manage service config variables",
				Description: "serviced service variable",
				Subcommands: []cli.Command{
					{
						Name:        "list",
						Usage:       "List one or all config variables and their values for a given service",
						Description: "serviced service variable list SERVICEID",
						Action:      c.cmdServiceVariableList,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
					{
						Name:        "get",
						Usage:       "Find the value of a config variable for a service",
						Description: "serviced service variable get SERVICEID VARIABLE",
						Action:      c.cmdServiceVariableGet,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
					{
						Name:        "set",
						Usage:       "Add or update one variable's value for a given service",
						Description: "serviced service variable set SERVICEID VARIABLE VALUE",
						Action:      c.cmdServiceVariableSet,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
					{
						Name:        "unset",
						Usage:       "Remove a variable from a given service",
						Description: "serviced service variable unset SERVICEID VARIABLE",
						Action:      c.cmdServiceVariableUnset,
                                                Flags: []cli.Flag{
                                                        cli.BoolFlag{
                                                                Name:  "no-prefix-match, np",
                                                                Usage: "Make SERVICEID matches on name strict 'ends with' matches",
                                                        },
                                                },
					},
				},
			},
		},
	})
}
947354
func (jolokiaClient *JolokiaClient) ExecuteOperation(mBean, operation string, arguments interface{}, pattern string) (*JolokiaReadResponse, error) {
	resp, requestErr := jolokiaClient.executePostRequestCallback(pattern, func() ([]byte, error) {
		return wrapExecData(mBean, nil, operation, arguments, jolokiaClient.target, jolokiaClient.targetUser, jolokiaClient.targetPass)
	})
	if requestErr != nil {
		return nil, requestErr
	}
	var respJ JolokiaReadResponse
	decodeErr := json.Unmarshal([]byte(resp), &respJ)
	if decodeErr != nil {
		return nil, fmt.Errorf("Failed to decode Jolokia resp : %v", decodeErr)
	}
	return &respJ, nil
}
1291120
func (l *State) Services() map[string]*structs.NodeService {
	l.RLock()
	defer l.RUnlock()

	m := make(map[string]*structs.NodeService)
	for id, s := range l.services {
		if s.Deleted {
			continue
		}
		m[id] = s.Service
	}
	return m
}
1250001
func (d *MultiDiscovery) Services() []service.Service {
	var aggregate []service.Service

	for _, disco := range d.Discoverers {
		services := disco.Services()
		if len(services) > 0 {
			aggregate = append(aggregate, services...)
		}
	}

	return aggregate
}
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,
	}
}
120303
func (m *Machine) UpdateOperation() *UpdateMachineOperation {
	return &UpdateMachineOperation{m: &Machine{st: m.st, doc: m.doc}}
}
1038472
func (_m *API) UpdateServiceObj(_a0 service.Service) (*service.ServiceDetails, error) {
	ret := _m.Called(_a0)

	var r0 *service.ServiceDetails
	if rf, ok := ret.Get(0).(func(service.Service) *service.ServiceDetails); ok {
		r0 = rf(_a0)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*service.ServiceDetails)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(service.Service) error); ok {
		r1 = rf(_a0)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1

}
159576
func (d *Daemon) CheckServiceTasks(service string) func(*check.C) (interface{}, check.CommentInterface) {
	return func(c *check.C) (interface{}, check.CommentInterface) {
		tasks := d.GetServiceTasks(c, service)
		return len(tasks), nil
	}
}
1361315
func (s *storeImpl) GetServices(ctx datastore.Context) ([]Service, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("ServiceStore.GetServices"))
	return s.query(ctx, "_exists_:ID")
}
218722
func (d *MasterDaemon) InitServices() {
	if d.ClusterMode == "kubernetes" {
		isLeader := func() bool {
			return d.currState == "leader"
		}
		networkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader)
	}
}
944218
func (mh MultiHandle) ServiceGenerator() ServiceGenerator {
	msg := make(MultiServiceGenerator, 0, len(mh))
	for _, h := range mh {
		if sg := h.ServiceGenerator(); sg != nil {
			msg = append(msg, sg)
		}
	}
	return msg
}
499782
func (s *Factory) Services() corev1.ServiceInterface {
	return s.coreClientSet.Services(s.namespace)
}
272241
func (_m *ClientInterface) ServiceUse(serviceID string, imageID string, registry string, replaceImgs []string, noOp bool) (string, error) {
	ret := _m.Called(serviceID, imageID, registry, replaceImgs, noOp)

	var r0 string
	if rf, ok := ret.Get(0).(func(string, string, string, []string, bool) string); ok {
		r0 = rf(serviceID, imageID, registry, replaceImgs, noOp)
	} else {
		r0 = ret.Get(0).(string)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string, string, string, []string, bool) error); ok {
		r1 = rf(serviceID, imageID, registry, replaceImgs, noOp)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
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
}
25471
func (b *RouteBuilder) Operation(name string) *RouteBuilder {
	b.operation = name
	return b
}