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
@@ -0,0 +1,48 @@
// Code generated by controller-gen. DO NOT EDIT.
package v1alpha1
import (
v1 "k8s.io/api/core/v1"
)
// GroupReferenceApplyConfiguration represents a declarative configuration of the GroupReference type for use
// with apply.
type GroupReferenceApplyConfiguration struct {
// Name is the name of the group.
Name *string `json:"name,omitempty"`
// ID is the id of the group.
ID *string `json:"id,omitempty"`
// LocalReference is a reference to a group in the same namespace.
LocalRef *v1.LocalObjectReference `json:"localRef,omitempty"`
}
// GroupReferenceApplyConfiguration constructs a declarative configuration of the GroupReference type for use with
// apply.
func GroupReference() *GroupReferenceApplyConfiguration {
return &GroupReferenceApplyConfiguration{}
}
// WithName sets the Name field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Name field is set to the value of the last call.
func (b *GroupReferenceApplyConfiguration) WithName(value string) *GroupReferenceApplyConfiguration {
b.Name = &value
return b
}
// WithID sets the ID field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ID field is set to the value of the last call.
func (b *GroupReferenceApplyConfiguration) WithID(value string) *GroupReferenceApplyConfiguration {
b.ID = &value
return b
}
// WithLocalRef sets the LocalRef field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the LocalRef field is set to the value of the last call.
func (b *GroupReferenceApplyConfiguration) WithLocalRef(value v1.LocalObjectReference) *GroupReferenceApplyConfiguration {
b.LocalRef = &value
return b
}
@@ -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")
@@ -18,7 +18,7 @@ type SetupKeySpecApplyConfiguration struct {
// Duration sets how long the setup key is valid for.
Duration *v1.Duration `json:"duration,omitempty"`
// AutoGroups are groups that will be automatically assigned to peers using setup key.
AutoGroups []ResourceReferenceApplyConfiguration `json:"autoGroups,omitempty"`
AutoGroups []GroupReferenceApplyConfiguration `json:"autoGroups,omitempty"`
}
// SetupKeySpecApplyConfiguration constructs a declarative configuration of the SetupKeySpec type for use with
@@ -54,7 +54,7 @@ func (b *SetupKeySpecApplyConfiguration) WithDuration(value v1.Duration) *SetupK
// WithAutoGroups adds the given value to the AutoGroups 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 AutoGroups field.
func (b *SetupKeySpecApplyConfiguration) WithAutoGroups(values ...*ResourceReferenceApplyConfiguration) *SetupKeySpecApplyConfiguration {
func (b *SetupKeySpecApplyConfiguration) WithAutoGroups(values ...*GroupReferenceApplyConfiguration) *SetupKeySpecApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithAutoGroups")