instances

package
v2.0.0-pre3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &command.Command{
	Cobra: &cobra.Command{
		Use:     "instances",
		Aliases: []string{"instance", "vms", "machines"},
		Short:   "Instances (aka VMs/Machines/Containers)",
	},

	Setup: func(parent *command.Command) error {

		cmds := []*command.Command{
			list.Cmd,
			create.Cmd,
			delete.Cmd,
			get.Cmd,
			count.Cmd,
			reboot.Cmd,
			start.Cmd,
			stop.Cmd,
			ip.Cmd,
		}

		for _, cmd := range cmds {
			cmd.Setup(cmd)
			parent.Cobra.AddCommand(cmd.Cobra)
		}

		{
			const (
				key          = config.KeyInstanceID
				longName     = "id"
				defaultValue = ""
				description  = "Instance ID"
			)

			flags := parent.Cobra.PersistentFlags()
			flags.String(longName, defaultValue, description)
			viper.BindPFlag(key, flags.Lookup(longName))
		}

		{
			const (
				key          = config.KeyInstanceName
				longName     = "name"
				shortName    = "n"
				defaultValue = ""
				description  = "Instance Name"
			)

			flags := parent.Cobra.PersistentFlags()
			flags.StringP(longName, shortName, defaultValue, description)
			viper.BindPFlag(key, flags.Lookup(longName))
		}

		{
			const (
				key         = config.KeyInstanceTag
				longName    = "tag"
				shortName   = "t"
				description = "Instance Tags. This flag can be used multiple times"
			)

			flags := parent.Cobra.PersistentFlags()
			flags.StringSliceP(longName, shortName, nil, description)
			viper.BindPFlag(key, flags.Lookup(longName))
		}

		{
			flags := parent.Cobra.PersistentFlags()
			flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
				switch name {
				case "tag":
					name = "tags"
					break
				}

				return pflag.NormalizedName(name)
			})
		}

		{
			const (
				key          = config.KeyInstanceState
				longName     = "state"
				defaultValue = ""
				description  = "Instance state (e.g. running)"
			)

			flags := parent.Cobra.PersistentFlags()
			flags.String(longName, defaultValue, description)
			viper.BindPFlag(key, flags.Lookup(longName))
		}

		{
			const (
				key          = config.KeyInstanceBrand
				longName     = "brand"
				defaultValue = ""
				description  = "Instance brand (e.g. lx, kvm)"
			)

			flags := parent.Cobra.PersistentFlags()
			flags.String(longName, defaultValue, description)
			viper.BindPFlag(key, flags.Lookup(longName))
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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