Documentation ¶
Index ¶
- Variables
- func EnsureObjectMetaIsUpdated(existingMeta metav1.ObjectMeta, generatedMeta metav1.ObjectMeta, ...) (toUpdate bool, updatedMeta metav1.ObjectMeta)
- func EnvValueByName(env []corev1.EnvVar, name string) string
- func EnvVarSourceByName(env []corev1.EnvVar, name string) *corev1.EnvVarSource
- func GenerateOwnerReferenceForObject(obj client.Object) metav1.OwnerReference
- func GetAPIVersionForObject(obj client.Object) string
- func GetCondition(cType consts.ConditionType, resource ConditionsAware) (metav1.Condition, bool)
- func GetContainerVolumeMountByMountPath(container *corev1.Container, mountPath string) *corev1.VolumeMount
- func GetEnvValueFromContainer(ctx context.Context, container *corev1.Container, namespace, name string, ...) (value string, found bool, err error)
- func GetLegacyManagedByLabel[managingObject managingObjectT](object managingObject) map[string]string
- func GetLegacyManagedByLabelSet[managingObject managingObjectT](object managingObject) map[string]string
- func GetManagedByLabelSet[managingObject managingObjectT](object managingObject) map[string]string
- func GetPodContainerByName(podSpec *corev1.PodSpec, name string) *corev1.Container
- func GetPodVolumeByName(podSpec *corev1.PodSpec, name string) *corev1.Volume
- func HasSameVolumeSource(baseVolumeSource, comparedVolumeSource *corev1.VolumeSource) bool
- func InitReady(resource ConditionsAndGenerationAware) bool
- func IsAccepted(resource ConditionsAware) bool
- func IsConditionTrue(cType consts.ConditionType, resource ConditionsAware) bool
- func IsEnvVarPresent(envVar corev1.EnvVar, envVars []corev1.EnvVar) bool
- func IsOwnedByRefUID(obj GetOwnerReferencer, uid types.UID) bool
- func IsProgrammed(resource ConditionsAware) bool
- func IsReady(resource ConditionsAware) bool
- func ListClusterRoleBindings(ctx context.Context, c client.Client, listOpts ...client.ListOption) ([]rbacv1.ClusterRoleBinding, error)
- func ListClusterRoles(ctx context.Context, c client.Client, listOpts ...client.ListOption) ([]rbacv1.ClusterRole, error)
- func ListConfigMapsForOwner(ctx context.Context, c client.Client, uid types.UID, ...) ([]corev1.ConfigMap, error)
- func ListDeploymentsForOwner(ctx context.Context, c client.Client, namespace string, uid types.UID, ...) ([]appsv1.Deployment, error)
- func ListHPAsForOwner(ctx context.Context, c client.Client, namespace string, uid types.UID, ...) ([]autoscalingv2.HorizontalPodAutoscaler, error)
- func ListPodDisruptionBudgetsForOwner(ctx context.Context, c client.Client, namespace string, uid types.UID, ...) ([]policyv1.PodDisruptionBudget, error)
- func ListSecretsForOwner(ctx context.Context, c client.Client, uid types.UID, ...) ([]corev1.Secret, error)
- func ListServiceAccountsForOwner(ctx context.Context, c client.Client, namespace string, uid types.UID, ...) ([]corev1.ServiceAccount, error)
- func ListServicesForOwner(ctx context.Context, c client.Client, namespace string, uid types.UID, ...) ([]corev1.Service, error)
- func ListValidatingWebhookConfigurations(ctx context.Context, c client.Client, listOpts ...client.ListOption) ([]admregv1.ValidatingWebhookConfiguration, error)
- func ListValidatingWebhookConfigurationsForOwner(ctx context.Context, c client.Client, uid types.UID, ...) ([]admregv1.ValidatingWebhookConfiguration, error)
- func NeedsUpdate(current, updated ConditionsAware) bool
- func NewCondition(cType consts.ConditionType, status metav1.ConditionStatus, ...) metav1.Condition
- func NewConditionWithGeneration(cType consts.ConditionType, status metav1.ConditionStatus, ...) metav1.Condition
- func RejectEnvByName(envVars []corev1.EnvVar, name string) []corev1.EnvVar
- func SetAcceptedConditionOnGateway(resource ConditionsAndListenerConditionsAndGenerationAware)
- func SetCondition(condition metav1.Condition, resource ConditionsAware)
- func SetOwnerForObject(obj, owner client.Object)
- func SetOwnerForObjectThroughLabels[managingObject managingObjectT](obj client.Object, owner managingObject)
- func SetPodContainer(podSpec *corev1.PodSpec, container *corev1.Container)
- func SetProgrammed(resource ConditionsAndGenerationAware)
- func SetReady(resource ConditionsAndGenerationAware)
- func SetReadyWithGeneration(resource ConditionsAndGenerationAware, generation int64)
- func TrimGenerateName(name string) string
- func UpdateEnv(envVars []corev1.EnvVar, name, val string) []corev1.EnvVar
- func UpdateEnvSource(envVars []corev1.EnvVar, name string, envSource *corev1.EnvVarSource) []corev1.EnvVar
- type CRDChecker
- type ConditionsAndGenerationAware
- type ConditionsAndListenerConditionsAndGenerationAware
- type ConditionsAware
- type GetOwnerReferencer
- type ListenersConditionsAware
- type SortableEnvVars
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExtractValueFromEnvSourceNotImplemented is the error when the Env references value from `ResourceRef` or `FieldRef` // that we do not support to extract values yet. ErrExtractValueFromEnvSourceNotImplemented = errors.New("EnvSource type not implemented for extracting value yet") )
Functions ¶
func EnsureObjectMetaIsUpdated ¶
func EnsureObjectMetaIsUpdated( existingMeta metav1.ObjectMeta, generatedMeta metav1.ObjectMeta, options ...func(existingMeta, generatedMeta metav1.ObjectMeta) (bool, metav1.ObjectMeta), ) (toUpdate bool, updatedMeta metav1.ObjectMeta)
EnsureObjectMetaIsUpdated ensures that the existing object metadata has all the needed fields set. The source of truth is the second argument of the function, a generated object metadata.
func EnvValueByName ¶
EnvValueByName returns the value of the first env var with the given name. If no env var with the given name is found, an empty string is returned.
func EnvVarSourceByName ¶
func EnvVarSourceByName(env []corev1.EnvVar, name string) *corev1.EnvVarSource
EnvVarSourceByName returns the ValueFrom of the first env var with the given name. returns nil if env var is not found, or does not have a ValueFrom field.
func GenerateOwnerReferenceForObject ¶
func GenerateOwnerReferenceForObject(obj client.Object) metav1.OwnerReference
GenerateOwnerReferenceForObject provides a metav1.OwnerReference for the provided object so that it can be applied to other objects to indicate ownership by the given object.
func GetAPIVersionForObject ¶
GetAPIVersionForObject provides the string of the full group and version for the provided object, e.g. "apps/v1"
func GetCondition ¶
func GetCondition(cType consts.ConditionType, resource ConditionsAware) (metav1.Condition, bool)
GetCondition returns the condition with the given type, if it exists. If the condition does not exists it returns false.
func GetContainerVolumeMountByMountPath ¶
func GetContainerVolumeMountByMountPath(container *corev1.Container, mountPath string) *corev1.VolumeMount
GetContainerVolumeMountByPath gets the volume mounted to given path in container. if the mount path does not exist, it returns `nil`.
func GetEnvValueFromContainer ¶
func GetEnvValueFromContainer(ctx context.Context, container *corev1.Container, namespace, name string, c client.Client) (value string, found bool, err error)
GetEnvValueFromContainer returns value of environment variable with given name in the given container. It returns true in the second return value if the env var is found in any of the following formats:
- Directly given in `value` of an item in `envs` of the container.
- Fetched from given record of `ConfigMap` or `Secret` in `valueFrom` of an `env` item
- Fetched from the record of `ConfigMap` or `Secret` in an `envFrom` item, where name is concatated from `envFrom.Prefix` and key of record in `ConfigMap` or `SecretMap`.
It returns a non-nil error if error happens in fetching the value.
func GetLegacyManagedByLabel ¶ added in v1.4.0
func GetLegacyManagedByLabel[managingObject managingObjectT](object managingObject) map[string]string
GetLegacyManagedByLabel returns a map of legacy labels with the provided object's metadata. These can be applied to other objects that are owned by the object provided as an argument.
func GetLegacyManagedByLabelSet ¶ added in v1.4.0
func GetLegacyManagedByLabelSet[managingObject managingObjectT](object managingObject) map[string]string
GetLegacyManagedByLabelSet returns a map of legacy labels with the provided object's metadata. These can be applied to other objects that are owned by the object provided as an argument.
func GetManagedByLabelSet ¶ added in v1.3.0
GetManagedByLabelSet returns a map of labels with the provided object's metadata. These can be applied to other objects that are owned by the object provided as an argument.
func GetPodContainerByName ¶
GetPodContainerByName takes a PodSpec reference and a string and returns a reference to the container in the PodSpec with that name, if any exists.
func GetPodVolumeByName ¶
GetPodVolumeByName gets the pointer of volume with given name. if the volume with given name does not exist in the pod, it returns `nil`.
func HasSameVolumeSource ¶
func HasSameVolumeSource(baseVolumeSource, comparedVolumeSource *corev1.VolumeSource) bool
HasSameVolumeSource returns true if the two volume sources are the same and we do not need to update the volume in deployments. currently it can only compare secrets.
func InitReady ¶
func InitReady(resource ConditionsAndGenerationAware) bool
InitReady initializes the Ready status to False if Ready condition is not yet set on the resource.
func IsAccepted ¶
func IsAccepted(resource ConditionsAware) bool
IsAccepted evaluates whether a resource is in Accepted state, meaning that all its listeners are accepted.
func IsConditionTrue ¶
func IsConditionTrue(cType consts.ConditionType, resource ConditionsAware) bool
IsConditionTrue returns a true value whether the condition is ConditionTrue, false otherwise
func IsEnvVarPresent ¶
IsEnvVarPresent indicates whether or not a given EnvVar is present in a list.
func IsOwnedByRefUID ¶
func IsOwnedByRefUID(obj GetOwnerReferencer, uid types.UID) bool
IsOwnedBy is a helper function to check if the provided object is owned by the provided ref UID.
func IsProgrammed ¶
func IsProgrammed(resource ConditionsAware) bool
IsProgrammed evaluates whether a resource is in Programmed state.
func IsReady ¶
func IsReady(resource ConditionsAware) bool
IsReady evaluates whether a resource is in Ready state, meaning that all its conditions are in the True state.
func ListClusterRoleBindings ¶ added in v1.3.0
func ListClusterRoleBindings( ctx context.Context, c client.Client, listOpts ...client.ListOption, ) ([]rbacv1.ClusterRoleBinding, error)
ListClusterRoleBindings is a helper function which gets a list of ClusterRoleBindings using the provided list options.
func ListClusterRoles ¶ added in v1.3.0
func ListClusterRoles( ctx context.Context, c client.Client, listOpts ...client.ListOption, ) ([]rbacv1.ClusterRole, error)
ListClusterRoles is a helper function which gets a list of ClusterRoles using the provided list options.
func ListConfigMapsForOwner ¶ added in v1.4.0
func ListConfigMapsForOwner(ctx context.Context, c client.Client, uid types.UID, listOpts ...client.ListOption, ) ([]corev1.ConfigMap, error)
ListConfigMapsForOwner is a helper function which gets a list of ConfigMaps using the provided list options and reduce by OwnerReference UID to efficiently list only the objects owned by the provided UID.
func ListDeploymentsForOwner ¶
func ListDeploymentsForOwner( ctx context.Context, c client.Client, namespace string, uid types.UID, listOpts ...client.ListOption, ) ([]appsv1.Deployment, error)
ListDeploymentsForOwner which gets a list of Deployments using the provided list options and reduce by OwnerReference UID and namespace to efficiently list only the objects owned by the provided UID.
func ListHPAsForOwner ¶
func ListHPAsForOwner( ctx context.Context, c client.Client, namespace string, uid types.UID, listOpts ...client.ListOption, ) ([]autoscalingv2.HorizontalPodAutoscaler, error)
ListHPAsForOwner is a helper function which gets a list of HorizontalPodAutoscalers using the provided list options and reduce by OwnerReference UID and namespace to efficiently list only the objects owned by the provided UID.
func ListPodDisruptionBudgetsForOwner ¶ added in v1.4.0
func ListPodDisruptionBudgetsForOwner( ctx context.Context, c client.Client, namespace string, uid types.UID, listOpts ...client.ListOption, ) ([]policyv1.PodDisruptionBudget, error)
ListPodDisruptionBudgetsForOwner is a helper function which gets a list of PodDisruptionBudget using the provided list options and reduce by OwnerReference UID and namespace to efficiently list only the objects owned by the provided UID.
func ListSecretsForOwner ¶
func ListSecretsForOwner(ctx context.Context, c client.Client, uid types.UID, listOpts ...client.ListOption, ) ([]corev1.Secret, error)
ListSecretsForOwner is a helper function which gets a list of Secrets using the provided list options and reduce by OwnerReference UID to efficiently list only the objects owned by the provided UID.
func ListServiceAccountsForOwner ¶
func ListServiceAccountsForOwner( ctx context.Context, c client.Client, namespace string, uid types.UID, listOpts ...client.ListOption, ) ([]corev1.ServiceAccount, error)
ListServiceAccountsForOwner is a helper function which gets a list of ServiceAccounts using the provided list options and reduce by OwnerReference UID and namespace to efficiently list only the objects owned by the provided UID.
func ListServicesForOwner ¶
func ListServicesForOwner( ctx context.Context, c client.Client, namespace string, uid types.UID, listOpts ...client.ListOption, ) ([]corev1.Service, error)
ListServicesForOwner is a helper function which gets a list of Services using the provided list options and reduce by OwnerReference UID and namespace to efficiently list only the objects owned by the provided UID.
func ListValidatingWebhookConfigurations ¶ added in v1.3.0
func ListValidatingWebhookConfigurations( ctx context.Context, c client.Client, listOpts ...client.ListOption, ) ([]admregv1.ValidatingWebhookConfiguration, error)
ListValidatingWebhookConfigurations is a helper function that gets a list of ValidatingWebhookConfiguration using the provided list options.
func ListValidatingWebhookConfigurationsForOwner ¶
func ListValidatingWebhookConfigurationsForOwner( ctx context.Context, c client.Client, uid types.UID, listOpts ...client.ListOption, ) ([]admregv1.ValidatingWebhookConfiguration, error)
ListValidatingWebhookConfigurationsForOwner is a helper function that gets a list of ValidatingWebhookConfiguration using the provided list options and checking if the provided object is the owner.
func NeedsUpdate ¶
func NeedsUpdate(current, updated ConditionsAware) bool
NeedsUpdate retrieves the persisted state and compares all the conditions to decide whether the status must be updated or not
func NewCondition ¶
func NewCondition(cType consts.ConditionType, status metav1.ConditionStatus, reason consts.ConditionReason, message string) metav1.Condition
NewCondition convenience method for creating conditions
func NewConditionWithGeneration ¶
func NewConditionWithGeneration(cType consts.ConditionType, status metav1.ConditionStatus, reason consts.ConditionReason, message string, observedGeneration int64) metav1.Condition
NewConditionWithGeneration convenience method for creating conditions with ObservedGeneration set.
func RejectEnvByName ¶
RejectEnvByName returns a copy of the given env vars, but with the env vars with the given name removed.
func SetAcceptedConditionOnGateway ¶
func SetAcceptedConditionOnGateway(resource ConditionsAndListenerConditionsAndGenerationAware)
SetAcceptedConditionOnGateway sets the gateway Accepted condition according to the Gateway API specification.
func SetCondition ¶
func SetCondition(condition metav1.Condition, resource ConditionsAware)
SetCondition sets a new condition to the provided resource
func SetOwnerForObject ¶
SetOwnerForObject ensures that the provided first object is marked as owned by the provided second object in the object metadata.
func SetOwnerForObjectThroughLabels ¶ added in v1.3.0
func SetOwnerForObjectThroughLabels[managingObject managingObjectT](obj client.Object, owner managingObject)
SetOwnerForObjectThroughLabels sets the owner of the provided object through a label.
func SetPodContainer ¶
SetPodContainer appends a container to the list of containers if it does not exists, or it overwrites the existing container, in case it exists.
func SetProgrammed ¶
func SetProgrammed(resource ConditionsAndGenerationAware)
SetProgrammed evaluates all the existing conditions and sets the Programmed status accordingly
func SetReady ¶
func SetReady(resource ConditionsAndGenerationAware)
SetReady evaluates all the existing conditions and sets the Ready status accordingly.
func SetReadyWithGeneration ¶
func SetReadyWithGeneration(resource ConditionsAndGenerationAware, generation int64)
SetReadyWithGeneration sets the Ready status to True if all the other conditions are True. It uses the provided generation to set the ObservedGeneration field.
func TrimGenerateName ¶
TrimGenerateName cut the string to 63 chars, in case it is longer, to be compliant with the GenerateName length maximum size of 63 chars.
func UpdateEnv ¶
UpdateEnv set env var with name to have val and returns the updated env vars. If no env var with the given `name“ is found, a new env var is appended to the list.
func UpdateEnvSource ¶
func UpdateEnvSource(envVars []corev1.EnvVar, name string, envSource *corev1.EnvVarSource) []corev1.EnvVar
UpdateEnvSource updates env var with `name` to come from `envSource`. If no env var with the given `name` is found, a new env var is appended to the list.
Types ¶
type CRDChecker ¶ added in v1.3.0
CRDChecker verifies whether the resource type defined by GVR is supported by the k8s apiserver.
func (CRDChecker) CRDExists ¶ added in v1.3.0
func (c CRDChecker) CRDExists(gvr schema.GroupVersionResource) (bool, error)
CRDExists returns true if the apiserver supports the specified group/version/resource.
type ConditionsAndGenerationAware ¶
type ConditionsAndGenerationAware interface { GetGeneration() int64 ConditionsAware }
ConditionsAndGenerationAware represents a CRD type that has been enabled with metav1.Conditions, it can then benefit of a series of utility methods.
type ConditionsAndListenerConditionsAndGenerationAware ¶
type ConditionsAndListenerConditionsAndGenerationAware interface { ConditionsAndGenerationAware ListenersConditionsAware }
ConditionsAndListenerConditionsAndGenerationAware is a CRD type that has Conditions, Generation, and Listener Conditions.
type ConditionsAware ¶
type ConditionsAware interface { GetConditions() []metav1.Condition SetConditions(conditions []metav1.Condition) }
ConditionsAware is a CRD that has Conditions.
type GetOwnerReferencer ¶
type GetOwnerReferencer interface {
GetOwnerReferences() []metav1.OwnerReference
}
GetOwnerReferencer retrieves owner references.
type ListenersConditionsAware ¶
type ListenersConditionsAware interface { GetListenersConditions() []gatewayv1.ListenerStatus SetListenersConditions([]gatewayv1.ListenerStatus) }
ListenersConditionsAware is a CRD that has Listener Conditions.
type SortableEnvVars ¶
SortableEnvVars is a wrapper around []corev1.EnvVars that enables sorting them lexographically by name.
func (SortableEnvVars) Len ¶
func (s SortableEnvVars) Len() int
func (SortableEnvVars) Less ¶
func (s SortableEnvVars) Less(i, j int) bool
func (SortableEnvVars) Swap ¶
func (s SortableEnvVars) Swap(i, j int)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
clusterroles
This file is generated by /hack/generators/kic/role-generator.
|
This file is generated by /hack/generators/kic/role-generator. |