Documentation
¶
Overview ¶
Package utility provides utility functionality that is used throughout the Civo CLI.
Index ¶
- func AskForConfirm(message string) error
- func BoolToYesNo(d bool) string
- func ColorStatus(status string) interface{}
- func Error(msg string, args ...interface{})
- func GetStringMap(s string) map[string]string
- func Green(value string) string
- func ObtainKubeConfig(KubeconfigFilename string, civoConfig string, merge bool) error
- func RandomName() string
- func Red(value string) string
- func RedConfirm(msg string, args ...interface{})
- func StartTime() time.Time
- func TrackTime(startTime time.Time) string
- func UserConfirmedDeletion(resourceType string, ignoringConfirmed bool) bool
- func UserConfirmedOverwrite(resourceType string, ignoringConfirmed bool) bool
- func YellowConfirm(msg string, args ...interface{})
- type OutputWriter
- func (ow *OutputWriter) AppendData(key, value string)
- func (ow *OutputWriter) AppendDataWithLabel(key, value, label string)
- func (ow *OutputWriter) StartLine()
- func (ow *OutputWriter) WriteCustomOutput(fields string)
- func (ow *OutputWriter) WriteHeader(label string)
- func (ow *OutputWriter) WriteKeyValues()
- func (ow *OutputWriter) WriteMultipleObjectsJSON()
- func (ow *OutputWriter) WriteSingleObjectJSON()
- func (ow *OutputWriter) WriteSubheader(label string)
- func (ow *OutputWriter) WriteTable()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskForConfirm ¶ added in v0.1.2
AskForConfirm parses and verifies user input for confirmation.
func BoolToYesNo ¶
BoolToYesNo returns Yes or No depending on the value of a boolean This wouldn't be as necessary if Go had a ternary operator
func ColorStatus ¶ added in v0.1.2
func ColorStatus(status string) interface{}
ColorStatus is to print the status of the Instance or k8s Cluster
func Error ¶ added in v0.1.2
func Error(msg string, args ...interface{})
Error is the function to handler all error in the Cli
func GetStringMap ¶ added in v0.1.2
GetStringMap getStringMap convert string in the format a:1,b:2,c:3 in map[string]string, this is util for the flags StringArrayVarP
func ObtainKubeConfig ¶ added in v0.1.2
ObtainKubeConfig is the function to get the kubeconfig from the cluster and save to the file or merge with the existing one
func RandomName ¶ added in v0.1.10
func RandomName() string
RandomName generates a Heroku-style random name for instances/clusters/etc
func RedConfirm ¶ added in v0.1.5
func RedConfirm(msg string, args ...interface{})
RedConfirm is the function to handler the new version of the Cli
func TrackTime ¶ added in v0.1.10
TrackTime function to get the start time and see the time between start time and the end time
func UserConfirmedDeletion ¶ added in v0.1.12
UserConfirmedDeletion builds a message to ask the user to confirm delete a resource and then sends it through to AskForConfirm to parses and verifies user input.
func UserConfirmedOverwrite ¶ added in v0.1.32
UserConfirmedOverwrite builds a message to ask the user to confirm overwrite config and then sends it through to AskForConfirm to parses and verifies user input.
func YellowConfirm ¶ added in v0.1.2
func YellowConfirm(msg string, args ...interface{})
YellowConfirm is the function to handler all delete confirm
Types ¶
type OutputWriter ¶
OutputWriter is for printing structured data in various tabular formats
ow := utility.NewOutputWriter()
ow.StartLine()
ow.AppendData("ID", instance.ID)
# Then one of:
ow.WriteSingleObjectJSON()
ow.WriteMultipleObjectsJSON()
ow.WriteCustomOutput(outputFields)
ow.WriteKeyValues()
ow.WriteTable()
func NewOutputWriter ¶
func NewOutputWriter() *OutputWriter
NewOutputWriter builds a new OutputWriter
func NewOutputWriterWithMap ¶
func NewOutputWriterWithMap(data map[string]string) *OutputWriter
NewOutputWriterWithMap builds a new OutputWriter and automatically inserts the supplied map as a single line
func (*OutputWriter) AppendData ¶
func (ow *OutputWriter) AppendData(key, value string)
AppendData adds a line of data to the output writer
func (*OutputWriter) AppendDataWithLabel ¶
func (ow *OutputWriter) AppendDataWithLabel(key, value, label string)
AppendDataWithLabel adds a line of data to the output writer
func (*OutputWriter) StartLine ¶
func (ow *OutputWriter) StartLine()
StartLine starts a new line of output
func (*OutputWriter) WriteCustomOutput ¶
func (ow *OutputWriter) WriteCustomOutput(fields string)
WriteCustomOutput prints one or multiple objects using custom formatting
func (*OutputWriter) WriteHeader ¶ added in v0.1.2
func (ow *OutputWriter) WriteHeader(label string)
WriteHeader WriteSubheader writes a centred heading line in to output
func (*OutputWriter) WriteKeyValues ¶
func (ow *OutputWriter) WriteKeyValues()
WriteKeyValues prints a single object stored in the OutputWriter in key: value format
func (*OutputWriter) WriteMultipleObjectsJSON ¶
func (ow *OutputWriter) WriteMultipleObjectsJSON()
WriteMultipleObjectsJSON writes the JSON for multiple objects to STDOUT
func (*OutputWriter) WriteSingleObjectJSON ¶
func (ow *OutputWriter) WriteSingleObjectJSON()
WriteSingleObjectJSON writes the JSON for a single object to STDOUT
func (*OutputWriter) WriteSubheader ¶
func (ow *OutputWriter) WriteSubheader(label string)
WriteSubheader writes a centred heading line in to output
func (*OutputWriter) WriteTable ¶
func (ow *OutputWriter) WriteTable()
WriteTable prints multiple objects stored in the OutputWriter in tabular format