Documentation ¶
Index ¶
- Variables
- func Command(ctx context.Context, name string, args ...string) ([]string, error)
- func Git(ctx context.Context, args ...string) ([]string, error)
- func HostnamePrompt(ctx context.Context, label, def string) (string, error)
- func Kubectl(ctx context.Context, args ...string) ([]string, error)
- func Logf(ctx context.Context, v string, args ...interface{})
- func NamePrompt(ctx context.Context, label, def string) (string, error)
- func RandName(prefix string, args ...interface{}) string
- func Searcher(items []string) func(input string, index int) bool
- func SelectPrompt(ctx context.Context, label string, items ...string) (int, string, error)
- func SelectYesNo(ctx context.Context, label string) (bool, error)
- func SetContextOutput(ctx context.Context, out io.Writer) context.Context
- func SetLogPrefix(ctx context.Context, prefix string) context.Context
- func SetVerbosity(ctx context.Context, verbose bool) context.Context
- func SetupSpace(ctx context.Context, containerRegistry string) error
Constants ¶
This section is empty.
Variables ¶
var ( // PrefixColor should be used when adding color to the prefix of a line // (e.g., [some-prefix]). PrefixColor = color.New(color.FgHiBlue, color.Bold) // LabelColor is used for the prompt and select labels. LabelColor = color.New(color.FgHiYellow, color.Bold) // BenchmarkColor is used for the commands to report how long they took. BenchmarkColor = color.New(color.FgHiGreen, color.Bold) )
var ( // NameRegexp ensures a reasonable name. NameRegexp = regexp.MustCompile(`^[a-z][0-9a-zA-Z-]{5,29}$`) // HostnameRegexp is from https://stackoverflow.com/a/106223 HostnameRegexp = regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`) )
Functions ¶
func Command ¶
Command runs a command with the given context and returns the output's lines. If the command fails, then the output is logged. If the context has verbose set, then the command is logged before being ran.
func HostnamePrompt ¶
HostnamePrompt asks the user to enter a hostname. It validates it using HostnameRegexp.
func NamePrompt ¶
NamePrompt asks the user to enter a name. It validates it using NameRegexp.
func RandName ¶
RandName is a utility function that returns a random name for things like spaces or projects.
func Searcher ¶
Searcher implements list.Searcher for promptui.Select. It is case insensitive and returns true only if the input string is present.
func SelectPrompt ¶
SelectPrompt prompts the user to select from the given items. It uses Searcher and properly colors the label.
func SelectYesNo ¶
SelectYesNo promts the user to select between yes and no. It will return true if the user selects "yes", and false otherwise.
func SetContextOutput ¶
SetContextOutput returns a context that holds where Logf should write.
func SetLogPrefix ¶
SetLogPrefix returns a context with the desired prefix that Logf will use.
func SetVerbosity ¶
SetVerbosity returns a context with the desired verbose setting used with Command.
Types ¶
This section is empty.