Skip to content

Commit

Permalink
Update reconciler.io/dies to 0.13.0 (#432)
Browse files Browse the repository at this point in the history
* Update reconciler.io/dies to 0.13.0

Signed-off-by: Scott Andrews <[email protected]>

* Gernerate die mutation methods where possible

Signed-off-by: Scott Andrews <[email protected]>

---------

Signed-off-by: Scott Andrews <[email protected]>
  • Loading branch information
scothis authored Jun 25, 2024
1 parent 820f1b9 commit 32b3ba5
Show file tree
Hide file tree
Showing 7 changed files with 691 additions and 101 deletions.
27 changes: 4 additions & 23 deletions dies/v1/clusterworkloadresourcemapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
65 changes: 6 additions & 59 deletions dies/v1/servicebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -27,81 +26,29 @@ 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

// +die
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
Loading

0 comments on commit 32b3ba5

Please sign in to comment.