Documentation ¶
Overview ¶
Package utils adding package comment to satisfy linters
Index ¶
- Constants
- func CheckKubernetesUpgradeCompatibility(fromVersion, toVersion string) bool
- func CompareMajorMinorPatchVersion(version1, version2 string) bool
- func CompareVMwareVersionStrings(v1, v2 string) (int, error)
- func ContainsString(arr []string, str string) bool
- func Convert(in string) interface{}
- func CopyFile(sourceFile, destFile string) error
- func CopyToTempFile(sourceFile, tempFilePrefix string) (string, error)
- func CreateTempFile(dir, prefix string) (string, error)
- func DeleteFile(filePath string) error
- func DivideVPCCidr(cidrStr string, extendedBits, numSubnets int) ([]string, error)
- func FixKubeConfigForMacEnvironment(dockerContext context.Context, cli *client.Client, kubeconfigBytes []byte) ([]byte, error)
- func GenerateRandomID(length int, excludeCapitalLetters bool) string
- func Get(from Getter, t clusterv1alpha3.ConditionType) *clusterv1alpha3.Condition
- func GetClusterInfoFromCluster(clusterAPIServerURL, configmapName string) (*clientcmdapi.Cluster, error)
- func GetClusterNameFromKubeconfigAndContext(kubeConfigPath, context string) (string, error)
- func GetClusterServerFromKubeconfigAndContext(kubeConfigPath, context string) (string, error)
- func GetFileLockWithTimeOut(lockPath string, lockDuration time.Duration) (*fslock.Lock, error)
- func GetMessage(from Getter, t clusterv1alpha3.ConditionType) string
- func GetReason(from Getter, t clusterv1alpha3.ConditionType) string
- func GetSeverity(from Getter, t clusterv1alpha3.ConditionType) *clusterv1alpha3.ConditionSeverity
- func GetTKGBoMTagFromFileName(fileName string) string
- func GetTKRVersionFromTKRName(tkrName string) string
- func GetTkrNameFromTkrVersion(tkrVersion string) string
- func Has(from Getter, t clusterv1alpha3.ConditionType) bool
- func IsFalse(from Getter, t clusterv1alpha3.ConditionType) bool
- func IsOnWindows() bool
- func IsTrue(from Getter, t clusterv1alpha3.ConditionType) bool
- func IsUnknown(from Getter, t clusterv1alpha3.ConditionType) bool
- func IsValidURL(s string) bool
- func PathExists(dir string) bool
- func ReplaceSpecialChars(str string) string
- func ReplaceVersionInDockerImage(image, newVersion string) (string, error)
- func SHA256FromFile(filePath string) (string, error)
- func SaveFile(filePath string, data []byte) error
- func ToSnakeCase(str string) string
- func WriteToFile(sourceFile string, data []byte) error
- type Getter
- type PinnipedConfigMapInfo
Constants ¶
const ( KubePublicNamespace = "kube-public" PinnipedInfoConfigMapName = "pinniped-info" )
const ( // DefaultLockTimeout is the default time waiting on the filelock DefaultLockTimeout = 10 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func CheckKubernetesUpgradeCompatibility ¶
CheckKubernetesUpgradeCompatibility checks if a tkg cluster with a k8s version can be upgraded to another version. Updrading operations is not supported if the gap between the minor versions is larger than 1. For example upgrading from v1.17.9 to v1.19.1 is not supported. The behavior of this function may be changed in the future, if the upstream supports upgrading between versions with larger gaps.
func CompareMajorMinorPatchVersion ¶
CompareMajorMinorPatchVersion returns true if major/minor/patch parts of the versions match, else false
func CompareVMwareVersionStrings ¶
CompareVMwareVersionStrings compares vmware aware versions
func ContainsString ¶
ContainsString checks the string contains in string array
func CopyToTempFile ¶
CopyToTempFile creates temp file and copies the sourcefile to created temp file
func CreateTempFile ¶
CreateTempFile creates temporary file
func DeleteFile ¶
DeleteFile deletes the file from given location
func DivideVPCCidr ¶
DivideVPCCidr divide VPC cidr as per extendedBits and number of subnets needed
func FixKubeConfigForMacEnvironment ¶
func FixKubeConfigForMacEnvironment(dockerContext context.Context, cli *client.Client, kubeconfigBytes []byte) ([]byte, error)
FixKubeConfigForMacEnvironment fix api server endpoint
func GenerateRandomID ¶
GenerateRandomID generates random string
func Get ¶ added in v0.11.0
func Get(from Getter, t clusterv1alpha3.ConditionType) *clusterv1alpha3.Condition
Get returns the condition with the given type, if the condition does not exist, it returns nil.
func GetClusterInfoFromCluster ¶
func GetClusterInfoFromCluster(clusterAPIServerURL, configmapName string) (*clientcmdapi.Cluster, error)
GetClusterInfoFromCluster gets the cluster Info by accessing the cluster-info configMap in kube-public namespace
func GetClusterNameFromKubeconfigAndContext ¶
GetClusterNameFromKubeconfigAndContext gets name of the cluster from kubeconfig file and kube-context
func GetClusterServerFromKubeconfigAndContext ¶
GetClusterServerFromKubeconfigAndContext gets apiserver URL of the cluster from kubeconfig file and kube-context
func GetFileLockWithTimeOut ¶
GetFileLockWithTimeOut returns a file lock with timeout
func GetMessage ¶ added in v0.11.0
func GetMessage(from Getter, t clusterv1alpha3.ConditionType) string
GetMessage returns a nil safe string of Message.
func GetReason ¶ added in v0.11.0
func GetReason(from Getter, t clusterv1alpha3.ConditionType) string
GetReason returns a nil safe string of Reason for the condition with the given type.
func GetSeverity ¶ added in v0.11.0
func GetSeverity(from Getter, t clusterv1alpha3.ConditionType) *clusterv1alpha3.ConditionSeverity
GetSeverity returns the condition Severity or nil if the condition does not exist (is nil).
func GetTKGBoMTagFromFileName ¶
GetTKGBoMTagFromFileName gets BOM Tag from filename
func GetTKRVersionFromTKRName ¶
GetTKRVersionFromTKRName gets TKr version from TKr name
func GetTkrNameFromTkrVersion ¶
GetTkrNameFromTkrVersion gets TKr name from TKr version
func Has ¶ added in v0.11.0
func Has(from Getter, t clusterv1alpha3.ConditionType) bool
Has returns true if a condition with the given type exists.
func IsFalse ¶ added in v0.11.0
func IsFalse(from Getter, t clusterv1alpha3.ConditionType) bool
IsFalse is true if the condition with the given type is False, otherwise it return false if the condition is not False or if the condition does not exist (is nil).
func IsOnWindows ¶
func IsOnWindows() bool
IsOnWindows returns true if running on a Windows machine.
func IsTrue ¶ added in v0.11.0
func IsTrue(from Getter, t clusterv1alpha3.ConditionType) bool
IsTrue is true if the condition with the given type is True, otherwise it return false if the condition is not True or if the condition does not exist (is nil).
func IsUnknown ¶ added in v0.11.0
func IsUnknown(from Getter, t clusterv1alpha3.ConditionType) bool
IsUnknown is true if the condition with the given type is Unknown or if the condition does not exist (is nil).
func PathExists ¶ added in v0.21.0
PathExists returns true if file/directory exists otherwise returns false
func ReplaceSpecialChars ¶
ReplaceSpecialChars replaces special character in string
func ReplaceVersionInDockerImage ¶
ReplaceVersionInDockerImage replaces version in existing docker image with a new version. This simply replaces the tag in REGISTRY[:PORT]/REPO/MORE/PATH/ELEMENTS/IMAGE[:TAG]
func SHA256FromFile ¶ added in v0.10.0
SHA256FromFile returns SHA256 sum of a file
func SaveFile ¶ added in v0.11.0
SaveFile saves the file to the provided path Also creates missing directories if any
func ToSnakeCase ¶
ToSnakeCase converts string to SnakeCase with all upper case letters
func WriteToFile ¶
WriteToFile writes byte data to file
Types ¶
type Getter ¶ added in v0.11.0
type Getter interface { crtclient.Object GetConditions() clusterv1alpha3.Conditions }
Getter interface defines methods that a Cluster API object should implement in order to use the conditions package for getting conditions.
type PinnipedConfigMapInfo ¶
type PinnipedConfigMapInfo struct { Kind string `json:"kind" yaml:"kind"` Version string `json:"apiVersion" yaml:"apiVersion"` Data struct { ClusterName string `json:"cluster_name" yaml:"cluster_name"` Issuer string `json:"issuer" yaml:"issuer"` IssuerCABundle string `json:"issuer_ca_bundle_data" yaml:"issuer_ca_bundle_data"` ConciergeEndpoint string `json:"concierge_endpoint" yaml:"concierge_endpoint"` ConciergeIsClusterScoped bool `json:"concierge_is_cluster_scoped,string" yaml:"concierge_is_cluster_scoped"` } }
PinnipedConfigMapInfo defines the fields of pinniped-info configMap
func GetPinnipedInfoFromCluster ¶
func GetPinnipedInfoFromCluster(clusterInfo *clientcmdapi.Cluster, discoveryPort *int) (*PinnipedConfigMapInfo, error)
GetPinnipedInfoFromCluster gets the Pinniped Info by accessing the pinniped-info configMap in kube-public namespace 'discoveryPort' is used to optionally override the port used for discovery. This may be needed on setups that expose discovery information to unauthenticated users on a different port (for instance, to avoid the need to anonymous auth on the apiserver). By default, the endpoint from the cluster-info is used.