Documentation ¶
Overview ¶
Package utility provides utility functionality that is used throughout the Civo CLI.
Index ¶
- func AskForConfirm(message string) error
- func Blue(value string) string
- func BoolToYesNo(d bool) string
- func CanManageVolume(volume *civogo.Volume) bool
- func CheckAPPName(appName string) bool
- func CheckAvailability(resource string, regionSet string) (bool, string, error)
- func CheckOS() string
- func CheckQuotaPercent(limit int, usage int) string
- func ColorStatus(status string) string
- func EnsureCurrentRegion()
- func Error(msg string, args ...interface{})
- func GetK3sSize() ([]string, error)
- func GetStringMap(s string) map[string]string
- func Green(value string) string
- func Info(msg string, args ...interface{})
- func ListDefaultApps() ([]string, error)
- func Magenta(value string) string
- func ObtainKubeConfig(KubeconfigFilename string, civoConfig string, merge bool, switchContext bool, ...) error
- func Orange(value string) string
- func RandomName() string
- func Red(value string) string
- func RedConfirm(msg string, args ...interface{})
- func RemoveApplicationFromInstalledList(current []civogo.KubernetesInstalledApplication, uninstall string) string
- func RemoveNodePool(s []civogo.KubernetesClusterPoolConfig, id string, names []string) ([]civogo.KubernetesClusterPoolConfig, []string)
- func RequestedSplit(appList []civogo.KubernetesMarketplaceApplication, requested string) string
- func SizeType(size string) string
- func SliceToString(slice []string) string
- func StartTime() time.Time
- func TrackTime(startTime time.Time) string
- func TrimID(id string) string
- func UpdateNodePool(s []civogo.KubernetesClusterPoolConfig, id string, count int) []civogo.KubernetesClusterPoolConfig
- func UserAccepts(in io.Reader) (bool, error)
- func UserConfirmedDeletion(resourceType string, ignoringConfirmed bool, objectToDelete string) bool
- func UserConfirmedOverwrite(resourceType string, ignoringConfirmed bool) bool
- func UserConfirmedRestore(resourceType string, ignoringConfirmed bool, objectToDelete string) bool
- func UserConfirmedUnassign(resourceType string, ignoringConfirmed bool, objectToDelete string) bool
- func ValidNameLength(name string) bool
- func ValidateSSHKey(key []byte) error
- func Warning(msg string, args ...interface{})
- func Yellow(value string) string
- func YellowConfirm(msg string, args ...interface{})
- type ObjecteList
- type OutputWriter
- func (ow *OutputWriter) AppendData(key, value string)
- func (ow *OutputWriter) AppendDataWithLabel(key, value, label string)
- func (ow *OutputWriter) FinishAndPrintOutput()
- func (ow *OutputWriter) StartLine()
- func (ow *OutputWriter) ToJSON(v interface{}, pretty bool)
- func (ow *OutputWriter) WriteCustomOutput(fields string)
- func (ow *OutputWriter) WriteHeader(label string)
- func (ow *OutputWriter) WriteKeyValues()
- func (ow *OutputWriter) WriteMultipleObjectsJSON(pretty bool)
- func (ow *OutputWriter) WriteSingleObjectJSON(pretty bool)
- 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 CanManageVolume ¶ added in v0.1.32
CanManageVolume is a function to check if a cluster can manage the volume
func CheckAPPName ¶ added in v0.1.32
CheckAPPName is a function to check if the app name is valid
func CheckAvailability ¶ added in v0.1.32
CheckAvailability is a function to check if the user can create Iaas and k8s cluster base on the result of region
func CheckOS ¶ added in v0.1.32
func CheckOS() string
CheckOS is a function to check the OS of the user
func CheckQuotaPercent ¶ added in v0.1.32
CheckQuotaPercent function to check the percent of the quota
func ColorStatus ¶ added in v0.1.2
ColorStatus is to print the status of the Instance or k8s Cluster
func EnsureCurrentRegion ¶ added in v0.1.32
func EnsureCurrentRegion()
EnsureCurrentRegion there's a current region set, error out if not
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 GetK3sSize ¶ added in v0.1.32
GetK3sSize is a functon to return only the k3s size
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 Info ¶ added in v0.1.32
func Info(msg string, args ...interface{})
Info is the function to handler all info messages in the Cli
func ListDefaultApps ¶ added in v0.1.32
ListDefaultApps is a function to list the default apps in the marketplace
func ObtainKubeConfig ¶ added in v0.1.2
func ObtainKubeConfig(KubeconfigFilename string, civoConfig string, merge bool, switchContext bool, clusterName string) error
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 and appends a short UUID
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 RemoveApplicationFromInstalledList ¶ added in v0.1.32
func RemoveApplicationFromInstalledList(current []civogo.KubernetesInstalledApplication, uninstall string) string
RemoveApplicationFromInstalledList is a function to split all currently installed apps and remove one being uninstalled
func RemoveNodePool ¶ added in v0.1.32
func RemoveNodePool(s []civogo.KubernetesClusterPoolConfig, id string, names []string) ([]civogo.KubernetesClusterPoolConfig, []string)
RemoveNodePool is a utility function to remove node pool from a kuberentes cluster
func RequestedSplit ¶ added in v0.1.32
func RequestedSplit(appList []civogo.KubernetesMarketplaceApplication, requested string) string
RequestedSplit is a function to split all app requested to be installed
func SizeType ¶ added in v0.1.77
SizeType is a utility function to to return the type of the size given it's name. Possible types(case-sensitive) : Instance, Database, Kubernetes
func SliceToString ¶ added in v1.0.81
SliceToString converts a slice of strings to a single string, with elements separated by a comma and a space.
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 UpdateNodePool ¶ added in v0.1.32
func UpdateNodePool(s []civogo.KubernetesClusterPoolConfig, id string, count int) []civogo.KubernetesClusterPoolConfig
UpdateNodePool is a utility function to update node pool from a kuberentes cluster
func UserAccepts ¶ added in v0.1.77
UserAccepts is a function that can retrieve user input in form of string and checks if it is a yes.
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 UserConfirmedRestore ¶ added in v0.1.77
UserConfirmedUnassign builds a message to ask the user to confirm unassign a resource and then sends it through to AskForConfirm to parses and verifies user input.
func UserConfirmedUnassign ¶ added in v0.1.32
UserConfirmedUnassign builds a message to ask the user to confirm unassign a resource and then sends it through to AskForConfirm to parses and verifies user input.
func ValidNameLength ¶ added in v0.1.32
ValidNameLength is a function to check is the name is valid
func ValidateSSHKey ¶ added in v0.1.32
ValidateSSHKey is a function to check if the public key is valid
func Warning ¶ added in v0.1.32
func Warning(msg string, args ...interface{})
Warning is the function to handler all warnings in the Cli
func YellowConfirm ¶ added in v0.1.2
func YellowConfirm(msg string, args ...interface{})
YellowConfirm is the function to handler all delete confirm
Types ¶
type ObjecteList ¶ added in v0.1.32
type ObjecteList struct {
ID, Name string
}
ObjecteList contains ID and Name
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(common.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) FinishAndPrintOutput ¶ added in v1.0.82
func (ow *OutputWriter) FinishAndPrintOutput()
func (*OutputWriter) StartLine ¶
func (ow *OutputWriter) StartLine()
StartLine starts a new line of output
func (*OutputWriter) ToJSON ¶ added in v0.1.32
func (ow *OutputWriter) ToJSON(v interface{}, pretty bool)
ToJSON is a function to show the output in json format
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(pretty bool)
WriteMultipleObjectsJSON writes the JSON for multiple objects to STDOUT
func (*OutputWriter) WriteSingleObjectJSON ¶
func (ow *OutputWriter) WriteSingleObjectJSON(pretty bool)
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