Documentation ¶
Index ¶
- Constants
- 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 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 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 InitProgrammed(resource ConditionsAware)
- func InitReady(resource ConditionsAndGenerationAware) bool
- func IsAccepted(resource ConditionsAware) bool
- func IsConditionTrue(cType 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 ListClusterRoleBindingsForOwner(ctx context.Context, c client.Client, uid types.UID, ...) ([]rbacv1.ClusterRoleBinding, error)
- func ListClusterRolesForOwner(ctx context.Context, c client.Client, uid types.UID, ...) ([]rbacv1.ClusterRole, 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 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 ListValidatingWebhookConfigurationsForOwner(ctx context.Context, c client.Client, uid types.UID, ...) ([]admregv1.ValidatingWebhookConfiguration, error)
- func NeedsUpdate(current, updated ConditionsAware) bool
- func NewCondition(cType ConditionType, status metav1.ConditionStatus, reason ConditionReason, ...) metav1.Condition
- func NewConditionWithGeneration(cType ConditionType, status metav1.ConditionStatus, reason ConditionReason, ...) 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 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 ConditionReason
- type ConditionType
- type ConditionsAndGenerationAware
- type ConditionsAndListenerConditionsAndGenerationAware
- type ConditionsAware
- type GetOwnerReferencer
- type ListenersConditionsAware
- type SortableEnvVars
Constants ¶
const ( // ReadyType indicates if the resource has all the dependent conditions Ready ReadyType ConditionType = "Ready" // DependenciesNotReadyReason is a generic reason describing that the other Conditions are not true DependenciesNotReadyReason ConditionReason = "DependenciesNotReady" // ResourceReadyReason indicates the resource is ready ResourceReadyReason ConditionReason = ConditionReason("Ready") // WaitingToBecomeReadyReason generic message for dependent resources waiting to be ready WaitingToBecomeReadyReason ConditionReason = "WaitingToBecomeReady" // ResourceCreatedOrUpdatedReason generic message for missing or outdated resources ResourceCreatedOrUpdatedReason ConditionReason = "ResourceCreatedOrUpdated" // UnableToProvisionReason generic message for unexpected errors UnableToProvisionReason ConditionReason = "UnableToProvision" // DependenciesNotReadyMessage indicates the other conditions are not yet ready DependenciesNotReadyMessage = "There are other conditions that are not yet ready" // WaitingToBecomeReadyMessage indicates the target resource is not ready WaitingToBecomeReadyMessage = "Waiting for the resource to become ready" // ResourceCreatedMessage indicates a missing resource was provisioned ResourceCreatedMessage = "Resource has been created" // ResourceUpdatedMessage indicates a resource was updated ResourceUpdatedMessage = "Resource has been updated" )
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 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 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 InitProgrammed ¶
func InitProgrammed(resource ConditionsAware)
InitProgrammed initializes the Programmed status to False
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 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 ListClusterRoleBindingsForOwner ¶
func ListClusterRoleBindingsForOwner( ctx context.Context, c client.Client, uid types.UID, listOpts ...client.ListOption, ) ([]rbacv1.ClusterRoleBinding, error)
ListClusterRoleBindingsForOwner is a helper function to map a list of ClusterRoleBindings by list options and reduce by OwnerReference UID to efficiently list only the objects owned by the provided UID.
func ListClusterRolesForOwner ¶
func ListClusterRolesForOwner( ctx context.Context, c client.Client, uid types.UID, listOpts ...client.ListOption, ) ([]rbacv1.ClusterRole, error)
ListClusterRolesForOwner is a helper function to map a list of ClusterRoles by 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 is a helper function to map a list of Deployments by 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 to map a list of HorizontalPodAutoscalers by 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 to map a list of Secrets by 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 to map a list of ServiceAccounts by 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 to map a list of Services by list options and reduce by OwnerReference UID and namespace to efficiently list only the objects owned by the provided UID.
func ListValidatingWebhookConfigurationsForOwner ¶
func ListValidatingWebhookConfigurationsForOwner( ctx context.Context, c client.Client, uid types.UID, listOpts ...client.ListOption, ) ([]admregv1.ValidatingWebhookConfiguration, error)
ListValidatingWebhookConfigurationsForOwner is a helper function to map a list of ValidatingWebhookConfiguration by list options and reduce by OwnerReference UID to efficiently list only the objects owned by the provided UID.
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 ConditionType, status metav1.ConditionStatus, reason ConditionReason, message string) metav1.Condition
NewCondition convenience method for creating conditions
func NewConditionWithGeneration ¶
func NewConditionWithGeneration(cType ConditionType, status metav1.ConditionStatus, reason 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 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 ConditionReason ¶
type ConditionReason string
CoditionReason literal to enumerate a specific condition reason
type ConditionType ¶
type ConditionType string
ConditionType literal that defines the different types of condition
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. |