diff --git a/dies/v1/clusterworkloadresourcemapping.go b/dies/v1/clusterworkloadresourcemapping.go index 8e5a631..b3ce367 100644 --- a/dies/v1/clusterworkloadresourcemapping.go +++ b/dies/v1/clusterworkloadresourcemapping.go @@ -24,36 +24,17 @@ import ( type _ = servicebindingv1.ClusterWorkloadResourceMapping // +die +// +die:field:name=Versions,die=ClusterWorkloadResourceMappingTemplateDie,listMapKey=Version type _ = servicebindingv1.ClusterWorkloadResourceMappingSpec +// deprecated use VersionDie func (d *ClusterWorkloadResourceMappingSpecDie) VersionsDie(version string, fn func(d *ClusterWorkloadResourceMappingTemplateDie)) *ClusterWorkloadResourceMappingSpecDie { - return d.DieStamp(func(r *servicebindingv1.ClusterWorkloadResourceMappingSpec) { - for i := range r.Versions { - if version == r.Versions[i].Version { - d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(r.Versions[i]) - fn(d) - r.Versions[i] = d.DieRelease() - return - } - } - - d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(servicebindingv1.ClusterWorkloadResourceMappingTemplate{Version: version}) - fn(d) - r.Versions = append(r.Versions, d.DieRelease()) - }) + return d.VersionDie(version, fn) } // +die +// +die:field:name=Containers,die=ClusterWorkloadResourceMappingContainerDie,listType=atomic type _ = servicebindingv1.ClusterWorkloadResourceMappingTemplate -func (d *ClusterWorkloadResourceMappingTemplateDie) ContainersDie(containers ...*ClusterWorkloadResourceMappingContainerDie) *ClusterWorkloadResourceMappingTemplateDie { - return d.DieStamp(func(r *servicebindingv1.ClusterWorkloadResourceMappingTemplate) { - r.Containers = make([]servicebindingv1.ClusterWorkloadResourceMappingContainer, len(containers)) - for i := range containers { - r.Containers[i] = containers[i].DieRelease() - } - }) -} - // +die type _ = servicebindingv1.ClusterWorkloadResourceMappingContainer diff --git a/dies/v1/servicebinding.go b/dies/v1/servicebinding.go index 443bece..26c53d3 100644 --- a/dies/v1/servicebinding.go +++ b/dies/v1/servicebinding.go @@ -17,7 +17,6 @@ limitations under the License. package v1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diemetav1 "reconciler.io/dies/apis/meta/v1" servicebindingv1 "github.com/servicebinding/runtime/apis/v1" @@ -27,52 +26,15 @@ import ( type _ = servicebindingv1.ServiceBinding // +die +// +die:field:name=Workload,die=ServiceBindingWorkloadReferenceDie +// +die:field:name=Service,die=ServiceBindingServiceReferenceDie +// +die:field:name=Env,die=EnvMappingDie,listType=map type _ = servicebindingv1.ServiceBindingSpec -func (d *ServiceBindingSpecDie) WorkloadDie(fn func(d *ServiceBindingWorkloadReferenceDie)) *ServiceBindingSpecDie { - return d.DieStamp(func(r *servicebindingv1.ServiceBindingSpec) { - d := ServiceBindingWorkloadReferenceBlank.DieImmutable(false).DieFeed(r.Workload) - fn(d) - r.Workload = d.DieRelease() - }) -} - -func (d *ServiceBindingSpecDie) ServiceDie(fn func(d *ServiceBindingServiceReferenceDie)) *ServiceBindingSpecDie { - return d.DieStamp(func(r *servicebindingv1.ServiceBindingSpec) { - d := ServiceBindingServiceReferenceBlank.DieImmutable(false).DieFeed(r.Service) - fn(d) - r.Service = d.DieRelease() - }) -} - -func (d *ServiceBindingSpecDie) EnvDie(name string, fn func(d *EnvMappingDie)) *ServiceBindingSpecDie { - return d.DieStamp(func(r *servicebindingv1.ServiceBindingSpec) { - for i := range r.Env { - if name == r.Env[i].Name { - d := EnvMappingBlank.DieImmutable(false).DieFeed(r.Env[i]) - fn(d) - r.Env[i] = d.DieRelease() - return - } - } - - d := EnvMappingBlank.DieImmutable(false).DieFeed(servicebindingv1.EnvMapping{Name: name}) - fn(d) - r.Env = append(r.Env, d.DieRelease()) - }) -} - // +die +// +die:field:name=Selector,package=_/meta/v1,die=LabelSelectorDie,pointer=true type _ = servicebindingv1.ServiceBindingWorkloadReference -func (d *ServiceBindingWorkloadReferenceDie) SelectorDie(fn func(d *diemetav1.LabelSelectorDie)) *ServiceBindingWorkloadReferenceDie { - return d.DieStamp(func(r *servicebindingv1.ServiceBindingWorkloadReference) { - d := diemetav1.LabelSelectorBlank.DieImmutable(false).DieFeedPtr(r.Selector) - fn(d) - r.Selector = d.DieReleasePtr() - }) -} - // +die type _ = servicebindingv1.ServiceBindingServiceReference @@ -80,28 +42,13 @@ type _ = servicebindingv1.ServiceBindingServiceReference type _ = servicebindingv1.EnvMapping // +die +// +die:field:name=Conditions,package=_/meta/v1,die=ConditionDie,listType=atomic +// +die:field:name=Binding,die=ServiceBindingSecretReferenceDie,pointer=true type _ = servicebindingv1.ServiceBindingStatus -func (d *ServiceBindingStatusDie) ConditionsDie(conditions ...*diemetav1.ConditionDie) *ServiceBindingStatusDie { - return d.DieStamp(func(r *servicebindingv1.ServiceBindingStatus) { - r.Conditions = make([]metav1.Condition, len(conditions)) - for i := range conditions { - r.Conditions[i] = conditions[i].DieRelease() - } - }) -} - var ServiceBindingConditionReady = diemetav1.ConditionBlank.Type(servicebindingv1.ServiceBindingConditionReady).Unknown().Reason("Initializing") var ServiceBindingConditionServiceAvailable = diemetav1.ConditionBlank.Type(servicebindingv1.ServiceBindingConditionServiceAvailable).Unknown().Reason("Initializing") var ServiceBindingConditionWorkloadProjected = diemetav1.ConditionBlank.Type(servicebindingv1.ServiceBindingConditionWorkloadProjected).Unknown().Reason("Initializing") -func (d *ServiceBindingStatusDie) BindingDie(fn func(d *ServiceBindingSecretReferenceDie)) *ServiceBindingStatusDie { - return d.DieStamp(func(r *servicebindingv1.ServiceBindingStatus) { - d := ServiceBindingSecretReferenceBlank.DieImmutable(false).DieFeedPtr(r.Binding) - fn(d) - r.Binding = d.DieReleasePtr() - }) -} - // +die type _ = servicebindingv1.ServiceBindingSecretReference diff --git a/dies/v1/zz_generated.die.go b/dies/v1/zz_generated.die.go index a33791e..487a444 100644 --- a/dies/v1/zz_generated.die.go +++ b/dies/v1/zz_generated.die.go @@ -22,17 +22,20 @@ limitations under the License. package v1 import ( - json "encoding/json" fmtx "fmt" osx "os" reflectx "reflect" + cmp "github.com/google/go-cmp/cmp" apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" unstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + json "k8s.io/apimachinery/pkg/util/json" jsonpath "k8s.io/client-go/util/jsonpath" metav1 "reconciler.io/dies/apis/meta/v1" + patch "reconciler.io/dies/patch" yaml "sigs.k8s.io/yaml" apisv1 "github.com/servicebinding/runtime/apis/v1" @@ -44,6 +47,7 @@ type ClusterWorkloadResourceMappingDie struct { metav1.FrozenObjectMeta mutable bool r apisv1.ClusterWorkloadResourceMapping + seal apisv1.ClusterWorkloadResourceMapping } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -67,6 +71,7 @@ func (d *ClusterWorkloadResourceMappingDie) DieFeed(r apisv1.ClusterWorkloadReso FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, + seal: d.seal, } } @@ -233,9 +238,53 @@ func (d *ClusterWorkloadResourceMappingDie) DeepCopy() *ClusterWorkloadResourceM FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, + seal: d.seal, } } +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingDie) DieSeal() *ClusterWorkloadResourceMappingDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingDie) DieSealFeed(r apisv1.ClusterWorkloadResourceMapping) *ClusterWorkloadResourceMappingDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ClusterWorkloadResourceMappingDie) DieSealFeedPtr(r *apisv1.ClusterWorkloadResourceMapping) *ClusterWorkloadResourceMappingDie { + if r == nil { + r = &apisv1.ClusterWorkloadResourceMapping{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ClusterWorkloadResourceMappingDie) DieSealRelease() apisv1.ClusterWorkloadResourceMapping { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ClusterWorkloadResourceMappingDie) DieSealReleasePtr() *apisv1.ClusterWorkloadResourceMapping { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ClusterWorkloadResourceMappingDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ClusterWorkloadResourceMappingDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + var _ runtime.Object = (*ClusterWorkloadResourceMappingDie)(nil) func (d *ClusterWorkloadResourceMappingDie) DeepCopyObject() runtime.Object { @@ -252,15 +301,12 @@ func (d *ClusterWorkloadResourceMappingDie) MarshalJSON() ([]byte, error) { } func (d *ClusterWorkloadResourceMappingDie) UnmarshalJSON(b []byte) error { - if d == ClusterWorkloadResourceMappingBlank { - return fmtx.Errorf("cannot unmarshal into the blank die, create a copy first") - } if !d.mutable { return fmtx.Errorf("cannot unmarshal into immutable dies, create a mutable version first") } - r := &apisv1.ClusterWorkloadResourceMapping{} - err := json.Unmarshal(b, r) - *d = *d.DieFeed(*r) + resource := &apisv1.ClusterWorkloadResourceMapping{} + err := json.Unmarshal(b, resource) + *d = *d.DieFeed(*resource) return err } @@ -278,6 +324,29 @@ func (d *ClusterWorkloadResourceMappingDie) Kind(v string) *ClusterWorkloadResou }) } +// TypeMetadata standard object's type metadata. +func (d *ClusterWorkloadResourceMappingDie) TypeMetadata(v apismetav1.TypeMeta) *ClusterWorkloadResourceMappingDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { + r.TypeMeta = v + }) +} + +// TypeMetadataDie stamps the resource's TypeMeta field with a mutable die. +func (d *ClusterWorkloadResourceMappingDie) TypeMetadataDie(fn func(d *metav1.TypeMetaDie)) *ClusterWorkloadResourceMappingDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { + d := metav1.TypeMetaBlank.DieImmutable(false).DieFeed(r.TypeMeta) + fn(d) + r.TypeMeta = d.DieRelease() + }) +} + +// Metadata standard object's metadata. +func (d *ClusterWorkloadResourceMappingDie) Metadata(v apismetav1.ObjectMeta) *ClusterWorkloadResourceMappingDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { + r.ObjectMeta = v + }) +} + // MetadataDie stamps the resource's ObjectMeta field with a mutable die. func (d *ClusterWorkloadResourceMappingDie) MetadataDie(fn func(d *metav1.ObjectMetaDie)) *ClusterWorkloadResourceMappingDie { return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMapping) { @@ -307,6 +376,7 @@ var ClusterWorkloadResourceMappingSpecBlank = (&ClusterWorkloadResourceMappingSp type ClusterWorkloadResourceMappingSpecDie struct { mutable bool r apisv1.ClusterWorkloadResourceMappingSpec + seal apisv1.ClusterWorkloadResourceMappingSpec } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -328,6 +398,7 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DieFeed(r apisv1.ClusterWorkload return &ClusterWorkloadResourceMappingSpecDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -481,9 +552,73 @@ func (d *ClusterWorkloadResourceMappingSpecDie) DeepCopy() *ClusterWorkloadResou return &ClusterWorkloadResourceMappingSpecDie{ mutable: d.mutable, r: r, + seal: d.seal, } } +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingSpecDie) DieSeal() *ClusterWorkloadResourceMappingSpecDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingSpecDie) DieSealFeed(r apisv1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingSpecDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ClusterWorkloadResourceMappingSpecDie) DieSealFeedPtr(r *apisv1.ClusterWorkloadResourceMappingSpec) *ClusterWorkloadResourceMappingSpecDie { + if r == nil { + r = &apisv1.ClusterWorkloadResourceMappingSpec{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ClusterWorkloadResourceMappingSpecDie) DieSealRelease() apisv1.ClusterWorkloadResourceMappingSpec { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ClusterWorkloadResourceMappingSpecDie) DieSealReleasePtr() *apisv1.ClusterWorkloadResourceMappingSpec { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ClusterWorkloadResourceMappingSpecDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ClusterWorkloadResourceMappingSpecDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + +// VersionDie mutates a single item in Versions matched by the nested field Version, appending a new item if no match is found. +// +// Versions is the collection of versions for a given resource, with mappings. +func (d *ClusterWorkloadResourceMappingSpecDie) VersionDie(v string, fn func(d *ClusterWorkloadResourceMappingTemplateDie)) *ClusterWorkloadResourceMappingSpecDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingSpec) { + for i := range r.Versions { + if v == r.Versions[i].Version { + d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(r.Versions[i]) + fn(d) + r.Versions[i] = d.DieRelease() + return + } + } + + d := ClusterWorkloadResourceMappingTemplateBlank.DieImmutable(false).DieFeed(apisv1.ClusterWorkloadResourceMappingTemplate{Version: v}) + fn(d) + r.Versions = append(r.Versions, d.DieRelease()) + }) +} + // Versions is the collection of versions for a given resource, with mappings. func (d *ClusterWorkloadResourceMappingSpecDie) Versions(v ...apisv1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingSpecDie { return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingSpec) { @@ -496,6 +631,7 @@ var ClusterWorkloadResourceMappingTemplateBlank = (&ClusterWorkloadResourceMappi type ClusterWorkloadResourceMappingTemplateDie struct { mutable bool r apisv1.ClusterWorkloadResourceMappingTemplate + seal apisv1.ClusterWorkloadResourceMappingTemplate } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -517,6 +653,7 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DieFeed(r apisv1.ClusterWork return &ClusterWorkloadResourceMappingTemplateDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -670,7 +807,65 @@ func (d *ClusterWorkloadResourceMappingTemplateDie) DeepCopy() *ClusterWorkloadR return &ClusterWorkloadResourceMappingTemplateDie{ mutable: d.mutable, r: r, + seal: d.seal, + } +} + +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingTemplateDie) DieSeal() *ClusterWorkloadResourceMappingTemplateDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingTemplateDie) DieSealFeed(r apisv1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingTemplateDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ClusterWorkloadResourceMappingTemplateDie) DieSealFeedPtr(r *apisv1.ClusterWorkloadResourceMappingTemplate) *ClusterWorkloadResourceMappingTemplateDie { + if r == nil { + r = &apisv1.ClusterWorkloadResourceMappingTemplate{} } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ClusterWorkloadResourceMappingTemplateDie) DieSealRelease() apisv1.ClusterWorkloadResourceMappingTemplate { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ClusterWorkloadResourceMappingTemplateDie) DieSealReleasePtr() *apisv1.ClusterWorkloadResourceMappingTemplate { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ClusterWorkloadResourceMappingTemplateDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ClusterWorkloadResourceMappingTemplateDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + +// ContainersDie replaces Containers by collecting the released value from each die passed. +// +// Containers is the collection of mappings to container-like fragments of the workload resource. Defaults to +// +// mappings appropriate for a PodSpecable resource. +func (d *ClusterWorkloadResourceMappingTemplateDie) ContainersDie(v ...*ClusterWorkloadResourceMappingContainerDie) *ClusterWorkloadResourceMappingTemplateDie { + return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingTemplate) { + r.Containers = make([]apisv1.ClusterWorkloadResourceMappingContainer, len(v)) + for i := range v { + r.Containers[i] = v[i].DieRelease() + } + }) } // Version is the version of the workload resource that this mapping is for. @@ -714,6 +909,7 @@ var ClusterWorkloadResourceMappingContainerBlank = (&ClusterWorkloadResourceMapp type ClusterWorkloadResourceMappingContainerDie struct { mutable bool r apisv1.ClusterWorkloadResourceMappingContainer + seal apisv1.ClusterWorkloadResourceMappingContainer } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -735,6 +931,7 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DieFeed(r apisv1.ClusterWor return &ClusterWorkloadResourceMappingContainerDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -888,9 +1085,53 @@ func (d *ClusterWorkloadResourceMappingContainerDie) DeepCopy() *ClusterWorkload return &ClusterWorkloadResourceMappingContainerDie{ mutable: d.mutable, r: r, + seal: d.seal, } } +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingContainerDie) DieSeal() *ClusterWorkloadResourceMappingContainerDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ClusterWorkloadResourceMappingContainerDie) DieSealFeed(r apisv1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingContainerDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ClusterWorkloadResourceMappingContainerDie) DieSealFeedPtr(r *apisv1.ClusterWorkloadResourceMappingContainer) *ClusterWorkloadResourceMappingContainerDie { + if r == nil { + r = &apisv1.ClusterWorkloadResourceMappingContainer{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ClusterWorkloadResourceMappingContainerDie) DieSealRelease() apisv1.ClusterWorkloadResourceMappingContainer { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ClusterWorkloadResourceMappingContainerDie) DieSealReleasePtr() *apisv1.ClusterWorkloadResourceMappingContainer { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ClusterWorkloadResourceMappingContainerDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ClusterWorkloadResourceMappingContainerDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + // Path is the JSONPath within the workload resource that matches an existing fragment that is container-like. func (d *ClusterWorkloadResourceMappingContainerDie) Path(v string) *ClusterWorkloadResourceMappingContainerDie { return d.DieStamp(func(r *apisv1.ClusterWorkloadResourceMappingContainer) { @@ -935,6 +1176,7 @@ type ServiceBindingDie struct { metav1.FrozenObjectMeta mutable bool r apisv1.ServiceBinding + seal apisv1.ServiceBinding } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -958,6 +1200,7 @@ func (d *ServiceBindingDie) DieFeed(r apisv1.ServiceBinding) *ServiceBindingDie FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, + seal: d.seal, } } @@ -1124,9 +1367,53 @@ func (d *ServiceBindingDie) DeepCopy() *ServiceBindingDie { FrozenObjectMeta: metav1.FreezeObjectMeta(r.ObjectMeta), mutable: d.mutable, r: r, + seal: d.seal, } } +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ServiceBindingDie) DieSeal() *ServiceBindingDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ServiceBindingDie) DieSealFeed(r apisv1.ServiceBinding) *ServiceBindingDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ServiceBindingDie) DieSealFeedPtr(r *apisv1.ServiceBinding) *ServiceBindingDie { + if r == nil { + r = &apisv1.ServiceBinding{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ServiceBindingDie) DieSealRelease() apisv1.ServiceBinding { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ServiceBindingDie) DieSealReleasePtr() *apisv1.ServiceBinding { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ServiceBindingDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ServiceBindingDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + var _ runtime.Object = (*ServiceBindingDie)(nil) func (d *ServiceBindingDie) DeepCopyObject() runtime.Object { @@ -1143,15 +1430,12 @@ func (d *ServiceBindingDie) MarshalJSON() ([]byte, error) { } func (d *ServiceBindingDie) UnmarshalJSON(b []byte) error { - if d == ServiceBindingBlank { - return fmtx.Errorf("cannot unmarshal into the blank die, create a copy first") - } if !d.mutable { return fmtx.Errorf("cannot unmarshal into immutable dies, create a mutable version first") } - r := &apisv1.ServiceBinding{} - err := json.Unmarshal(b, r) - *d = *d.DieFeed(*r) + resource := &apisv1.ServiceBinding{} + err := json.Unmarshal(b, resource) + *d = *d.DieFeed(*resource) return err } @@ -1169,6 +1453,29 @@ func (d *ServiceBindingDie) Kind(v string) *ServiceBindingDie { }) } +// TypeMetadata standard object's type metadata. +func (d *ServiceBindingDie) TypeMetadata(v apismetav1.TypeMeta) *ServiceBindingDie { + return d.DieStamp(func(r *apisv1.ServiceBinding) { + r.TypeMeta = v + }) +} + +// TypeMetadataDie stamps the resource's TypeMeta field with a mutable die. +func (d *ServiceBindingDie) TypeMetadataDie(fn func(d *metav1.TypeMetaDie)) *ServiceBindingDie { + return d.DieStamp(func(r *apisv1.ServiceBinding) { + d := metav1.TypeMetaBlank.DieImmutable(false).DieFeed(r.TypeMeta) + fn(d) + r.TypeMeta = d.DieRelease() + }) +} + +// Metadata standard object's metadata. +func (d *ServiceBindingDie) Metadata(v apismetav1.ObjectMeta) *ServiceBindingDie { + return d.DieStamp(func(r *apisv1.ServiceBinding) { + r.ObjectMeta = v + }) +} + // MetadataDie stamps the resource's ObjectMeta field with a mutable die. func (d *ServiceBindingDie) MetadataDie(fn func(d *metav1.ObjectMetaDie)) *ServiceBindingDie { return d.DieStamp(func(r *apisv1.ServiceBinding) { @@ -1213,6 +1520,7 @@ var ServiceBindingSpecBlank = (&ServiceBindingSpecDie{}).DieFeed(apisv1.ServiceB type ServiceBindingSpecDie struct { mutable bool r apisv1.ServiceBindingSpec + seal apisv1.ServiceBindingSpec } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1234,6 +1542,7 @@ func (d *ServiceBindingSpecDie) DieFeed(r apisv1.ServiceBindingSpec) *ServiceBin return &ServiceBindingSpecDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -1387,9 +1696,95 @@ func (d *ServiceBindingSpecDie) DeepCopy() *ServiceBindingSpecDie { return &ServiceBindingSpecDie{ mutable: d.mutable, r: r, + seal: d.seal, } } +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ServiceBindingSpecDie) DieSeal() *ServiceBindingSpecDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ServiceBindingSpecDie) DieSealFeed(r apisv1.ServiceBindingSpec) *ServiceBindingSpecDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ServiceBindingSpecDie) DieSealFeedPtr(r *apisv1.ServiceBindingSpec) *ServiceBindingSpecDie { + if r == nil { + r = &apisv1.ServiceBindingSpec{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ServiceBindingSpecDie) DieSealRelease() apisv1.ServiceBindingSpec { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ServiceBindingSpecDie) DieSealReleasePtr() *apisv1.ServiceBindingSpec { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ServiceBindingSpecDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ServiceBindingSpecDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + +// WorkloadDie mutates Workload as a die. +// +// Workload is a reference to an object +func (d *ServiceBindingSpecDie) WorkloadDie(fn func(d *ServiceBindingWorkloadReferenceDie)) *ServiceBindingSpecDie { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { + d := ServiceBindingWorkloadReferenceBlank.DieImmutable(false).DieFeed(r.Workload) + fn(d) + r.Workload = d.DieRelease() + }) +} + +// ServiceDie mutates Service as a die. +// +// Service is a reference to an object that fulfills the ProvisionedService duck type +func (d *ServiceBindingSpecDie) ServiceDie(fn func(d *ServiceBindingServiceReferenceDie)) *ServiceBindingSpecDie { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { + d := ServiceBindingServiceReferenceBlank.DieImmutable(false).DieFeed(r.Service) + fn(d) + r.Service = d.DieRelease() + }) +} + +// EnvDie mutates a single item in Env matched by the nested field Name, appending a new item if no match is found. +// +// Env is the collection of mappings from Secret entries to environment variables +func (d *ServiceBindingSpecDie) EnvDie(v string, fn func(d *EnvMappingDie)) *ServiceBindingSpecDie { + return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { + for i := range r.Env { + if v == r.Env[i].Name { + d := EnvMappingBlank.DieImmutable(false).DieFeed(r.Env[i]) + fn(d) + r.Env[i] = d.DieRelease() + return + } + } + + d := EnvMappingBlank.DieImmutable(false).DieFeed(apisv1.EnvMapping{Name: v}) + fn(d) + r.Env = append(r.Env, d.DieRelease()) + }) +} + // Name is the name of the service as projected into the workload container. Defaults to .metadata.name. func (d *ServiceBindingSpecDie) Name(v string) *ServiceBindingSpecDie { return d.DieStamp(func(r *apisv1.ServiceBindingSpec) { @@ -1437,6 +1832,7 @@ var ServiceBindingWorkloadReferenceBlank = (&ServiceBindingWorkloadReferenceDie{ type ServiceBindingWorkloadReferenceDie struct { mutable bool r apisv1.ServiceBindingWorkloadReference + seal apisv1.ServiceBindingWorkloadReference } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1458,6 +1854,7 @@ func (d *ServiceBindingWorkloadReferenceDie) DieFeed(r apisv1.ServiceBindingWork return &ServiceBindingWorkloadReferenceDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -1611,9 +2008,64 @@ func (d *ServiceBindingWorkloadReferenceDie) DeepCopy() *ServiceBindingWorkloadR return &ServiceBindingWorkloadReferenceDie{ mutable: d.mutable, r: r, + seal: d.seal, } } +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ServiceBindingWorkloadReferenceDie) DieSeal() *ServiceBindingWorkloadReferenceDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ServiceBindingWorkloadReferenceDie) DieSealFeed(r apisv1.ServiceBindingWorkloadReference) *ServiceBindingWorkloadReferenceDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ServiceBindingWorkloadReferenceDie) DieSealFeedPtr(r *apisv1.ServiceBindingWorkloadReference) *ServiceBindingWorkloadReferenceDie { + if r == nil { + r = &apisv1.ServiceBindingWorkloadReference{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ServiceBindingWorkloadReferenceDie) DieSealRelease() apisv1.ServiceBindingWorkloadReference { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ServiceBindingWorkloadReferenceDie) DieSealReleasePtr() *apisv1.ServiceBindingWorkloadReference { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ServiceBindingWorkloadReferenceDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ServiceBindingWorkloadReferenceDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + +// SelectorDie mutates Selector as a die. +// +// Selector is a query that selects the workload or workloads to bind the service to +func (d *ServiceBindingWorkloadReferenceDie) SelectorDie(fn func(d *metav1.LabelSelectorDie)) *ServiceBindingWorkloadReferenceDie { + return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { + d := metav1.LabelSelectorBlank.DieImmutable(false).DieFeedPtr(r.Selector) + fn(d) + r.Selector = d.DieReleasePtr() + }) +} + // API version of the referent. func (d *ServiceBindingWorkloadReferenceDie) APIVersion(v string) *ServiceBindingWorkloadReferenceDie { return d.DieStamp(func(r *apisv1.ServiceBindingWorkloadReference) { @@ -1658,6 +2110,7 @@ var ServiceBindingServiceReferenceBlank = (&ServiceBindingServiceReferenceDie{}) type ServiceBindingServiceReferenceDie struct { mutable bool r apisv1.ServiceBindingServiceReference + seal apisv1.ServiceBindingServiceReference } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1679,6 +2132,7 @@ func (d *ServiceBindingServiceReferenceDie) DieFeed(r apisv1.ServiceBindingServi return &ServiceBindingServiceReferenceDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -1832,7 +2286,51 @@ func (d *ServiceBindingServiceReferenceDie) DeepCopy() *ServiceBindingServiceRef return &ServiceBindingServiceReferenceDie{ mutable: d.mutable, r: r, + seal: d.seal, + } +} + +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ServiceBindingServiceReferenceDie) DieSeal() *ServiceBindingServiceReferenceDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ServiceBindingServiceReferenceDie) DieSealFeed(r apisv1.ServiceBindingServiceReference) *ServiceBindingServiceReferenceDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ServiceBindingServiceReferenceDie) DieSealFeedPtr(r *apisv1.ServiceBindingServiceReference) *ServiceBindingServiceReferenceDie { + if r == nil { + r = &apisv1.ServiceBindingServiceReference{} } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ServiceBindingServiceReferenceDie) DieSealRelease() apisv1.ServiceBindingServiceReference { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ServiceBindingServiceReferenceDie) DieSealReleasePtr() *apisv1.ServiceBindingServiceReference { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ServiceBindingServiceReferenceDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ServiceBindingServiceReferenceDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) } // API version of the referent. @@ -1865,6 +2363,7 @@ var EnvMappingBlank = (&EnvMappingDie{}).DieFeed(apisv1.EnvMapping{}) type EnvMappingDie struct { mutable bool r apisv1.EnvMapping + seal apisv1.EnvMapping } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -1886,6 +2385,7 @@ func (d *EnvMappingDie) DieFeed(r apisv1.EnvMapping) *EnvMappingDie { return &EnvMappingDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -2039,7 +2539,51 @@ func (d *EnvMappingDie) DeepCopy() *EnvMappingDie { return &EnvMappingDie{ mutable: d.mutable, r: r, + seal: d.seal, + } +} + +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *EnvMappingDie) DieSeal() *EnvMappingDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *EnvMappingDie) DieSealFeed(r apisv1.EnvMapping) *EnvMappingDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *EnvMappingDie) DieSealFeedPtr(r *apisv1.EnvMapping) *EnvMappingDie { + if r == nil { + r = &apisv1.EnvMapping{} } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *EnvMappingDie) DieSealRelease() apisv1.EnvMapping { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *EnvMappingDie) DieSealReleasePtr() *apisv1.EnvMapping { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *EnvMappingDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *EnvMappingDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) } // Name is the name of the environment variable @@ -2061,6 +2605,7 @@ var ServiceBindingStatusBlank = (&ServiceBindingStatusDie{}).DieFeed(apisv1.Serv type ServiceBindingStatusDie struct { mutable bool r apisv1.ServiceBindingStatus + seal apisv1.ServiceBindingStatus } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -2082,6 +2627,7 @@ func (d *ServiceBindingStatusDie) DieFeed(r apisv1.ServiceBindingStatus) *Servic return &ServiceBindingStatusDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -2235,7 +2781,74 @@ func (d *ServiceBindingStatusDie) DeepCopy() *ServiceBindingStatusDie { return &ServiceBindingStatusDie{ mutable: d.mutable, r: r, + seal: d.seal, + } +} + +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ServiceBindingStatusDie) DieSeal() *ServiceBindingStatusDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ServiceBindingStatusDie) DieSealFeed(r apisv1.ServiceBindingStatus) *ServiceBindingStatusDie { + if !d.mutable { + d = d.DeepCopy() } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ServiceBindingStatusDie) DieSealFeedPtr(r *apisv1.ServiceBindingStatus) *ServiceBindingStatusDie { + if r == nil { + r = &apisv1.ServiceBindingStatus{} + } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ServiceBindingStatusDie) DieSealRelease() apisv1.ServiceBindingStatus { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ServiceBindingStatusDie) DieSealReleasePtr() *apisv1.ServiceBindingStatus { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ServiceBindingStatusDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ServiceBindingStatusDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) +} + +// ConditionsDie replaces Conditions by collecting the released value from each die passed. +// +// Conditions are the conditions of this ServiceBinding +func (d *ServiceBindingStatusDie) ConditionsDie(v ...*metav1.ConditionDie) *ServiceBindingStatusDie { + return d.DieStamp(func(r *apisv1.ServiceBindingStatus) { + r.Conditions = make([]apismetav1.Condition, len(v)) + for i := range v { + r.Conditions[i] = v[i].DieRelease() + } + }) +} + +// BindingDie mutates Binding as a die. +// +// Binding exposes the projected secret for this ServiceBinding +func (d *ServiceBindingStatusDie) BindingDie(fn func(d *ServiceBindingSecretReferenceDie)) *ServiceBindingStatusDie { + return d.DieStamp(func(r *apisv1.ServiceBindingStatus) { + d := ServiceBindingSecretReferenceBlank.DieImmutable(false).DieFeedPtr(r.Binding) + fn(d) + r.Binding = d.DieReleasePtr() + }) } // ObservedGeneration is the 'Generation' of the ServiceBinding that @@ -2266,6 +2879,7 @@ var ServiceBindingSecretReferenceBlank = (&ServiceBindingSecretReferenceDie{}).D type ServiceBindingSecretReferenceDie struct { mutable bool r apisv1.ServiceBindingSecretReference + seal apisv1.ServiceBindingSecretReference } // DieImmutable returns a new die for the current die's state that is either mutable (`false`) or immutable (`true`). @@ -2287,6 +2901,7 @@ func (d *ServiceBindingSecretReferenceDie) DieFeed(r apisv1.ServiceBindingSecret return &ServiceBindingSecretReferenceDie{ mutable: d.mutable, r: r, + seal: d.seal, } } @@ -2440,7 +3055,51 @@ func (d *ServiceBindingSecretReferenceDie) DeepCopy() *ServiceBindingSecretRefer return &ServiceBindingSecretReferenceDie{ mutable: d.mutable, r: r, + seal: d.seal, + } +} + +// DieSeal returns a new die for the current die's state that is sealed for comparison in future diff and patch operations. +func (d *ServiceBindingSecretReferenceDie) DieSeal() *ServiceBindingSecretReferenceDie { + return d.DieSealFeed(d.r) +} + +// DieSealFeed returns a new die for the current die's state that uses a specific resource for comparison in future diff and patch operations. +func (d *ServiceBindingSecretReferenceDie) DieSealFeed(r apisv1.ServiceBindingSecretReference) *ServiceBindingSecretReferenceDie { + if !d.mutable { + d = d.DeepCopy() + } + d.seal = *r.DeepCopy() + return d +} + +// DieSealFeedPtr returns a new die for the current die's state that uses a specific resource pointer for comparison in future diff and patch operations. If the resource is nil, the empty value is used instead. +func (d *ServiceBindingSecretReferenceDie) DieSealFeedPtr(r *apisv1.ServiceBindingSecretReference) *ServiceBindingSecretReferenceDie { + if r == nil { + r = &apisv1.ServiceBindingSecretReference{} } + return d.DieSealFeed(*r) +} + +// DieSealRelease returns the sealed resource managed by the die. +func (d *ServiceBindingSecretReferenceDie) DieSealRelease() apisv1.ServiceBindingSecretReference { + return *d.seal.DeepCopy() +} + +// DieSealReleasePtr returns the sealed resource pointer managed by the die. +func (d *ServiceBindingSecretReferenceDie) DieSealReleasePtr() *apisv1.ServiceBindingSecretReference { + r := d.DieSealRelease() + return &r +} + +// DieDiff uses cmp.Diff to compare the current value of the die with the sealed value. +func (d *ServiceBindingSecretReferenceDie) DieDiff(opts ...cmp.Option) string { + return cmp.Diff(d.seal, d.r, opts...) +} + +// DiePatch generates a patch between the current value of the die and the sealed value. +func (d *ServiceBindingSecretReferenceDie) DiePatch(patchType types.PatchType) ([]byte, error) { + return patch.Create(d.seal, d.r, patchType) } // Name of the referent secret. diff --git a/go.mod b/go.mod index 3ffa170..da93d64 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( k8s.io/apimachinery v0.30.2 k8s.io/client-go v0.30.2 k8s.io/utils v0.0.0-20240102154912-e7106e64919e - reconciler.io/dies v0.12.0 + reconciler.io/dies v0.13.0 reconciler.io/runtime v0.20.0 sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/yaml v1.4.0 diff --git a/go.sum b/go.sum index 3d30676..d37014d 100644 --- a/go.sum +++ b/go.sum @@ -207,8 +207,8 @@ k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7F k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -reconciler.io/dies v0.12.0 h1:6xg3h2l5gcVF478aRThL/NaStxxpytg/jTnE0zpGEmU= -reconciler.io/dies v0.12.0/go.mod h1:xMXTc1Wp1kt8NwOU9/+gCk6bwJG3TnaFofttwPEEpdI= +reconciler.io/dies v0.13.0 h1:Bc0GrdCI48psuJtPf09h2+BjAeT0lwOlQuEViRQ+xQI= +reconciler.io/dies v0.13.0/go.mod h1:5CKAAP1L9dnehzJkGJeq3RnAbXVuFaABiB2NmLErJS4= reconciler.io/runtime v0.20.0 h1:b2RQTYRrnEDTZQHH6h57SIR373vzKPRyfTKtRyO2cpw= reconciler.io/runtime v0.20.0/go.mod h1:rDD6qZcijjw+7JIkfOOnLM9uMOH+Robq24fbihD5ZRc= sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= diff --git a/hack/diegen/go.mod b/hack/diegen/go.mod index ea7e26f..8f73100 100644 --- a/hack/diegen/go.mod +++ b/hack/diegen/go.mod @@ -2,12 +2,13 @@ module github.com/servicebinding/runtime/hack/controller-gen go 1.22.0 -require reconciler.io/dies/diegen v0.12.0 +require reconciler.io/dies/diegen v0.13.0 require ( golang.org/x/mod v0.15.0 // indirect golang.org/x/tools v0.18.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/apimachinery v0.30.0 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/controller-tools v0.14.0 // indirect ) diff --git a/hack/diegen/go.sum b/hack/diegen/go.sum index 8cb3253..2337ba5 100644 --- a/hack/diegen/go.sum +++ b/hack/diegen/go.sum @@ -37,7 +37,9 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= -reconciler.io/dies/diegen v0.12.0 h1:iNl64oDzOCwv2pur5jLoTUxe8FTem9JacL8Y/hbnlNA= -reconciler.io/dies/diegen v0.12.0/go.mod h1:tdT0MK+CnHt+uGK9UNz6RFd0O9k7MBUemsnueAtxWYM= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +reconciler.io/dies/diegen v0.13.0 h1:p+LjyVziQXG43egR+J3zpSVuBTa3LO2edz4GN0FTUnc= +reconciler.io/dies/diegen v0.13.0/go.mod h1:tdT0MK+CnHt+uGK9UNz6RFd0O9k7MBUemsnueAtxWYM= sigs.k8s.io/controller-tools v0.14.0 h1:rnNoCC5wSXlrNoBKKzL70LNJKIQKEzT6lloG6/LF73A= sigs.k8s.io/controller-tools v0.14.0/go.mod h1:TV7uOtNNnnR72SpzhStvPkoS/U5ir0nMudrkrC4M9Sc=