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 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 GetClusterInfoFromCluster(clusterAPIServerURL 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 GetTKGBoMTagFromFileName(fileName string) string
- func GetTKRVersionFromTKRName(tkrName string) string
- func GetTkrNameFromTkrVersion(tkrVersion string) string
- func IsOnWindows() bool
- func IsValidURL(s string) bool
- func ReplaceSpecialChars(str string) string
- func ReplaceVersionInDockerImage(image, newVersion string) (string, error)
- func ToSnakeCase(str string) string
- func WriteToFile(sourceFile string, data []byte) error
- type PinnipedConfigMapInfo
Constants ¶
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 GetClusterInfoFromCluster ¶
func GetClusterInfoFromCluster(clusterAPIServerURL 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 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 IsOnWindows ¶
func IsOnWindows() bool
IsOnWindows returns true if running on a Windows machine.
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 ToSnakeCase ¶
ToSnakeCase converts string to SnakeCase with all upper case letters
func WriteToFile ¶
WriteToFile writes byte data to file
Types ¶
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"` } }
PinnipedConfigMapInfo defines the fields of pinniped-info configMap
func GetPinnipedInfoFromCluster ¶
func GetPinnipedInfoFromCluster(clusterInfo *clientcmdapi.Cluster) (*PinnipedConfigMapInfo, error)
GetPinnipedInfoFromCluster gets the Pinniped Info by accessing the pinniped-info configMap in kube-public namespace