Allow references to groups by name (#195)

Group names are unique so we can safely use the name as a reference
method to groups. This makes assigning resources created in the cluster
to groups that already exist a lot easier.
This commit is contained in:
Philip Laine
2026-04-23 13:12:09 +02:00
committed by GitHub
parent 1a593dafc2
commit 99ef70603f
14 changed files with 139 additions and 71 deletions
@@ -16,7 +16,7 @@ type NetworkResourceSpecApplyConfiguration struct {
// ServiceRef is a reference to the service to expose in the Network.
ServiceRef *v1.LocalObjectReference `json:"serviceRef,omitempty"`
// Groups are references to groups that the resource will be a part of.
Groups []ResourceReferenceApplyConfiguration `json:"groups,omitempty"`
Groups []GroupReferenceApplyConfiguration `json:"groups,omitempty"`
}
// NetworkResourceSpecApplyConfiguration constructs a declarative configuration of the NetworkResourceSpec type for use with
@@ -44,7 +44,7 @@ func (b *NetworkResourceSpecApplyConfiguration) WithServiceRef(value v1.LocalObj
// WithGroups adds the given value to the Groups field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Groups field.
func (b *NetworkResourceSpecApplyConfiguration) WithGroups(values ...*ResourceReferenceApplyConfiguration) *NetworkResourceSpecApplyConfiguration {
func (b *NetworkResourceSpecApplyConfiguration) WithGroups(values ...*GroupReferenceApplyConfiguration) *NetworkResourceSpecApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithGroups")