console

package
v2.0.0-snapshot...-58e3a78 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "console",
	ShortHelp: "Open a secure console to a service",
	LongHelp: "`console` gives you direct access to your database service or application shell. " +
		"For example, if you open up a console to a postgres database, you will be given access to a psql prompt. " +
		"You can also open up a mysql prompt, mongo cli prompt, rails console, django shell, and much more. " +
		"When accessing a database service, the `COMMAND` argument is not needed because the appropriate prompt will be given to you. " +
		"If you are connecting to an application service the `COMMAND` argument is required. Here are some sample commands\n\n" +
		"```\ncatalyze -E \"<your_env_alias>\" console db01\n" +
		"catalyze -E \"<your_env_alias>\" console app01 \"bundle exec rails console\"\n```",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(cmd *cli.Cmd) {
			serviceName := cmd.StringArg("SERVICE_NAME", "", "The name of the service to open up a console for")
			command := cmd.StringArg("COMMAND", "", "An optional command to run when the console becomes available")
			cmd.Action = func() {
				if _, err := auth.New(settings, prompts.New()).Signin(); err != nil {
					logrus.Fatal(err.Error())
				}
				if err := config.CheckRequiredAssociation(true, true, settings); err != nil {
					logrus.Fatal(err.Error())
				}
				err := CmdConsole(*serviceName, *command, New(settings, jobs.New(settings)), services.New(settings))
				if err != nil {
					logrus.Fatal(err.Error())
				}
			}
			cmd.Spec = "SERVICE_NAME [COMMAND]"
		}
	},
}

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.

Functions

func CmdConsole

func CmdConsole(svcName, command string, ic IConsole, is services.IServices) error

Types

type IConsole

type IConsole interface {
	Open(command string, service *models.Service) error
	Request(command string, service *models.Service) (*models.Job, error)
	RetrieveTokens(jobID string, service *models.Service) (*models.ConsoleCredentials, error)
	Destroy(jobID string, service *models.Service) error
}

IConsole

func New

func New(settings *models.Settings, jobs jobs.IJobs) IConsole

New returns an instance of IConsole

type SConsole

type SConsole struct {
	Settings *models.Settings
	Jobs     jobs.IJobs
}

SConsole is a concrete implementation of IConsole

func (*SConsole) Destroy

func (c *SConsole) Destroy(jobID string, service *models.Service) error

func (*SConsole) Open

func (c *SConsole) Open(command string, service *models.Service) error

Open opens a secure console to a code or database service. For code services, a command is required. This command is executed as root in the context of the application root directory. For database services, no command is needed - instead, the appropriate command for the database type is run. For example, for a postgres database, psql is run.

func (*SConsole) Request

func (c *SConsole) Request(command string, service *models.Service) (*models.Job, error)

func (*SConsole) RetrieveTokens

func (c *SConsole) RetrieveTokens(jobID string, service *models.Service) (*models.ConsoleCredentials, error)

Jump to

Keyboard shortcuts

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