services

package
v0.0.0-...-966d904 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "services",
	ShortHelp: "Perform operations on an environment's services",
	LongHelp:  "The <code>services</code> command allows you to manage your services. The services command cannot be run directly but has subcommands.",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.CommandLong(ListSubCmd.Name, ListSubCmd.ShortHelp, ListSubCmd.LongHelp, ListSubCmd.CmdFunc(settings))
			cmd.CommandLong(StopSubCmd.Name, StopSubCmd.ShortHelp, StopSubCmd.LongHelp, StopSubCmd.CmdFunc(settings))
			cmd.CommandLong(RenameSubCmd.Name, RenameSubCmd.ShortHelp, RenameSubCmd.LongHelp, RenameSubCmd.CmdFunc(settings))
		}
	},
}

Cmd is the contract between the user and the CLI. This specifies the command name, arguments, and required/optional arguments and flags for the command.

View Source
var ListSubCmd = models.Command{
	Name:      "list",
	ShortHelp: "List all services for your environment",
	LongHelp: "<code>services list</code> prints out a list of all services in your environment and their sizes. " +
		"The services will be printed regardless of their currently running state. " +
		"To see which services are currently running and which are not, use the status command. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" services list\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdServices(New(settings), volumes.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
		}
	},
}
View Source
var RenameSubCmd = models.Command{
	Name:      "rename",
	ShortHelp: "Rename a service",
	LongHelp: "<code>services rename</code> allows you to rename any service in your environment. Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" services rename code-1 api-svc\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The service to rename")
			label := subCmd.StringArg("NEW_NAME", "", "The new name for the service")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdRename(*serviceName, *label, New(settings))
				if err != nil {
					logrus.Fatalln(err.Error())
				}
			}
			subCmd.Spec = "SERVICE_NAME NEW_NAME"
		}
	},
}
View Source
var StopSubCmd = models.Command{
	Name:      "stop",
	ShortHelp: "Stop all instances of a given service (including all workers, rake tasks, and open consoles)",
	LongHelp: "<code>services stop</code> shuts down all running instances of a given service. " +
		"This is useful when performing maintenance on code services or services without volumes that must be shutdown to perform maintenance. " +
		"Take caution when running this command as all instances of the service, all workers, all rake tasks, and all open console sessions will be stopped. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" services stop code-1\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			svcName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to stop")
			subCmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdStop(*svcName, settings.Pod, New(settings), jobs.New(settings), volumes.New(settings), prompts.New())
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			subCmd.Spec = "SERVICE_NAME"
		}
	},
}

Functions

func CmdRename

func CmdRename(svcName, label string, is IServices) error

func CmdServices

func CmdServices(is IServices, v volumes.IVolumes) error

CmdServices lists the names of all services for an environment.

func CmdStop

func CmdStop(svcName, pod string, is IServices, ij jobs.IJobs, iv volumes.IVolumes, ip prompts.IPrompts) error

CmdStop stops all instances of a given service. All workers and rake tasks will also be stopped if applicable.

Types

type IServices

type IServices interface {
	List() (*[]models.Service, error)
	ListByEnvID(envID, podID string) (*[]models.Service, error)
	Retrieve(svcID string) (*models.Service, error)
	RetrieveByLabel(label string) (*models.Service, error)
	Update(svcID string, updates map[string]string) error
}

IServices

func New

func New(settings *models.Settings) IServices

New generates a new instance of IServices

type SServices

type SServices struct {
	Settings *models.Settings
}

SServices is a concrete implementation of IServices

func (*SServices) List

func (s *SServices) List() (*[]models.Service, error)

func (*SServices) ListByEnvID

func (s *SServices) ListByEnvID(envID, podID string) (*[]models.Service, error)

func (*SServices) Retrieve

func (s *SServices) Retrieve(svcID string) (*models.Service, error)

func (*SServices) RetrieveByLabel

func (s *SServices) RetrieveByLabel(label string) (*models.Service, error)

func (*SServices) Update

func (s *SServices) Update(svcID string, updates map[string]string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL