Documentation ¶
Index ¶
- Constants
- Variables
- func CheckKubectl() bool
- func CompareVersions(v1 string, v2 string) (int, error)
- func DurationPhrase(hours int) string
- func GetBashCompletionFn(fName, fBody string) string
- func GetCustomCommandCompletionFnBody() string
- func GetDeprecatedNotice(provider, gsctlCmd, kubectlgsCmd, docsURL string) string
- func IsCouldNotSetKubectlClusterError(err error) bool
- func IsCouldNotSetKubectlContextError(err error) bool
- func IsCouldNotSetKubectlCredentialsError(err error) bool
- func IsCouldNotUseKubectlContextError(err error) bool
- func IsDurationExceededError(err error) bool
- func IsInvalidDurationStringError(err error) bool
- func KubectlSetCluster(clusterID, apiEndpoint, caCertificatePath string) error
- func KubectlSetContext(contextName, clusterID string) error
- func KubectlSetCredentials(clusterID, keyPath, certificatePath string) error
- func KubectlUseContext(contextName string) error
- func ParseDate(dateString string) time.Time
- func ParseDuration(durationString string) (time.Duration, error)
- func RegisterBashCompletionFn(command *cobra.Command, fName, fBody string)
- func SetCommandBashCompletion(completionFn *BashCompletionFunc)
- func SetFlagBashCompletionFn(completionFn *BashCompletionFunc)
- func ShortDate(date time.Time) string
- func StoreCaCertificate(fs afero.Fs, certsDirPath, clusterID, data string) string
- func StoreClientCertificate(fs afero.Fs, certsDirPath, clusterID, keyPairID, data string) string
- func StoreClientKey(fs afero.Fs, certsDirPath, clusterID, keyPairID, data string) string
- func Truncate(str string, length int, doTruncate bool) string
- func VersionSortComp(v1, v2 string) bool
- type BashCompletionFunc
Constants ¶
const LabelFilterKeySubstring = "giantswarm.io"
LabelFilterKeySubstring is the substring used to hide giantswarm labels
Variables ¶
var CouldNotSetKubectlClusterError = µerror.Error{
Kind: "CouldNotSetKubectlClusterError",
Desc: "could not set cluster using 'kubectl config set-cluster'",
}
CouldNotSetKubectlClusterError is used if kubectl config set-cluster could not be executed.
var CouldNotSetKubectlContextError = µerror.Error{
Kind: "CouldNotSetKubectlContextError",
Desc: "could not set context using 'kubectl config set-context'",
}
CouldNotSetKubectlContextError is used when kubectl config set-context could not be executed.
var CouldNotSetKubectlCredentialsError = µerror.Error{
Kind: "CouldNotSetKubectlCredentialsError",
Desc: "could not set credentials using 'kubectl config set-credentials'",
}
CouldNotSetKubectlCredentialsError is used when kubectl config set-credentials could not be executed.
var CouldNotUseKubectlContextError = µerror.Error{
Kind: "CouldNotUseKubectlContextError",
Desc: "could not apply context using 'kubectl config set-context'",
}
CouldNotUseKubectlContextError is used when kubectl config use-context could not be executed.
var DurationExceededError = µerror.Error{
Kind: "DurationExceededError",
}
DurationExceededError is thrown when a duration value is larger than can be represented internally
var InvalidDurationStringError = µerror.Error{
Kind: "InvalidDurationStringError",
}
InvalidDurationStringError is used when a duration string given by the user could not be parsed.
Functions ¶
func CheckKubectl ¶
func CheckKubectl() bool
CheckKubectl checks if kubectl exists, is silent if yes, prints error and exits if not
func CompareVersions ¶
CompareVersions compres to semver version strings v1 and v2. Returned result: - if v1 is greater than v2: 1 - if v1 is equal to v2: 0 if v1 is smaller than v2: -1
func DurationPhrase ¶
DurationPhrase creates a human-friendly phrase from a number of hours expressing a duration, like "3 days, 2 hours". Precision of output is limited in favour of readability.
func GetBashCompletionFn ¶
GenBashCompletionFn generates a bash function that can be used for auto-completion of command-line commands or flags
func GetCustomCommandCompletionFnBody ¶
func GetCustomCommandCompletionFnBody() string
GetCustomCommandCompletionFnBody returns the global custom command-line completion function body
func GetDeprecatedNotice ¶
func IsCouldNotSetKubectlClusterError ¶
IsCouldNotSetKubectlClusterError asserts CouldNotSetKubectlClusterError.
func IsCouldNotSetKubectlContextError ¶
IsCouldNotSetKubectlContextError asserts CouldNotSetKubectlContextError.
func IsCouldNotSetKubectlCredentialsError ¶
IsCouldNotSetKubectlCredentialsError asserts CouldNotSetKubectlClusterError.
func IsCouldNotUseKubectlContextError ¶
IsCouldNotUseKubectlContextError asserts CouldNotUseKubectlContextError.
func IsDurationExceededError ¶
IsDurationExceededError asserts DurationExceededError
func IsInvalidDurationStringError ¶
IsInvalidDurationStringError asserts InvalidDurationStringError.
func KubectlSetCluster ¶
KubectlSetCluster is a wrapper for the `kubectl config set-cluster` command
func KubectlSetContext ¶
KubectlSetContext is a wrapper for the `kubectl config set-context` command
func KubectlSetCredentials ¶
KubectlSetCredentials is a wrapper for the `kubectl config set-credentials` command
func KubectlUseContext ¶
KubectlUseContext applies the context for the given cluster ID
func ParseDuration ¶
ParseDuration converts strings like "1d" into a duration. Only one combination of <number> and <unit> is allowed, and the unit must be one of: - "h" - one hour - "d" - day (24 hours) - "w" - 7 days - "m" - 30 days - "y" - 365 days
This is necessary because time.ParseDuration does not support units larger than hour.
func RegisterBashCompletionFn ¶
RegisterBashCompletionFn adds a custom completion function to the root command config
func SetCommandBashCompletion ¶
func SetCommandBashCompletion(completionFn *BashCompletionFunc)
SetCommandBashCompletion adds functionality to the global custom command-line completion function
Due to `cobra` limitations, this is currently the only way of adding auto-completion for commands
func SetFlagBashCompletionFn ¶
func SetFlagBashCompletionFn(completionFn *BashCompletionFunc)
SetFlagBashCompletionFn sets a custom completion function for a given command-line flag
func StoreCaCertificate ¶
StoreCaCertificate writes a CA certificate to a file
The file will have the name format `<clusterID>-ca.crt`
func StoreClientCertificate ¶
StoreClientCertificate writes a client certificate to a file
The file will have the name format `<clusterID>-<keypair-id>-client.crt`
func StoreClientKey ¶
StoreClientKey writes a client key to a file
The file will have the name format `<clusterID>-<keypair-id>-client.key`
func VersionSortComp ¶
VersionSortComp is a comparison function usable with the sort.Slice API