maintenance

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "maintenance",
	ShortHelp: "Manage maintenance mode for code services",
	LongHelp: "Maintenance mode can be enabled or disabled for code services " +
		"on demand. This redirects all traffic to a default maintenance page.",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			cmd.CommandLong(DisableSubCmd.Name, DisableSubCmd.ShortHelp, DisableSubCmd.LongHelp, DisableSubCmd.CmdFunc(settings))
			cmd.CommandLong(EnableSubCmd.Name, EnableSubCmd.ShortHelp, EnableSubCmd.LongHelp, EnableSubCmd.CmdFunc(settings))
			cmd.CommandLong(ShowSubCmd.Name, ShowSubCmd.ShortHelp, ShowSubCmd.LongHelp, ShowSubCmd.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 DisableSubCmd = models.Command{
	Name:      "disable",
	ShortHelp: "Disable maintenance mode for a code service",
	LongHelp: "<code>maintenance disable</code> turns off maintenance mode for a given code service. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" maintenance disable code-1\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the service to disable maintenance mode for")
			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 := CmdDisable(*serviceName, New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			subCmd.Spec = "SERVICE_NAME"
		}
	},
}
View Source
var EnableSubCmd = models.Command{
	Name:      "enable",
	ShortHelp: "Enable maintenance mode for a code service",
	LongHelp: "<code>maintenance enable</code> turns on maintenance mode for a given code service. " +
		"Maintenance mode redirects all traffic for the given code service to a default HTTP maintenance page. " +
		"If you would like to customize this maintenance page, please contact Datica support. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" maintenance enable code-1\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the code service to enable maintenance mode for")
			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 := CmdEnable(*serviceName, New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			subCmd.Spec = "SERVICE_NAME"
		}
	},
}
View Source
var ShowSubCmd = models.Command{
	Name:      "show",
	ShortHelp: "Show the status of maintenance mode for a code service",
	LongHelp: "<code>maintenance show</code> displays whether or not maintenance mode is enabled " +
		"for a code service or all code services. " +
		"Here are some sample commands\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" maintenance show\n" +
		"datica -E \"<your_env_name>\" maintenance show code-1\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			serviceName := subCmd.StringArg("SERVICE_NAME", "", "The name of the code service to show the status of maintenance mode")
			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 := CmdShow(*serviceName, settings.EnvironmentID, settings.Pod, New(settings), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			subCmd.Spec = "[SERVICE_NAME]"
		}
	},
}

Functions

func CmdDisable

func CmdDisable(svcName string, im IMaintenance, is services.IServices) error

func CmdEnable

func CmdEnable(svcName string, im IMaintenance, is services.IServices) error

func CmdShow

func CmdShow(svcName, envID, podID string, im IMaintenance, is services.IServices) error

Types

type IMaintenance

type IMaintenance interface {
	Enable(svcProxyID, upstreamID string) error
	Disable(svcProxyID, upstreamID string) error
	List(svcProxyID string) (*[]models.Maintenance, error)
}

IMaintenance

func New

func New(settings *models.Settings) IMaintenance

New returns an instance of IMetrics

type SMaintenance

type SMaintenance struct {
	Settings *models.Settings
}

SMaintenance is a concrete implementation of IMaintenance

func (*SMaintenance) Disable

func (m *SMaintenance) Disable(svcProxyID, upstreamID string) error

func (*SMaintenance) Enable

func (m *SMaintenance) Enable(svcProxyID, upstreamID string) error

func (*SMaintenance) List

func (m *SMaintenance) List(svcProxyID string) (*[]models.Maintenance, error)

Jump to

Keyboard shortcuts

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