Documentation ¶
Overview ¶
Package util provides utilities for feature and feature gate functionality.
Index ¶
- Constants
- Variables
- func ComputeFeatureStates(featureGateSpec configv1alpha1.FeatureGateSpec, ...) (activated, deactivated, unavailable []string)
- func FeatureActivatedInNamespace(ctx context.Context, c client.Client, namespace, feature string) (bool, error)
- func FeaturesActivatedInNamespacesMatchingSelector(ctx context.Context, c client.Client, namespaceSelector metav1.LabelSelector, ...) (bool, error)
- func GetFeatureGateForFeature(ctx context.Context, c client.Client, featureName string) (*corev1alpha2.FeatureGate, bool, error)
- func GetFeatureGateWithFeatureInStatus(ctx context.Context, c client.Client, featureName string) (*corev1alpha2.FeatureGate, bool, error)
- func GetFeatureReferenceFromFeatureGate(featureGate *corev1alpha2.FeatureGate, feature string) (corev1alpha2.FeatureReference, bool)
- func IsFeatureActivated(ctx context.Context, c client.Client, featureName string) (bool, error)
- func NamespacesMatchingSelector(ctx context.Context, c client.Client, selector *metav1.LabelSelector) ([]string, error)
Constants ¶
const (
// TKGSystemFeatureGate is the FeatureGate resource for gating TKG features.
TKGSystemFeatureGate = "tkg-system"
)
Variables ¶
var TKGNamespaceSelector = metav1.LabelSelector{ MatchExpressions: []metav1.LabelSelectorRequirement{ {Key: "kubernetes.io/metadata.name", Operator: metav1.LabelSelectorOpIn, Values: []string{"tkg-system-public"}}, }, }
TKGNamespaceSelector is a label selector which matches TKG-related namespaces.
Functions ¶
func ComputeFeatureStates ¶
func ComputeFeatureStates(featureGateSpec configv1alpha1.FeatureGateSpec, features []configv1alpha1.Feature) (activated, deactivated, unavailable []string)
ComputeFeatureStates takes a configv1alpha1 FeatureGate spec and computes the actual state (activated, deactivated or unavailable) of the features in the gate by referring to a list of Feature resources. Deprecated: Use IsFeatureActivated function instead to check if a feature is activated. IsFeatureActivated function checks for feature belonging to core.tanzu.vmware.com is activated or not.
func FeatureActivatedInNamespace ¶
func FeatureActivatedInNamespace(ctx context.Context, c client.Client, namespace, feature string) (bool, error)
FeatureActivatedInNamespace returns true only if all of the features specified are activated in the namespace. Deprecated: Use IsFeatureActivated function instead to check if a feature is activated. IsFeatureActivated function checks for feature belonging to core.tanzu.vmware.com is activated or not.
func FeaturesActivatedInNamespacesMatchingSelector ¶
func FeaturesActivatedInNamespacesMatchingSelector(ctx context.Context, c client.Client, namespaceSelector metav1.LabelSelector, features []string) (bool, error)
FeaturesActivatedInNamespacesMatchingSelector returns true only if all the features specified are activated in every namespace matched by the selector. Deprecated: Use IsFeatureActivated function instead to check if a feature is activated. IsFeatureActivated function checks for feature belonging to core.tanzu.vmware.com is activated or not.
func GetFeatureGateForFeature ¶
func GetFeatureGateForFeature(ctx context.Context, c client.Client, featureName string) (*corev1alpha2.FeatureGate, bool, error)
GetFeatureGateForFeature returns FeatureGate resource that is gating the feature
func GetFeatureGateWithFeatureInStatus ¶
func GetFeatureGateWithFeatureInStatus(ctx context.Context, c client.Client, featureName string) (*corev1alpha2.FeatureGate, bool, error)
GetFeatureGateWithFeatureInStatus returns FeatureGate resource with feature in its status
func GetFeatureReferenceFromFeatureGate ¶
func GetFeatureReferenceFromFeatureGate(featureGate *corev1alpha2.FeatureGate, feature string) (corev1alpha2.FeatureReference, bool)
GetFeatureReferenceFromFeatureGate returns feature reference from FeatureGate spec
func IsFeatureActivated ¶
IsFeatureActivated returns true only if the feature is activated.
func NamespacesMatchingSelector ¶
func NamespacesMatchingSelector(ctx context.Context, c client.Client, selector *metav1.LabelSelector) ([]string, error)
NamespacesMatchingSelector returns the list of namespaces after applying the NamespaceSelector filter. Note that a nil selector selects nothing, while an empty selector selects everything. Callers using this function in feature gates context should be sending a pointer to an empty selector instead of nil.
Types ¶
This section is empty.