{"modulePath":"github.com/onexstack/onex","version":"v0.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package patch\n\nPackage patch implements patch utilities.\n\n## Types\n\n```go\ntype Helper struct {\n\t// contains filtered or unexported fields\n}\n```\nHelper is a utility for ensuring the proper patching of objects.\n\n```go\nfunc NewHelper(obj client.Object, crClient client.Client) (*Helper, error)\n```\nNewHelper returns an initialized Helper. Use NewHelper before changing obj. After changing obj use Helper.Patch to persist your changes.\n\n```go\nfunc (h *Helper) Patch(ctx context.Context, obj client.Object, opts ...Option) error\n```\nPatch will attempt to patch the given object, including its status.\n\n```go\ntype HelperOptions struct {\n\t// IncludeStatusObservedGeneration sets the status.observedGeneration field\n\t// on the incoming object to match metadata.generation, only if there is a change.\n\tIncludeStatusObservedGeneration bool\n\n\t// ForceOverwriteConditions allows the patch helper to overwrite conditions in case of conflicts.\n\t// This option should only ever be set in controller managing the object being patched.\n\tForceOverwriteConditions bool\n\n\t// OwnedConditions defines condition types owned by the controller.\n\t// In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller.\n\tOwnedConditions []v1beta1.ConditionType\n}\n```\nHelperOptions contains options for patch options.\n\n```go\ntype Option interface {\n\t// ApplyToHelper applies this configuration to the given Helper options.\n\tApplyToHelper(*HelperOptions)\n}\n```\nOption is some configuration that modifies options for a patch request.\n\n```go\ntype WithForceOverwriteConditions struct{}\n```\nWithForceOverwriteConditions 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.\n\n```go\nfunc (w WithForceOverwriteConditions) ApplyToHelper(in *HelperOptions)\n```\nApplyToHelper applies this configuration to the given HelperOptions.\n\n```go\ntype WithOwnedConditions struct {\n\tConditions []v1beta1.ConditionType\n}\n```\nWithOwnedConditions 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.\n\n```go\nfunc (w WithOwnedConditions) ApplyToHelper(in *HelperOptions)\n```\nApplyToHelper applies this configuration to the given HelperOptions.\n\n```go\ntype WithStatusObservedGeneration struct{}\n```\nWithStatusObservedGeneration sets the status.observedGeneration field on the incoming object to match metadata.generation, only if there is a change.\n\n```go\nfunc (w WithStatusObservedGeneration) ApplyToHelper(in *HelperOptions)\n```\nApplyToHelper applies this configuration to the given HelperOptions.\n\n","path":"github.com/onexstack/onex/internal/pkg/util/patch","name":"patch","synopsis":"Package patch implements patch utilities.","isRedistributable":true}
