Documentation ¶
Overview ¶
Package util implements various utility functionality for working with clusters TKR, BOMs, and others.
Index ¶
- func ClustersToRequests(clusters []*clusterv1beta1.Cluster, log logr.Logger) []ctrl.Request
- func ExtractTypedLocalObjectRef(unstructuredContent map[string]interface{}, fieldSuffix string) map[schema.GroupKind][]string
- func GenerateAppNameFromAddonSecret(addonSecret *corev1.Secret) string
- func GenerateAppNamespaceFromAddonSecret(addonSecret *corev1.Secret, defaultAddonNamespace string) string
- func GenerateAppSecretNameFromAddonSecret(addonSecret *corev1.Secret) string
- func GenerateDataValueSecretName(clusterName, carvelPkgRefName string) string
- func GeneratePackageInstallName(clusterName, addonName string) string
- func GeneratePackageSecretName(clusterName, carvelPkgRefName string) string
- func GetAddonImageRepository(ctx context.Context, c client.Client, bom *tkrv1.Bom) (string, error)
- func GetAddonNameFromAddonSecret(addonSecret *corev1.Secret) string
- func GetAddonSecretsForCluster(ctx context.Context, c client.Client, cluster *clusterapiv1beta1.Cluster) (*corev1.SecretList, error)
- func GetApp(ctx context.Context, localClient client.Client, remoteClient client.Client, ...) (*kappctrl.App, error)
- func GetBOMByTKRName(ctx context.Context, c client.Client, tkrName string) (*tkrv1.Bom, error)
- func GetBOMForCluster(ctx context.Context, c client.Client, cluster *clusterv1beta1.Cluster) (*tkrv1.Bom, error)
- func GetBootstrapPackageNameFromTKR(ctx context.Context, clt client.Client, pkgRefName string, ...) (string, string, error)
- func GetClientFromAddonSecret(addonSecret *corev1.Secret, localClient, remoteClient client.Client) client.Client
- func GetClusterByName(ctx context.Context, c client.Client, namespace, name string) (*clusterv1beta1.Cluster, error)
- func GetClusterClient(ctx context.Context, currentClusterClient client.Client, ...) (client.Client, error)
- func GetClusterLabel(clusterLabels map[string]string, labelKey string) string
- func GetClusterNameFromAddonSecret(addonSecret *corev1.Secret) string
- func GetClustersByTKR(ctx context.Context, c client.Client, ...) ([]*clusterv1beta1.Cluster, error)
- func GetCorePackageRepositoryImageFromBom(bom *tkrv1.Bom) (*tkrv1.ImageInfo, error)
- func GetGVRForGroupKind(gk schema.GroupKind, discoveryClient discovery.CachedDiscoveryInterface) (*schema.GroupVersionResource, error)
- func GetImageInfo(addonConfig *tkrv1.Addon, imageRepository, imagePullPolicy string, ...) ([]byte, error)
- func GetInfraProvider(cluster *clusterv1beta1.Cluster) (string, error)
- func GetKappUsefulErrorMessage(s string) string
- func GetOwnerCluster(ctx context.Context, c client.Client, obj *metav1.ObjectMeta) (*clusterv1beta1.Cluster, error)
- func GetPackageInstallFromAddonSecret(ctx context.Context, remoteClient client.Client, addonSecret *corev1.Secret, ...) (*pkgiv1alpha1.PackageInstall, error)
- func GetPackageMetadata(ctx context.Context, c client.Client, carvelPkgName, carvelPkgNamespace string) (string, string, error)
- func GetServiceCIDRs(cluster *clusterapiv1beta1.Cluster) (string, string, error)
- func GetTKRByNameV1Alpha1(ctx context.Context, c client.Client, tkrName string) (*runtanzuv1alpha1.TanzuKubernetesRelease, error)
- func GetTKRByNameV1Alpha3(ctx context.Context, c client.Client, cluster *clusterapiv1beta1.Cluster, ...) (*runtanzuv1alpha3.TanzuKubernetesRelease, error)
- func GetTKRNameFromBOMConfigMap(bomConfigMap *corev1.ConfigMap) string
- func GetTemplateImageURLFromBom(addonConfig *tkrv1.Addon, imageRepository string, bom *tkrv1.Bom) (string, error)
- func GetTkgBomConfigMapByName(ctx context.Context, c client.Client, configmapName string) (*tkrv1.TkgBom, error)
- func GetTkgBomForCluster(ctx context.Context, c client.Client, tkrName string) (*tkrv1.TkgBom, error)
- func HasSameState(i, j *clusterapiv1beta1.Condition) bool
- func IsAddonPaused(addonSecret *corev1.Secret) bool
- func IsAppPresent(ctx context.Context, localClient client.Client, remoteClient client.Client, ...) (bool, error)
- func IsPackageInstallPresent(ctx context.Context, localClient client.Client, addonSecret *corev1.Secret, ...) (bool, error)
- func IsRemoteApp(addonSecret *corev1.Secret) bool
- func IsTKGSCluster(ctx context.Context, dynamicClient dynamic.Interface, ...) (bool, error)
- func ParseClusterVariableBool(cluster *clusterapiv1beta1.Cluster, variableName string) (bool, error)
- func ParseClusterVariableCert(cluster *clusterapiv1beta1.Cluster, variableName, keyName, data string) (string, error)
- func ParseClusterVariableInterface(cluster *clusterapiv1beta1.Cluster, variableName, keyName string) (string, error)
- func ParseClusterVariableInterfaceArray(cluster *clusterapiv1beta1.Cluster, variableName, keyName string) ([]string, error)
- func ParseClusterVariableList(cluster *clusterapiv1beta1.Cluster, variableName string) (string, error)
- func ParseClusterVariableString(cluster *clusterapiv1beta1.Cluster, variableName string) (string, error)
- func ParseStringForLabel(s string) string
- func SummarizeAppConditions(conditions []v1alpha1.AppCondition) *v1alpha1.AppCondition
- type ClusterKubeconfigSecretDetails
- type GVRHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClustersToRequests ¶
ClustersToRequests returns a list of Requests for clusters
func ExtractTypedLocalObjectRef ¶
func ExtractTypedLocalObjectRef(unstructuredContent map[string]interface{}, fieldSuffix string) map[schema.GroupKind][]string
ExtractTypedLocalObjectRef extracts the TypedLocalObjectReference from the unstructuredContent by looking at the fields which has the specified fieldSuffix. Returns a map with groupKind as the key and object names as the value
func GenerateAppNameFromAddonSecret ¶
GenerateAppNameFromAddonSecret generates app name given an addon secret
func GenerateAppNamespaceFromAddonSecret ¶
func GenerateAppNamespaceFromAddonSecret(addonSecret *corev1.Secret, defaultAddonNamespace string) string
GenerateAppNamespaceFromAddonSecret generates app namespace from addons secret
func GenerateAppSecretNameFromAddonSecret ¶
GenerateAppSecretNameFromAddonSecret generates app secret name from addon secret
func GenerateDataValueSecretName ¶
GenerateDataValueSecretName generates data value secret name from the cluster and the package name
func GeneratePackageInstallName ¶
GeneratePackageInstallName is the util function to generate the PackageInstall CR name in a consistent manner. clusterName is the name of cluster within which all resources associated with this PackageInstall CR is installed. It does not necessarily mean the PackageInstall CR will be installed in that cluster. I.e., the kapp-controller PackageInstall CR is installed in the management cluster but is named after "<workload-cluster-name>-kapp-controller". It indicates that this kapp-controller PackageInstall is for reconciling resources in a cluster named "<workload-cluster-name>". addonName is the short name of a Tanzu addon with which the PackageInstall CR is associated.
func GeneratePackageSecretName ¶
GeneratePackageSecretName generates secret name for a package from the cluster and the package name
func GetAddonImageRepository ¶
GetAddonImageRepository returns imageRepository from configMap `tkr-controller-config` in namespace `tkg-system`. If not found, try the legacy `tkr-system`, else use BOM
func GetAddonNameFromAddonSecret ¶
GetAddonNameFromAddonSecret gets the addon name from addon secret
func GetAddonSecretsForCluster ¶
func GetAddonSecretsForCluster(ctx context.Context, c client.Client, cluster *clusterapiv1beta1.Cluster) (*corev1.SecretList, error)
GetAddonSecretsForCluster gets the addon secrets belonging to the cluster
func GetApp ¶
func GetApp(ctx context.Context, localClient client.Client, remoteClient client.Client, addonSecret *corev1.Secret, defaultAddonNamespace string) (*kappctrl.App, error)
GetApp gets the app CR from cluster
func GetBOMByTKRName ¶
GetBOMByTKRName returns the bom associated with the TKR
func GetBOMForCluster ¶
func GetBOMForCluster(ctx context.Context, c client.Client, cluster *clusterv1beta1.Cluster) (*tkrv1.Bom, error)
GetBOMForCluster gets the bom associated with the legacy-style TKGm cluster
func GetBootstrapPackageNameFromTKR ¶
func GetBootstrapPackageNameFromTKR(ctx context.Context, clt client.Client, pkgRefName string, cluster *clusterapiv1beta1.Cluster) (string, string, error)
GetBootstrapPackageNameFromTKR tries to find the prefix of the provided package RefName in the bootstrap packages of the TKR v1Alpha3 object associated with the cluster. Upon finding the corresponding bootstrap package name, it returns it as the bumped version of the package
func GetClientFromAddonSecret ¶
func GetClientFromAddonSecret(addonSecret *corev1.Secret, localClient, remoteClient client.Client) client.Client
GetClientFromAddonSecret gets appropriate cluster client given addon secret
func GetClusterByName ¶
func GetClusterByName(ctx context.Context, c client.Client, namespace, name string) (*clusterv1beta1.Cluster, error)
GetClusterByName finds and return a Cluster object using the specified params.
func GetClusterClient ¶
func GetClusterClient(ctx context.Context, currentClusterClient client.Client, scheme *runtime.Scheme, cluster client.ObjectKey) (client.Client, error)
GetClusterClient gets cluster's client
func GetClusterLabel ¶
func GetClusterNameFromAddonSecret ¶
GetClusterNameFromAddonSecret gets the cluster name from addon secret
func GetClustersByTKR ¶
func GetClustersByTKR(ctx context.Context, c client.Client, tkr *runtanzuv1alpha1.TanzuKubernetesRelease) ([]*clusterv1beta1.Cluster, error)
GetClustersByTKR gets the clusters using this TKR
func GetCorePackageRepositoryImageFromBom ¶
GetCorePackageRepositoryImageFromBom generates the core PackageRepository Object
func GetGVRForGroupKind ¶
func GetGVRForGroupKind(gk schema.GroupKind, discoveryClient discovery.CachedDiscoveryInterface) (*schema.GroupVersionResource, error)
GetGVRForGroupKind returns a GroupVersionResource for a GroupKind
func GetImageInfo ¶
func GetImageInfo(addonConfig *tkrv1.Addon, imageRepository, imagePullPolicy string, bom *tkrv1.Bom) ([]byte, error)
GetImageInfo gets the image Info of an addon
func GetInfraProvider ¶
func GetInfraProvider(cluster *clusterv1beta1.Cluster) (string, error)
GetInfraProvider get infrastructure kind from cluster spec
func GetKappUsefulErrorMessage ¶
GetKappUsefulErrorMessage extracts the relevant portion from UsefulErrorMessage
func GetOwnerCluster ¶
func GetOwnerCluster(ctx context.Context, c client.Client, obj *metav1.ObjectMeta) (*clusterv1beta1.Cluster, error)
GetOwnerCluster returns the Cluster object owning the current resource.
func GetPackageInstallFromAddonSecret ¶
func GetPackageInstallFromAddonSecret(ctx context.Context, remoteClient client.Client, addonSecret *corev1.Secret, defaultAddonNamespace string) (*pkgiv1alpha1.PackageInstall, error)
GetPackageInstallFromAddonSecret gets the PackageInstall CR from cluster
func GetPackageMetadata ¶
func GetServiceCIDRs ¶
func GetServiceCIDRs(cluster *clusterapiv1beta1.Cluster) (string, string, error)
GetServiceCIDRs returns the Service CIDR blocks for both IPv4 and IPv6 family Parse Service CIDRBlocks obtained from the cluster and return the following from the function: <IPv4 CIDRs, IPv6 CIDRs, error> The first two return parameters should be used only if the function returns error as nil. Also, note that when no error is returned, IPv4 and/or IPv6 CIDRs may still be empty depending on the cluster Service CIDR Blocks
func GetTKRByNameV1Alpha1 ¶
func GetTKRByNameV1Alpha1(ctx context.Context, c client.Client, tkrName string) (*runtanzuv1alpha1.TanzuKubernetesRelease, error)
GetTKRByNameV1Alpha1 gets v1Alpha1 TKR object given a TKR name
func GetTKRByNameV1Alpha3 ¶
func GetTKRByNameV1Alpha3(ctx context.Context, c client.Client, cluster *clusterapiv1beta1.Cluster, tkrName string) (*runtanzuv1alpha3.TanzuKubernetesRelease, error)
GetTKRByNameV1Alpha3 gets v1Alpha3 TKR object given a TKR name
func GetTKRNameFromBOMConfigMap ¶
GetTKRNameFromBOMConfigMap returns tkr name given a bom configmap
func GetTemplateImageURLFromBom ¶
func GetTemplateImageURLFromBom(addonConfig *tkrv1.Addon, imageRepository string, bom *tkrv1.Bom) (string, error)
GetTemplateImageURLFromBom gets the image template image url of an addon This method first checks if packageName is present in addonConfig If packageName is present, it will use it to find imgpkg bundle in tkg-core-packages If packageName is not present, it will look for addonTemplatesImage addonTemplatesImage should be present in a 1.3.1 cluster, and will be used to find images in tanzu_core_addons If addonTemplatesImage is not present, it will fall back to using templatesImagePath and templatesImageTag to find template images
func GetTkgBomForCluster ¶
func HasSameState ¶
func HasSameState(i, j *clusterapiv1beta1.Condition) bool
HasSameState returns true if a ClusterBootstrap condition has the same state of another; state is defined by the union of following fields: Type, Status, Message, Reason (it excludes LastTransitionTime).
func IsAddonPaused ¶
IsAddonPaused returns true if Addon is paused
func IsAppPresent ¶
func IsAppPresent(ctx context.Context, localClient client.Client, remoteClient client.Client, addonSecret *corev1.Secret, defaultAddonNamespace string) (bool, error)
IsAppPresent returns true if app is present on the cluster
func IsPackageInstallPresent ¶
func IsPackageInstallPresent(ctx context.Context, localClient client.Client, addonSecret *corev1.Secret, defaultAddonNamespace string) (bool, error)
IsPackageInstallPresent returns true if PackageInstall is present on the cluster
func IsRemoteApp ¶
IsRemoteApp returns true if App needs to be remote instead of App being on local cluster
func IsTKGSCluster ¶
func IsTKGSCluster(ctx context.Context, dynamicClient dynamic.Interface, discoveryClient discovery.DiscoveryInterface, cluster *clusterv1beta1.Cluster) (bool, error)
IsTKGSCluster checks if the cluster is a TKGS cluster
func ParseClusterVariableBool ¶
func ParseClusterVariableBool(cluster *clusterapiv1beta1.Cluster, variableName string) (bool, error)
func ParseClusterVariableCert ¶
func ParseClusterVariableCert(cluster *clusterapiv1beta1.Cluster, variableName, keyName, data string) (string, error)
Decode all certificate then append them in single string, then ecode them together
func ParseClusterVariableInterface ¶
func ParseClusterVariableInterface(cluster *clusterapiv1beta1.Cluster, variableName, keyName string) (string, error)
func ParseClusterVariableInterfaceArray ¶
func ParseClusterVariableInterfaceArray(cluster *clusterapiv1beta1.Cluster, variableName, keyName string) ([]string, error)
func ParseClusterVariableList ¶
func ParseClusterVariableList(cluster *clusterapiv1beta1.Cluster, variableName string) (string, error)
func ParseClusterVariableString ¶
func ParseClusterVariableString(cluster *clusterapiv1beta1.Cluster, variableName string) (string, error)
func ParseStringForLabel ¶
ParseStringForLabel parse the package ref name to make it valid for K8S object labels. A package ref name could contain some characters that are not allowed as a label value. Also the label should not end with any non-alphanumeric characters. The regex used for validation is (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?
func SummarizeAppConditions ¶
func SummarizeAppConditions(conditions []v1alpha1.AppCondition) *v1alpha1.AppCondition
SummarizeAppConditions summarizes the provided conditions slice into a single condition with the following logic: - If there be any 'Reconciling' condition type with status 'True', the summary condition type will be 'Reconciling' - Otherwise, if there be any 'ReconcileFailed' condition type with status 'True', the summary condition type will be 'ReconcileFailed' - Otherwise, if there be any 'ReconcileSucceeded' condition type with status 'True', the summary condition type will be 'ReconcileSucceeded' - Otherwise, if there be any 'Deleting' condition type with status 'True', the summary condition type will be 'Deleting' - Otherwise, if there be any 'DeleteFailed' condition type with status 'True', the summary condition type will be 'DeleteFailed' - Otherwise, the condition type is unknown and nil will be returned Note that ReconcileFailed|Reconciling|ReconcileSucceeded|Deleting|DeleteFailed|DeleteSucceeded are mutually exclusive
Types ¶
type ClusterKubeconfigSecretDetails ¶
ClusterKubeconfigSecretDetails contains the cluster kubeconfig secret details.
func GetClusterKubeconfigSecretDetails ¶
func GetClusterKubeconfigSecretDetails(cluster *clusterv1beta1.Cluster) *ClusterKubeconfigSecretDetails
GetClusterKubeconfigSecretDetails returns the name, namespace and key of the cluster's kubeconfig secret
type GVRHelper ¶
type GVRHelper interface { GetGVR(gk schema.GroupKind) (*schema.GroupVersionResource, error) GetDiscoveryClient() discovery.DiscoveryInterface }
func NewGVRHelper ¶
func NewGVRHelper(ctx context.Context, discoveryClient discovery.DiscoveryInterface) GVRHelper
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package clusterbootstrapclone provides helper functions to create ClusterBootstrap CR and clones its associated objects.
|
Package clusterbootstrapclone provides helper functions to create ClusterBootstrap CR and clones its associated objects. |