Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Allow resources to contain unexported fields #487

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions internal/resources/dies/dies.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,69 @@ func (d *TestDuckSpecDie) AddField(key, value string) *TestDuckSpecDie {
r.Fields[key] = value
})
}

// +die:object=true
type _ = resources.TestResourceUnexportedFields

// +die:ignore={unexportedFields}
type _ = resources.TestResourceUnexportedFieldsSpec

func (d *TestResourceUnexportedFieldsSpecDie) AddField(key, value string) *TestResourceUnexportedFieldsSpecDie {
return d.DieStamp(func(r *resources.TestResourceUnexportedFieldsSpec) {
if r.Fields == nil {
r.Fields = map[string]string{}
}
r.Fields[key] = value
})
}

func (d *TestResourceUnexportedFieldsSpecDie) AddUnexportedField(key, value string) *TestResourceUnexportedFieldsSpecDie {
return d.DieStamp(func(r *resources.TestResourceUnexportedFieldsSpec) {
f := r.GetUnexportedFields()
if f == nil {
f = map[string]string{}
}
f[key] = value
r.SetUnexportedFields(f)
})
}

func (d *TestResourceUnexportedFieldsSpecDie) TemplateDie(fn func(d *diecorev1.PodTemplateSpecDie)) *TestResourceUnexportedFieldsSpecDie {
return d.DieStamp(func(r *resources.TestResourceUnexportedFieldsSpec) {
d := diecorev1.PodTemplateSpecBlank.DieImmutable(false).DieFeed(r.Template)
fn(d)
r.Template = d.DieRelease()
})
}

// +die:ignore={unexportedFields}
type _ = resources.TestResourceUnexportedFieldsStatus

func (d *TestResourceUnexportedFieldsStatusDie) ConditionsDie(conditions ...*diemetav1.ConditionDie) *TestResourceUnexportedFieldsStatusDie {
return d.DieStamp(func(r *resources.TestResourceUnexportedFieldsStatus) {
r.Conditions = make([]metav1.Condition, len(conditions))
for i := range conditions {
r.Conditions[i] = conditions[i].DieRelease()
}
})
}

func (d *TestResourceUnexportedFieldsStatusDie) AddField(key, value string) *TestResourceUnexportedFieldsStatusDie {
return d.DieStamp(func(r *resources.TestResourceUnexportedFieldsStatus) {
if r.Fields == nil {
r.Fields = map[string]string{}
}
r.Fields[key] = value
})
}

func (d *TestResourceUnexportedFieldsStatusDie) AddUnexportedField(key, value string) *TestResourceUnexportedFieldsStatusDie {
return d.DieStamp(func(r *resources.TestResourceUnexportedFieldsStatus) {
f := r.GetUnexportedFields()
if f == nil {
f = map[string]string{}
}
f[key] = value
r.SetUnexportedFields(f)
})
}
Loading
Loading