Documentation
¶
Overview ¶
Package patch implements patch utilities.
Deprecated: This package is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clusterv1ConditionsFieldPath ¶
type Clusterv1ConditionsFieldPath []string
Clusterv1ConditionsFieldPath allows to override the path for the field hosting clusterv1.Conditions. Please note that the default value for this option is inferred from the object struct. The override for this option is considered only if the object implements the conditions.Setter interface.
func (Clusterv1ConditionsFieldPath) ApplyToHelper ¶
func (w Clusterv1ConditionsFieldPath) ApplyToHelper(in *HelperOptions)
ApplyToHelper applies this configuration to the given HelperOptions.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is a utility for ensuring the proper patching of objects.
func NewHelper ¶
NewHelper returns an initialized Helper. Use NewHelper before changing obj. After changing obj use Helper.Patch to persist your changes.
Please note that patch helper implements a custom handling for objects implementing the condition.Setter interface or the v1beta2conditions.Setter interface.
It is also possible to implement wrappers for object not implementing those interfaces; in case those objects have custom conditions types the wrapper should take care of conversions. Additionally, if the conditions are not in the canonical place defined by the proposal for improving status in Cluster API conditions, locations of the condition field must be provided explicitly by using Metav1ConditionsFieldPath and Clusterv1ConditionsFieldPath options during the Patch call.
type HelperOptions ¶
type HelperOptions struct { // IncludeStatusObservedGeneration sets the status.observedGeneration field // on the incoming object to match metadata.generation, only if there is a change. IncludeStatusObservedGeneration bool // ForceOverwriteConditions allows the patch helper to overwrite conditions in case of conflicts. // This option should only ever be set in controller managing the object being patched. ForceOverwriteConditions bool // OwnedConditions defines condition types owned by the controller. // In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller. OwnedConditions []clusterv1.ConditionType // OwnedV1Beta2Conditions defines condition types owned by the controller. // In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller. OwnedV1Beta2Conditions []string // Metav1ConditionsFields allows to override the path for the field hosting []metav1.Condition. // Please note that the default value for this option is inferred from the object struct. // This means, that if the correct path cannot be detected, this option has to be specified. One example // is if you pass a wrapper to unstructured. // The override for this option is considered only if the object implements the v1beta2conditions.Setter interface. Metav1ConditionsFieldPath []string // Clusterv1ConditionsFieldPath allows to override the path for the field hosting clusterv1.Conditions. // Please note that the default value for this option is inferred from the object struct. // This means, that if the correct path cannot be detected, this option has to be specified. One example // is if you pass a wrapper to unstructured. // The override for this option is considered only if the object implements the conditions.Setter interface. Clusterv1ConditionsFieldPath []string }
HelperOptions contains options for patch options.
type Metav1ConditionsFieldPath ¶
type Metav1ConditionsFieldPath []string
Metav1ConditionsFieldPath allows to override the path for the field hosting []metav1.Condition. Please note that the default value for this option is inferred from the object struct. The override for this option is considered only if the object implements the v1beta2conditions.Setter interface.
func (Metav1ConditionsFieldPath) ApplyToHelper ¶
func (w Metav1ConditionsFieldPath) ApplyToHelper(in *HelperOptions)
ApplyToHelper applies this configuration to the given HelperOptions.
type Option ¶
type Option interface { // ApplyToHelper applies this configuration to the given Helper options. ApplyToHelper(*HelperOptions) }
Option is some configuration that modifies options for a patch request.
type WithForceOverwriteConditions ¶
type WithForceOverwriteConditions struct{}
WithForceOverwriteConditions allows the patch helper to overwrite conditions in case of conflicts. This option should only ever be set in controller managing the object being patched.
func (WithForceOverwriteConditions) ApplyToHelper ¶
func (w WithForceOverwriteConditions) ApplyToHelper(in *HelperOptions)
ApplyToHelper applies this configuration to the given HelperOptions.
type WithOwnedConditions ¶
type WithOwnedConditions struct {
Conditions []clusterv1.ConditionType
}
WithOwnedConditions allows to define condition types owned by the controller. In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller.
func (WithOwnedConditions) ApplyToHelper ¶
func (w WithOwnedConditions) ApplyToHelper(in *HelperOptions)
ApplyToHelper applies this configuration to the given HelperOptions.
type WithOwnedV1Beta2Conditions ¶
type WithOwnedV1Beta2Conditions struct {
Conditions []string
}
WithOwnedV1Beta2Conditions allows to define condition types owned by the controller. In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller.
func (WithOwnedV1Beta2Conditions) ApplyToHelper ¶
func (w WithOwnedV1Beta2Conditions) ApplyToHelper(in *HelperOptions)
ApplyToHelper applies this configuration to the given HelperOptions.
type WithStatusObservedGeneration ¶
type WithStatusObservedGeneration struct{}
WithStatusObservedGeneration sets the status.observedGeneration field on the incoming object to match metadata.generation, only if there is a change.
func (WithStatusObservedGeneration) ApplyToHelper ¶
func (w WithStatusObservedGeneration) ApplyToHelper(in *HelperOptions)
ApplyToHelper applies this configuration to the given HelperOptions.