Documentation ¶
Index ¶
- Constants
- func EnsureFinalizersInMetadata(metadata *metav1.ObjectMeta, finalizers ...string) bool
- func EnsureObjectMetaIsUpdated(existingObjMeta metav1.ObjectMeta, generatedObjMeta metav1.ObjectMeta) (toUpdate bool, updatedMeta metav1.ObjectMeta)
- func GenerateOwnerReferenceForObject(obj client.Object) metav1.OwnerReference
- func GetAPIVersionForObject(obj client.Object) string
- func GetCondition(cType ConditionType, resource ConditionsAware) (metav1.Condition, bool)
- func InitReady(resource ConditionsAware)
- func IsEnvVarPresent(envVar corev1.EnvVar, envVars []corev1.EnvVar) (found bool)
- func IsOwnedByRefUID(obj metav1.Object, uid types.UID) bool
- func IsReady(resource ConditionsAware) bool
- func IsValidCondition(cType ConditionType, resource ConditionsAware) bool
- func ListClusterRoleBindingsForOwner(ctx context.Context, c client.Client, requiredLabel string, ...) ([]rbacv1.ClusterRoleBinding, error)
- func ListClusterRolesForOwner(ctx context.Context, c client.Client, requiredLabel string, ...) ([]rbacv1.ClusterRole, error)
- func ListDeploymentsForOwner(ctx context.Context, c client.Client, requiredLabel string, ...) ([]appsv1.Deployment, error)
- func ListSecretsForOwner(ctx context.Context, c client.Client, requiredLabel string, ...) ([]corev1.Secret, error)
- func ListServiceAccountsForOwner(ctx context.Context, c client.Client, requiredLabel string, ...) ([]corev1.ServiceAccount, error)
- func ListServicesForOwner(ctx context.Context, c client.Client, requiredLabel string, ...) ([]corev1.Service, error)
- func NeedsUpdate(current, updated ConditionsAware) bool
- func NewCondition(cType ConditionType, status metav1.ConditionStatus, reason ConditionReason, ...) metav1.Condition
- func RemoveFinalizerInMetadata(metadata *metav1.ObjectMeta, finalizer string) bool
- func SetCondition(condition metav1.Condition, resource ConditionsAware)
- func SetOwnerForObject(obj, owner client.Object)
- func SetReady(resource ConditionsAware)
- type ConditionReason
- type ConditionType
- type ConditionsAware
- 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 = "ResourceReady" // 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 ¶
This section is empty.
Functions ¶
func EnsureFinalizersInMetadata ¶
func EnsureFinalizersInMetadata(metadata *metav1.ObjectMeta, finalizers ...string) bool
EnsureFinalizersInMetadata ensures the expected finalizers exist in ObjectMeta. If the finalizers do not exist, append them to finalizers. Returns true if the ObjectMeta has been changed.
func EnsureObjectMetaIsUpdated ¶
func EnsureObjectMetaIsUpdated( existingObjMeta metav1.ObjectMeta, generatedObjMeta 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 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 InitReady ¶
func InitReady(resource ConditionsAware)
InitReady initializes the Ready status to False
func IsEnvVarPresent ¶
IsEnvVarPresent indicates whether or not a given EnvVar is present in a list
func IsOwnedByRefUID ¶
IsOwnedBy is a helper function to check if the provided object is owned by the provided ref UID.
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 IsValidCondition ¶
func IsValidCondition(cType ConditionType, resource ConditionsAware) bool
IsValidCondition returns a true value whether the condition is ConditionTrue, false otherwise
func ListClusterRoleBindingsForOwner ¶
func ListClusterRoleBindingsForOwner( ctx context.Context, c client.Client, requiredLabel string, requiredValue string, uid types.UID, ) ([]rbacv1.ClusterRoleBinding, error)
ListClusterRoleBindingsForOwner is a helper function to map a list of ClusterRoleBindings by label 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, requiredLabel string, requiredValue string, uid types.UID, ) ([]rbacv1.ClusterRole, error)
ListClusterRolesForOwner is a helper function to map a list of ClusterRoles by label 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, requiredLabel string, requiredValue string, namespace string, uid types.UID, ) ([]appsv1.Deployment, error)
ListDeploymentsForOwner is a helper function to map a list of Deployments by label 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, requiredLabel string, requiredValue string, uid types.UID, ) ([]corev1.Secret, error)
ListSecretsForOwner is a helper function to map a list of Secrets by label 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, requiredLabel string, requiredValue string, namespace string, uid types.UID, ) ([]corev1.ServiceAccount, error)
ListServiceAccountsForOwner is a helper function to map a list of ServiceAccounts by label 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, requiredLabel string, requiredValue string, namespace string, uid types.UID, ) ([]corev1.Service, error)
ListServicesForOwner is a helper function to map a list of Services by label and reduce by OwnerReference UID and namespace 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 RemoveFinalizerInMetadata ¶
func RemoveFinalizerInMetadata(metadata *metav1.ObjectMeta, finalizer string) bool
RemoveFinalizerInMetadata removes the finalizer from the finalizers in ObjectMeta. If it exists, remove the finalizer from the slice. Returns true if the ObjectMeta has been changed.
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 SetReady ¶
func SetReady(resource ConditionsAware)
SetReady evaluates all the existing conditions and sets the Ready status accordingly
Types ¶
type ConditionReason ¶
type ConditionReason string
ConditionReason literal to enumerate a specific condition reason
type ConditionType ¶
type ConditionType string
ConditionType literal that defines the different types of condition
type ConditionsAware ¶
type ConditionsAware interface { GetConditions() []metav1.Condition SetConditions(conditions []metav1.Condition) }
ConditionsAware represents a CRD type that has been enabled with metav1.Conditions, it can then benefit of a series of utility methods.
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)