mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
Implement group resource (#181)
This change implements a new group resource. It also sets the standard for a resource reference will be done through out the controller. A resource reference can either be done by ID or as a local named reference to the actual resource. This allows end users to chose if they want to manage things completely in the cluster or not. Part of #172 Signed-off-by: Philip Laine <philip.laine@gmail.com>
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
)
|
||||
|
||||
// GroupApplyConfiguration represents a declarative configuration of the Group type for use
|
||||
// with apply.
|
||||
//
|
||||
// Group is the Schema for the groups API
|
||||
type GroupApplyConfiguration struct {
|
||||
v1.TypeMetaApplyConfiguration `json:",inline"`
|
||||
// metadata is a standard object metadata
|
||||
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||
// spec defines the desired state of Group
|
||||
Spec *GroupSpecApplyConfiguration `json:"spec,omitempty"`
|
||||
// status defines the observed state of Group
|
||||
Status *GroupStatusApplyConfiguration `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// Group constructs a declarative configuration of the Group type for use with
|
||||
// apply.
|
||||
func Group(name, namespace string) *GroupApplyConfiguration {
|
||||
b := &GroupApplyConfiguration{}
|
||||
b.WithName(name)
|
||||
b.WithNamespace(namespace)
|
||||
b.WithKind("Group")
|
||||
b.WithAPIVersion("netbird.io/v1alpha1")
|
||||
return b
|
||||
}
|
||||
|
||||
func (b GroupApplyConfiguration) IsApplyConfiguration() {}
|
||||
|
||||
// WithKind sets the Kind 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 Kind field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithKind(value string) *GroupApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.Kind = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAPIVersion sets the APIVersion 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 APIVersion field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithAPIVersion(value string) *GroupApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.APIVersion = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// 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 *GroupApplyConfiguration) WithName(value string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.Name = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithGenerateName(value string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.GenerateName = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithNamespace(value string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.Namespace = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithUID sets the UID 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 UID field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithUID(value types.UID) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.UID = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithResourceVersion(value string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.ResourceVersion = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithGeneration(value int64) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.Generation = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithCreationTimestamp(value metav1.Time) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.CreationTimestamp = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds 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 DeletionGracePeriodSeconds field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithLabels puts the entries into the Labels field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the Labels field,
|
||||
// overwriting an existing map entries in Labels field with the same key.
|
||||
func (b *GroupApplyConfiguration) WithLabels(entries map[string]string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.Labels[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the Annotations field,
|
||||
// overwriting an existing map entries in Annotations field with the same key.
|
||||
func (b *GroupApplyConfiguration) WithAnnotations(entries map[string]string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.Annotations[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithOwnerReferences adds the given value to the OwnerReferences 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 OwnerReferences field.
|
||||
func (b *GroupApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithOwnerReferences")
|
||||
}
|
||||
b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithFinalizers adds the given value to the Finalizers 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 Finalizers field.
|
||||
func (b *GroupApplyConfiguration) WithFinalizers(values ...string) *GroupApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *GroupApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||
if b.ObjectMetaApplyConfiguration == nil {
|
||||
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
|
||||
}
|
||||
}
|
||||
|
||||
// WithSpec sets the Spec 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 Spec field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithSpec(value *GroupSpecApplyConfiguration) *GroupApplyConfiguration {
|
||||
b.Spec = value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithStatus sets the Status 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 Status field is set to the value of the last call.
|
||||
func (b *GroupApplyConfiguration) WithStatus(value *GroupStatusApplyConfiguration) *GroupApplyConfiguration {
|
||||
b.Status = value
|
||||
return b
|
||||
}
|
||||
|
||||
// GetKind retrieves the value of the Kind field in the declarative configuration.
|
||||
func (b *GroupApplyConfiguration) GetKind() *string {
|
||||
return b.TypeMetaApplyConfiguration.Kind
|
||||
}
|
||||
|
||||
// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration.
|
||||
func (b *GroupApplyConfiguration) GetAPIVersion() *string {
|
||||
return b.TypeMetaApplyConfiguration.APIVersion
|
||||
}
|
||||
|
||||
// GetName retrieves the value of the Name field in the declarative configuration.
|
||||
func (b *GroupApplyConfiguration) GetName() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Name
|
||||
}
|
||||
|
||||
// GetNamespace retrieves the value of the Namespace field in the declarative configuration.
|
||||
func (b *GroupApplyConfiguration) GetNamespace() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Namespace
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
// GroupSpecApplyConfiguration represents a declarative configuration of the GroupSpec type for use
|
||||
// with apply.
|
||||
//
|
||||
// GroupSpec defines the desired state of Group
|
||||
type GroupSpecApplyConfiguration struct {
|
||||
// name of the group.
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// GroupSpecApplyConfiguration constructs a declarative configuration of the GroupSpec type for use with
|
||||
// apply.
|
||||
func GroupSpec() *GroupSpecApplyConfiguration {
|
||||
return &GroupSpecApplyConfiguration{}
|
||||
}
|
||||
|
||||
// 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 *GroupSpecApplyConfiguration) WithName(value string) *GroupSpecApplyConfiguration {
|
||||
b.Name = &value
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
)
|
||||
|
||||
// GroupStatusApplyConfiguration represents a declarative configuration of the GroupStatus type for use
|
||||
// with apply.
|
||||
//
|
||||
// GroupStatus defines the observed state of Group.
|
||||
type GroupStatusApplyConfiguration struct {
|
||||
GroupID *string `json:"groupID,omitempty"`
|
||||
// The status of each condition is one of True, False, or Unknown.
|
||||
Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
// GroupStatusApplyConfiguration constructs a declarative configuration of the GroupStatus type for use with
|
||||
// apply.
|
||||
func GroupStatus() *GroupStatusApplyConfiguration {
|
||||
return &GroupStatusApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithGroupID sets the GroupID 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 GroupID field is set to the value of the last call.
|
||||
func (b *GroupStatusApplyConfiguration) WithGroupID(value string) *GroupStatusApplyConfiguration {
|
||||
b.GroupID = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithConditions adds the given value to the Conditions 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 Conditions field.
|
||||
func (b *GroupStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *GroupStatusApplyConfiguration {
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithConditions")
|
||||
}
|
||||
b.Conditions = append(b.Conditions, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// ResourceReferenceApplyConfiguration represents a declarative configuration of the ResourceReference type for use
|
||||
// with apply.
|
||||
type ResourceReferenceApplyConfiguration struct {
|
||||
// id of the resource in the Netbird API.
|
||||
ID *string `json:"id,omitempty"`
|
||||
// local reference to the object in the same namespace.
|
||||
LocalRef *v1.LocalObjectReference `json:"localRef,omitempty"`
|
||||
}
|
||||
|
||||
// ResourceReferenceApplyConfiguration constructs a declarative configuration of the ResourceReference type for use with
|
||||
// apply.
|
||||
func ResourceReference() *ResourceReferenceApplyConfiguration {
|
||||
return &ResourceReferenceApplyConfiguration{}
|
||||
}
|
||||
|
||||
// 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 *ResourceReferenceApplyConfiguration) WithID(value string) *ResourceReferenceApplyConfiguration {
|
||||
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 *ResourceReferenceApplyConfiguration) WithLocalRef(value v1.LocalObjectReference) *ResourceReferenceApplyConfiguration {
|
||||
b.LocalRef = &value
|
||||
return b
|
||||
}
|
||||
@@ -15,6 +15,8 @@ type SetupKeySpecApplyConfiguration struct {
|
||||
Ephemeral *bool `json:"ephemeral,omitempty"`
|
||||
// Duration sets how long the setup key is valid for.
|
||||
Duration *v1.Duration `json:"duration,omitempty"`
|
||||
// Groups that will be automatically assigned to resources using setup key.
|
||||
AutoGroups []ResourceReferenceApplyConfiguration `json:"autoGroups,omitempty"`
|
||||
}
|
||||
|
||||
// SetupKeySpecApplyConfiguration constructs a declarative configuration of the SetupKeySpec type for use with
|
||||
@@ -38,3 +40,16 @@ func (b *SetupKeySpecApplyConfiguration) WithDuration(value v1.Duration) *SetupK
|
||||
b.Duration = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// 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 {
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithAutoGroups")
|
||||
}
|
||||
b.AutoGroups = append(b.AutoGroups, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
@@ -16,6 +16,14 @@ import (
|
||||
func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
switch kind {
|
||||
// Group=netbird.io, Version=v1alpha1
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("Group"):
|
||||
return &apiv1alpha1.GroupApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("GroupSpec"):
|
||||
return &apiv1alpha1.GroupSpecApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("GroupStatus"):
|
||||
return &apiv1alpha1.GroupStatusApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("ResourceReference"):
|
||||
return &apiv1alpha1.ResourceReferenceApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("SetupKey"):
|
||||
return &apiv1alpha1.SetupKeyApplyConfiguration{}
|
||||
case v1alpha1.SchemeGroupVersion.WithKind("SetupKeySpec"):
|
||||
|
||||
Reference in New Issue
Block a user