cli

package
v0.0.0-...-dfc6acd Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// P helps format usage details
	P = func() string {
		str := ""
		spaces := ""
		maxLen := 0
		for shorthand := range ProfileMapIndexed {
			l := len(shorthand)
			if l > maxLen {
				maxLen = l
			}
		}
		for _, shorthand := range sortedKeys(ProfileMapIndexed) {
			spaces = ""
			k := math.Abs(float64(maxLen) - float64(len(shorthand)) + 3)
			for i := 0; i < int(k); i++ {
				spaces = fmt.Sprintf("%s%s", spaces, " ")
			}
			str = fmt.Sprintf("%s   %s%s %s\n", str, shorthand, spaces, ProfileMapIndexed[shorthand].Description)
		}
		return str
	}()
	// UsageTemplate is a template for showing usage
	UsageTemplate = fmt.Sprintf(`Usage:{{if .Runnable}}
  {{if .HasAvailableFlags}}{{appendIfNotPresent .UseLine "[flags]"}}{{else}}{{.UseLine}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
  {{ .CommandPath}} [command]{{end}}

Profiles:
%s{{if gt .Aliases 0}}
Aliases:
  {{.NameAndAliases}}
{{end}}{{if .HasExample}}
Examples:
{{ .Example }}{{end}}{{ if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if .IsAvailableCommand}}
  {{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimRightSpace}}{{end}}{{ if .HasAvailableInheritedFlags}}

Global Flags:
{{.InheritedFlags.FlagUsages | trimRightSpace}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsHelpCommand}}
  {{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{ if .HasAvailableSubCommands }}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`, P)
)
View Source
var ProfileMapIndexed = map[string]ProfileMap{
	"azure": {
		ProfileFunc: azure.NewUbuntuCluster,
		Description: "Ubuntu on Azure",
	},
	"azure-ubuntu": {
		ProfileFunc: azure.NewUbuntuCluster,
		Description: "Ubuntu on Azure",
	},
	"amazon": {
		ProfileFunc: amazon.NewUbuntuCluster,
		Description: "Ubuntu on Amazon",
	},
	"aws": {
		ProfileFunc: amazon.NewUbuntuCluster,
		Description: "Ubuntu on Amazon",
	},
	"do": {
		ProfileFunc: digitalocean.NewUbuntuCluster,
		Description: "Ubuntu on DigitalOcean",
	},
	"google": {
		ProfileFunc: googlecompute.NewUbuntuCluster,
		Description: "Ubuntu on Google Compute",
	},
	"digitalocean": {
		ProfileFunc: digitalocean.NewUbuntuCluster,
		Description: "Ubuntu on DigitalOcean",
	},
	"do-ubuntu": {
		ProfileFunc: digitalocean.NewUbuntuCluster,
		Description: "Ubuntu on DigitalOcean",
	},
	"aws-ubuntu": {
		ProfileFunc: amazon.NewUbuntuCluster,
		Description: "Ubuntu on Amazon",
	},
	"do-centos": {
		ProfileFunc: digitalocean.NewCentosCluster,
		Description: "CentOS on DigitalOcean",
	},
	"aws-centos": {
		ProfileFunc: amazon.NewCentosCluster,
		Description: "CentOS on Amazon",
	},
	"aws-debian": {
		ProfileFunc: amazon.NewDebianCluster,
		Description: "Debian on Amazon",
	},
	"ovh": {
		ProfileFunc: ovh.NewUbuntuCluster,
		Description: "Ubuntu on OVH",
	},
	"ovh-ubuntu": {
		ProfileFunc: ovh.NewUbuntuCluster,
		Description: "Ubuntu on OVH",
	},
	"packet": {
		ProfileFunc: packet.NewUbuntuCluster,
		Description: "Ubuntu on Packet x86",
	},
	"packet-ubuntu": {
		ProfileFunc: packet.NewUbuntuCluster,
		Description: "Ubuntu on Packet x86",
	},
}

ProfileMapIndexed is a map of possible profiles

Functions

func BoolEnvDef

func BoolEnvDef(env string, def bool) bool

BoolEnvDef get environemnt variable and return bool.

func ExpandPath

func ExpandPath(path string) string

ExpandPath returns working directory path

func IntEnvDef

func IntEnvDef(env string, def int) int

IntEnvDef get environment variable, or some default def

func StrEnvDef

func StrEnvDef(env string, def string) string

StrEnvDef get environment variable, or some default def

Types

type ApplyOptions

type ApplyOptions struct {
	Options
}

ApplyOptions represents apply command options.

type CreateOptions

type CreateOptions struct {
	Options
	Profile string
}

CreateOptions represents create command options.

type DeleteOptions

type DeleteOptions struct {
	Options
	Purge bool
}

DeleteOptions represents delete command options.

type EditOptions

type EditOptions struct {
	Options
	Editor string
}

EditOptions represents edit command options.

type ExplainOptions

type ExplainOptions struct {
	Options
	Profile string
	Output  string
}

ExplainOptions represents explain command options.

type GetConfigOptions

type GetConfigOptions struct {
	Options
}

GetConfigOptions represents getConfig command options.

type ListOptions

type ListOptions struct {
	Options
	Profile string
}

ListOptions represents list command options.

type Options

type Options struct {
	StateStore     string
	StateStorePath string
	Name           string
	CloudID        string
	Set            string
	AwsProfile     string
	GitRemote      string

	S3AccessKey       string
	S3SecretKey       string
	BucketEndpointURL string
	BucketSSL         bool
	BucketName        string
}

Options represents command options.

func (Options) NewStateStore

func (options Options) NewStateStore() (state.ClusterStorer, error)

NewStateStore returns clusterStorer object based on type.

type ProfileFunc

type ProfileFunc func(name string) *cluster.Cluster

ProfileFunc represents function type for a profile

type ProfileMap

type ProfileMap struct {
	ProfileFunc ProfileFunc
	Description string
}

ProfileMap object representing profile function and a description

type VersionOptions

type VersionOptions struct {
	Version   string `json:"Version"`
	GitCommit string `json:"GitCommit"`
	BuildDate string `json:"BuildDate"`
	GOVersion string `json:"GOVersion"`
	GOARCH    string `json:"GOARCH"`
	GOOS      string `json:"GOOS"`
}

VersionOptions contains fields for version output

Jump to

Keyboard shortcuts

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