environments

package
v0.0.0-...-493bf59 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 8 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = models.Command{
	Name:      "environments",
	ShortHelp: "Manage environments for which you have access",
	LongHelp:  "The <code>environments</code> command allows you to manage your environments. The environments command can not 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(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 environments you have access to",
	LongHelp: "<code>environments list</code> lists all environments that you are granted access to. " +
		"These environments include those you created and those that other Datica customers have added you to. " +
		"Here is a sample command\n\n" +
		"<pre>\ndatica environments 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.Fatalln(err.Error())
				}
				err := CmdList(settings, New(settings))
				if err != nil {
					logrus.Fatalln(err.Error())
				}
			}
		}
	},
}
View Source
var RenameSubCmd = models.Command{
	Name:      "rename",
	ShortHelp: "Rename an environment",
	LongHelp: "<code>environments rename</code> allows you to rename your environment. Here is a sample command\n\n" +
		"<pre>\ndatica -E \"<your_env_name>\" environments rename MyNewEnvName\n</pre>",
	CmdFunc: func(settings *models.Settings) func(cmd *cli.Cmd) {
		return func(subCmd *cli.Cmd) {
			name := subCmd.StringArg("NAME", "", "The new name of the environment")
			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(settings.EnvironmentID, *name, New(settings))
				if err != nil {
					logrus.Fatalln(err.Error())
				}
			}
			subCmd.Spec = "NAME"
		}
	},
}

Functions

func CmdList

func CmdList(settings *models.Settings, environments IEnvironments) error

CmdList lists all environments which the user has access to

func CmdRename

func CmdRename(envID, name string, ie IEnvironments) error

Types

type IEnvironments

type IEnvironments interface {
	List() (*[]models.Environment, map[string]error)
	Retrieve(envID string) (*models.Environment, error)
	Update(envID string, updates map[string]string) error
}

IEnvironments is an interface for interacting with environments

func New

func New(settings *models.Settings) IEnvironments

New generates a new instance of IEnvironments

type SEnvironments

type SEnvironments struct {
	Settings *models.Settings
}

SEnvironments is a concrete implementation of IEnvironments

func (*SEnvironments) List

func (e *SEnvironments) List() (*[]models.Environment, map[string]error)

func (*SEnvironments) Retrieve

func (e *SEnvironments) Retrieve(envID string) (*models.Environment, error)

func (*SEnvironments) Update

func (e *SEnvironments) Update(envID string, updates map[string]string) error

Jump to

Keyboard shortcuts

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