diff --git a/api/v1alpha1/condition_types.go b/api/v1alpha1/condition_types.go new file mode 100644 index 0000000..0958898 --- /dev/null +++ b/api/v1alpha1/condition_types.go @@ -0,0 +1,9 @@ +package v1alpha1 + +const NetbirdFinalizer = "finalizers.netbird.io" + +const ReadyCondition = "Ready" + +const ( + ReconciledReason = "Reconciled" +) diff --git a/api/v1alpha1/group_types.go b/api/v1alpha1/group_types.go index 62da5b7..a08787d 100644 --- a/api/v1alpha1/group_types.go +++ b/api/v1alpha1/group_types.go @@ -4,49 +4,61 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// GroupSpec defines the desired state of Group +// GroupSpec defines the desired state of Group. type GroupSpec struct { - // name of the group. + // Name of the group. // +kubebuilder:validation:MinLength=1 Name string `json:"name"` } // GroupStatus defines the observed state of Group. type GroupStatus struct { + // ObservedGeneration is the last reconciled generation. // +optional - GroupID *string `json:"groupID,omitempty"` + ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // The status of each condition is one of True, False, or Unknown. + // Conditions holds the conditions for the Group. // +listType=map // +listMapKey=type // +optional Conditions []metav1.Condition `json:"conditions,omitempty"` + + // GroupID is the id of the created group. + // +optional + GroupID string `json:"groupID,omitempty"` } // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="" -// Group is the Schema for the groups API +// Group is the Schema for the groups API. type Group struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` - // metadata is a standard object metadata - // +optional - metav1.ObjectMeta `json:"metadata,omitzero"` - - // spec defines the desired state of Group // +required Spec GroupSpec `json:"spec"` - // status defines the observed state of Group - // +optional - Status GroupStatus `json:"status,omitzero"` + // +kubebuilder:default={"observedGeneration":-1} + Status GroupStatus `json:"status,omitempty"` +} + +// GetConditions returns the status conditions of the object. +func (g *Group) GetConditions() []metav1.Condition { + return g.Status.Conditions +} + +// SetConditions sets the status conditions on the object. +func (g *Group) SetConditions(conditions []metav1.Condition) { + g.Status.Conditions = conditions } // +kubebuilder:object:root=true -// GroupList contains a list of Group +// GroupList contains a list of Group. type GroupList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitzero"` diff --git a/api/v1alpha1/setupkey_types.go b/api/v1alpha1/setupkey_types.go index 94ff4b6..e7a106c 100644 --- a/api/v1alpha1/setupkey_types.go +++ b/api/v1alpha1/setupkey_types.go @@ -4,7 +4,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// SetupKeySpec defines the desired state of SetupKey +// SetupKeySpec defines the desired state of SetupKey. type SetupKeySpec struct { // Ephemeral decides if peers added with the key are ephemeral or not. // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ephemeral is immutable" @@ -15,42 +15,53 @@ type SetupKeySpec struct { // +optional Duration *metav1.Duration `json:"duration,omitempty"` - // Groups that will be automatically assigned to resources using setup key. + // AutoGroups are groups that will be automatically assigned to peers using setup key. // +optional AutoGroups []ResourceReference `json:"autoGroups,omitempty"` } // SetupKeyStatus defines the observed state of SetupKey. type SetupKeyStatus struct { - // SetupKeyID of the setup key. - SetupKeyID *string `json:"setupKeyID,omitempty"` + // ObservedGeneration is the last reconciled generation. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // The status of each condition is one of True, False, or Unknown. + // Conditions holds the conditions for the SetupKey. // +listType=map // +listMapKey=type // +optional Conditions []metav1.Condition `json:"conditions,omitempty"` + + // SetupKeyID is the id of the created setup key. + SetupKeyID string `json:"setupKeyID,omitempty"` } // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="" -// SetupKey is the Schema for the setupkeys API +// SetupKey is the Schema for the setupkeys API. type SetupKey struct { - metav1.TypeMeta `json:",inline"` + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` - // metadata is a standard object metadata - // +optional - metav1.ObjectMeta `json:"metadata,omitzero"` - - // spec defines the desired state of SetupKey // +required Spec SetupKeySpec `json:"spec"` - // status defines the observed state of SetupKey - // +optional - Status SetupKeyStatus `json:"status,omitzero"` + // +kubebuilder:default={"observedGeneration":-1} + Status SetupKeyStatus `json:"status,omitempty"` +} + +// GetConditions returns the status conditions of the object. +func (sk *SetupKey) GetConditions() []metav1.Condition { + return sk.Status.Conditions +} + +// SetConditions sets the status conditions on the object. +func (sk *SetupKey) SetConditions(conditions []metav1.Condition) { + sk.Status.Conditions = conditions } func (sk SetupKey) SecretName() string { @@ -59,7 +70,7 @@ func (sk SetupKey) SecretName() string { // +kubebuilder:object:root=true -// SetupKeyList contains a list of SetupKey +// SetupKeyList contains a list of SetupKey. type SetupKeyList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitzero"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index b416ac4..ad01638 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -87,11 +87,6 @@ func (in *GroupSpec) DeepCopy() *GroupSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GroupStatus) DeepCopyInto(out *GroupStatus) { *out = *in - if in.GroupID != nil { - in, out := &in.GroupID, &out.GroupID - *out = new(string) - **out = **in - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]v1.Condition, len(*in)) @@ -225,11 +220,6 @@ func (in *SetupKeySpec) DeepCopy() *SetupKeySpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SetupKeyStatus) DeepCopyInto(out *SetupKeyStatus) { *out = *in - if in.SetupKeyID != nil { - in, out := &in.SetupKeyID, &out.SetupKeyID - *out = new(string) - **out = **in - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]v1.Condition, len(*in)) diff --git a/examples/refactor/setup-key.yaml b/examples/refactor/setup-key.yaml index 12d07df..7d54b06 100644 --- a/examples/refactor/setup-key.yaml +++ b/examples/refactor/setup-key.yaml @@ -4,4 +4,4 @@ metadata: name: test namespace: default spec: - expiration: 0 + ephemeral: true diff --git a/go.mod b/go.mod index 97514dd..154d793 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.25.0 toolchain go1.26.1 require ( + github.com/fluxcd/pkg/runtime v0.103.0 github.com/go-logr/logr v1.4.3 github.com/google/uuid v1.6.0 github.com/netbirdio/netbird v0.66.4 @@ -30,6 +31,7 @@ require ( github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/evanphx/json-patch/v5 v5.9.11 // indirect github.com/fatih/color v1.18.0 // indirect + github.com/fluxcd/pkg/apis/meta v1.26.0 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/go-logr/zapr v1.3.0 // indirect @@ -52,18 +54,19 @@ require ( github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oapi-codegen/runtime v1.1.2 // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/pquerna/cachecontrol v0.2.0 // indirect github.com/prometheus/client_golang v1.23.2 // indirect github.com/prometheus/client_model v0.6.2 // indirect github.com/prometheus/common v0.66.1 // indirect - github.com/prometheus/procfs v0.16.1 // indirect + github.com/prometheus/procfs v0.17.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/x448/float16 v0.8.4 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect + go.uber.org/zap v1.27.1 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/mod v0.32.0 // indirect @@ -75,7 +78,7 @@ require ( golang.org/x/text v0.33.0 // indirect golang.org/x/time v0.14.0 // indirect golang.org/x/tools v0.41.0 // indirect - gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect + gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect google.golang.org/protobuf v1.36.11 // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect @@ -84,8 +87,8 @@ require ( gopkg.in/ldap.v2 v2.5.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.35.0 // indirect - k8s.io/code-generator v0.35.0 // indirect + k8s.io/apiextensions-apiserver v0.35.2 // indirect + k8s.io/code-generator v0.35.2 // indirect k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect diff --git a/go.sum b/go.sum index 46e8956..b5e094a 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= @@ -119,6 +121,10 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/fluxcd/pkg/apis/meta v1.26.0 h1:dxP1FfBpTCYso6odzRcltVnnRuBb2VyhhgV0VX9YbUE= +github.com/fluxcd/pkg/apis/meta v1.26.0/go.mod h1:c7o6mJGLCMvNrfdinGZehkrdZuFT9vZdZNrn66DtVD0= +github.com/fluxcd/pkg/runtime v0.103.0 h1:J5y5GPhWdkyqIUBlaI1FP2N02TtZmsjbWhhZubuTSFk= +github.com/fluxcd/pkg/runtime v0.103.0/go.mod h1:mbo2f3azo3yVQgm7XZGxQB6/2zvzQ5Wgtd8TjRRwwAw= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= @@ -163,8 +169,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI= -github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= +github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ= +github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -329,8 +335,8 @@ github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNw github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE= github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs= github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA= -github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg= -github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is= +github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0= +github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw= github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM= github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= @@ -427,8 +433,8 @@ go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= +go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= @@ -469,8 +475,8 @@ golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvY golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80= golang.zx2c4.com/wireguard/windows v0.5.3 h1:On6j2Rpn3OEMXqBq00QEDC7bWSZrPIHKIus8eIuExIE= golang.zx2c4.com/wireguard/windows v0.5.3/go.mod h1:9TEe8TJmtwyQebdFwAkEWOPr3prrtqm+REGFifP60hI= -gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= -gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +gomodules.xyz/jsonpatch/v2 v2.5.0 h1:JELs8RLM12qJGXU4u/TO3V25KW8GreMKl9pdkk14RM0= +gomodules.xyz/jsonpatch/v2 v2.5.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/api v0.257.0 h1:8Y0lzvHlZps53PEaw+G29SsQIkuKrumGWs9puiexNAA= google.golang.org/api v0.257.0/go.mod h1:4eJrr+vbVaZSqs7vovFd1Jb/A6ml6iw2e6FBYf3GAO4= google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950= @@ -515,18 +521,18 @@ gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= k8s.io/api v0.35.2 h1:tW7mWc2RpxW7HS4CoRXhtYHSzme1PN1UjGHJ1bdrtdw= k8s.io/api v0.35.2/go.mod h1:7AJfqGoAZcwSFhOjcGM7WV05QxMMgUaChNfLTXDRE60= -k8s.io/apiextensions-apiserver v0.35.0 h1:3xHk2rTOdWXXJM+RDQZJvdx0yEOgC0FgQ1PlJatA5T4= -k8s.io/apiextensions-apiserver v0.35.0/go.mod h1:E1Ahk9SADaLQ4qtzYFkwUqusXTcaV2uw3l14aqpL2LU= +k8s.io/apiextensions-apiserver v0.35.2 h1:iyStXHoJZsUXPh/nFAsjC29rjJWdSgUmG1XpApE29c0= +k8s.io/apiextensions-apiserver v0.35.2/go.mod h1:OdyGvcO1FtMDWQ+rRh/Ei3b6X3g2+ZDHd0MSRGeS8rU= k8s.io/apimachinery v0.35.2 h1:NqsM/mmZA7sHW02JZ9RTtk3wInRgbVxL8MPfzSANAK8= k8s.io/apimachinery v0.35.2/go.mod h1:jQCgFZFR1F4Ik7hvr2g84RTJSZegBc8yHgFWKn//hns= -k8s.io/apiserver v0.35.0 h1:CUGo5o+7hW9GcAEF3x3usT3fX4f9r8xmgQeCBDaOgX4= -k8s.io/apiserver v0.35.0/go.mod h1:QUy1U4+PrzbJaM3XGu2tQ7U9A4udRRo5cyxkFX0GEds= +k8s.io/apiserver v0.35.2 h1:rb52v0CZGEL0FkhjS+I6jHflAp7fZ4MIaKcEHX7wmDk= +k8s.io/apiserver v0.35.2/go.mod h1:CROJUAu0tfjZLyYgSeBsBan2T7LUJGh0ucWwTCSSk7g= k8s.io/client-go v0.35.2 h1:YUfPefdGJA4aljDdayAXkc98DnPkIetMl4PrKX97W9o= k8s.io/client-go v0.35.2/go.mod h1:4QqEwh4oQpeK8AaefZ0jwTFJw/9kIjdQi0jpKeYvz7g= -k8s.io/code-generator v0.35.0 h1:TvrtfKYZTm9oDF2z+veFKSCcgZE3Igv0svY+ehCmjHQ= -k8s.io/code-generator v0.35.0/go.mod h1:iS1gvVf3c/T71N5DOGYO+Gt3PdJ6B9LYSvIyQ4FHzgc= -k8s.io/component-base v0.35.0 h1:+yBrOhzri2S1BVqyVSvcM3PtPyx5GUxCK2tinZz1G94= -k8s.io/component-base v0.35.0/go.mod h1:85SCX4UCa6SCFt6p3IKAPej7jSnF3L8EbfSyMZayJR0= +k8s.io/code-generator v0.35.2 h1:3874swbO2c26VWTf6lKD4NWGyHIfyBeTCk7caCG3TuU= +k8s.io/code-generator v0.35.2/go.mod h1:id4XLCm0yAQq5nlvyfAKibMOKnMjzlesAwGw6kM3Adc= +k8s.io/component-base v0.35.2 h1:btgR+qNrpWuRSuvWSnQYsZy88yf5gVwemvz0yw79pGc= +k8s.io/component-base v0.35.2/go.mod h1:B1iBJjooe6xIJYUucAxb26RwhAjzx0gHnqO9htWIX+0= k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b h1:gMplByicHV/TJBizHd9aVEsTYoJBnnUAT5MHlTkbjhQ= k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b/go.mod h1:CgujABENc3KuTrcsdpGmrrASjtQsWCT7R99mEV4U/fM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= diff --git a/helm/kubernetes-operator/crds/netbird.io_groups.yaml b/helm/kubernetes-operator/crds/netbird.io_groups.yaml index 823ea25..95bb602 100644 --- a/helm/kubernetes-operator/crds/netbird.io_groups.yaml +++ b/helm/kubernetes-operator/crds/netbird.io_groups.yaml @@ -14,10 +14,17 @@ spec: singular: group scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 schema: openAPIV3Schema: - description: Group is the Schema for the groups API + description: Group is the Schema for the groups API. properties: apiVersion: description: |- @@ -37,21 +44,22 @@ spec: metadata: type: object spec: - description: spec defines the desired state of Group + description: GroupSpec defines the desired state of Group. properties: name: - description: name of the group. + description: Name of the group. minLength: 1 type: string required: - name type: object status: - description: status defines the observed state of Group + default: + observedGeneration: -1 + description: GroupStatus defines the observed state of Group. properties: conditions: - description: The status of each condition is one of True, False, or - Unknown. + description: Conditions holds the conditions for the Group. items: description: Condition contains details for one aspect of the current state of this API Resource. @@ -111,7 +119,12 @@ spec: - type x-kubernetes-list-type: map groupID: + description: GroupID is the id of the created group. type: string + observedGeneration: + description: ObservedGeneration is the last reconciled generation. + format: int64 + type: integer type: object required: - spec diff --git a/helm/kubernetes-operator/crds/netbird.io_setupkeys.yaml b/helm/kubernetes-operator/crds/netbird.io_setupkeys.yaml index 83ce536..78ce1de 100644 --- a/helm/kubernetes-operator/crds/netbird.io_setupkeys.yaml +++ b/helm/kubernetes-operator/crds/netbird.io_setupkeys.yaml @@ -14,10 +14,17 @@ spec: singular: setupkey scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 schema: openAPIV3Schema: - description: SetupKey is the Schema for the setupkeys API + description: SetupKey is the Schema for the setupkeys API. properties: apiVersion: description: |- @@ -37,11 +44,11 @@ spec: metadata: type: object spec: - description: spec defines the desired state of SetupKey + description: SetupKeySpec defines the desired state of SetupKey. properties: autoGroups: - description: Groups that will be automatically assigned to resources - using setup key. + description: AutoGroups are groups that will be automatically assigned + to peers using setup key. items: properties: id: @@ -84,11 +91,12 @@ spec: - ephemeral type: object status: - description: status defines the observed state of SetupKey + default: + observedGeneration: -1 + description: SetupKeyStatus defines the observed state of SetupKey. properties: conditions: - description: The status of each condition is one of True, False, or - Unknown. + description: Conditions holds the conditions for the SetupKey. items: description: Condition contains details for one aspect of the current state of this API Resource. @@ -147,8 +155,12 @@ spec: x-kubernetes-list-map-keys: - type x-kubernetes-list-type: map + observedGeneration: + description: ObservedGeneration is the last reconciled generation. + format: int64 + type: integer setupKeyID: - description: SetupKeyID of the setup key. + description: SetupKeyID is the id of the created setup key. type: string type: object required: diff --git a/internal/controller/group_controller.go b/internal/controller/group_controller.go index 070cbc8..7b646a7 100644 --- a/internal/controller/group_controller.go +++ b/internal/controller/group_controller.go @@ -3,20 +3,17 @@ package controller import ( "context" + "github.com/fluxcd/pkg/runtime/conditions" + "github.com/fluxcd/pkg/runtime/patch" netbird "github.com/netbirdio/netbird/shared/management/client/rest" "github.com/netbirdio/netbird/shared/management/http/api" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" nbv1alpha1 "github.com/netbirdio/kubernetes-operator/api/v1alpha1" - nbv1alpha1ac "github.com/netbirdio/kubernetes-operator/pkg/applyconfigurations/api/v1alpha1" ) -const ( - GroupFinalizer = "netbird.io/group" -) - -// GroupReconciler reconciles a Group object type GroupReconciler struct { client.Client @@ -27,28 +24,29 @@ type GroupReconciler struct { // +kubebuilder:rbac:groups=netbird.io,resources=groups/status,verbs=get;update;patch // +kubebuilder:rbac:groups=netbird.io,resources=groups/finalizers,verbs=update func (r *GroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - group := nbv1alpha1.Group{} - err := r.Get(ctx, req.NamespacedName, &group) + group := &nbv1alpha1.Group{} + err := r.Get(ctx, req.NamespacedName, group) if err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } + sp := patch.NewSerialPatcher(group, r.Client) if !group.DeletionTimestamp.IsZero() { - return r.reconcileDelete(ctx, group) + return r.reconcileDelete(ctx, sp, group) } - groupAC := nbv1alpha1ac.Group(req.Name, req.Namespace).WithFinalizers(SetupKeyFinalizer) - err = r.Client.Apply(ctx, groupAC) + controllerutil.AddFinalizer(group, nbv1alpha1.NetbirdFinalizer) + err = sp.Patch(ctx, group) if err != nil { return ctrl.Result{}, err } groupID, err := func() (string, error) { - if group.Status.GroupID != nil { - groupReq := api.GroupRequest{ - Name: group.Spec.Name, - } - resp, err := r.Netbird.Groups.Update(ctx, *group.Status.GroupID, groupReq) + groupReq := api.GroupRequest{ + Name: group.Spec.Name, + } + if group.Status.GroupID != "" { + resp, err := r.Netbird.Groups.Update(ctx, group.Status.GroupID, groupReq) if err != nil && !netbird.IsNotFound(err) { return "", err } @@ -56,10 +54,6 @@ func (r *GroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl return resp.Id, nil } } - - groupReq := api.GroupRequest{ - Name: group.Spec.Name, - } resp, err := r.Netbird.Groups.Create(ctx, groupReq) if err != nil { return "", err @@ -69,26 +63,26 @@ func (r *GroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl if err != nil { return ctrl.Result{}, err } + group.Status.GroupID = groupID - groupAC = nbv1alpha1ac.Group(req.Name, req.Namespace).WithStatus(nbv1alpha1ac.GroupStatus().WithGroupID(groupID)) - err = r.Client.Status().Apply(ctx, groupAC) + conditions.MarkTrue(group, nbv1alpha1.ReadyCondition, nbv1alpha1.ReconciledReason, "") + err = sp.Patch(ctx, group, patch.WithStatusObservedGeneration{}) if err != nil { return ctrl.Result{}, err } - return ctrl.Result{}, nil } -func (r *GroupReconciler) reconcileDelete(ctx context.Context, group nbv1alpha1.Group) (ctrl.Result, error) { - if group.Status.GroupID != nil { - err := r.Netbird.Groups.Delete(ctx, *group.Status.GroupID) +func (r *GroupReconciler) reconcileDelete(ctx context.Context, sp *patch.SerialPatcher, group *nbv1alpha1.Group) (ctrl.Result, error) { + if group.Status.GroupID != "" { + err := r.Netbird.Groups.Delete(ctx, group.Status.GroupID) if err != nil && !netbird.IsNotFound(err) { return ctrl.Result{}, err } } - groupAC := nbv1alpha1ac.Group(group.Name, group.Namespace).WithFinalizers() - err := r.Client.Apply(ctx, groupAC) + controllerutil.RemoveFinalizer(group, nbv1alpha1.NetbirdFinalizer) + err := sp.Patch(ctx, group) if err != nil { return ctrl.Result{}, err } diff --git a/internal/controller/group_controller_test.go b/internal/controller/group_controller_test.go index f554729..f33bb6d 100644 --- a/internal/controller/group_controller_test.go +++ b/internal/controller/group_controller_test.go @@ -60,18 +60,18 @@ var _ = Describe("Group Controller", func() { Expect(err).NotTo(HaveOccurred()) err = k8sClient.Get(ctx, nn, group) Expect(err).NotTo(HaveOccurred()) - Expect(*group.Status.GroupID).NotTo(BeEmpty()) + Expect(group.Status.ObservedGeneration).To(Equal(group.Generation)) + Expect(group.Status.GroupID).NotTo(BeEmpty()) By("crerating a new group when deleted from API") - err = controllerReconciler.Netbird.Groups.Delete(ctx, *group.Status.GroupID) + err = controllerReconciler.Netbird.Groups.Delete(ctx, group.Status.GroupID) Expect(err).NotTo(HaveOccurred()) _, err = controllerReconciler.Reconcile(ctx, reconcile.Request{NamespacedName: nn}) Expect(err).NotTo(HaveOccurred()) newGroup := &nbv1alpha1.Group{} err = k8sClient.Get(ctx, nn, newGroup) Expect(err).NotTo(HaveOccurred()) - Expect(*newGroup.Status.GroupID).NotTo(BeEmpty()) - Expect(*newGroup.Status.GroupID).NotTo(Equal(*group.Status.GroupID)) + Expect(newGroup.Status.GroupID).NotTo(Equal(group.Status.GroupID)) }) }) }) diff --git a/internal/controller/setupkey_controller.go b/internal/controller/setupkey_controller.go index 587b82b..3d283a5 100644 --- a/internal/controller/setupkey_controller.go +++ b/internal/controller/setupkey_controller.go @@ -6,6 +6,8 @@ import ( "fmt" "time" + "github.com/fluxcd/pkg/runtime/conditions" + "github.com/fluxcd/pkg/runtime/patch" netbird "github.com/netbirdio/netbird/shared/management/client/rest" "github.com/netbirdio/netbird/shared/management/http/api" corev1 "k8s.io/api/core/v1" @@ -15,14 +17,13 @@ import ( "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" nbv1alpha1 "github.com/netbirdio/kubernetes-operator/api/v1alpha1" "github.com/netbirdio/kubernetes-operator/internal/ssautil" - nbv1alpha1ac "github.com/netbirdio/kubernetes-operator/pkg/applyconfigurations/api/v1alpha1" ) const ( - SetupKeyFinalizer = "netbird.io/setupkey" SetupKeySecretKey = "setup-key" ) @@ -36,14 +37,19 @@ type SetupKeyReconciler struct { // +kubebuilder:rbac:groups=netbird.io,resources=setupkeys/status,verbs=get;update;patch // +kubebuilder:rbac:groups=netbird.io,resources=setupkeys/finalizers,verbs=update func (r *SetupKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - setupKey := nbv1alpha1.SetupKey{} - err := r.Get(ctx, req.NamespacedName, &setupKey) + setupKey := &nbv1alpha1.SetupKey{} + err := r.Get(ctx, req.NamespacedName, setupKey) if err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) } + owner, err := ssautil.OwnerReference(setupKey, r.Client.Scheme()) + if err != nil { + return ctrl.Result{}, err + } + sp := patch.NewSerialPatcher(setupKey, r.Client) if !setupKey.DeletionTimestamp.IsZero() { - return r.reconcileDelete(ctx, setupKey) + return r.reconcileDelete(ctx, sp, setupKey) } // Get ids for auto groups. @@ -67,28 +73,27 @@ func (r *SetupKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c if err != nil { return ctrl.Result{}, err } - if group.Status.GroupID == nil { + if group.Status.GroupID == "" { return ctrl.Result{}, fmt.Errorf("group %s in auto groups list is not ready", group.Name) } - autoGroupIDs = append(autoGroupIDs, *group.Status.GroupID) + autoGroupIDs = append(autoGroupIDs, group.Status.GroupID) } } - // Set finalizer on the setup key. - setupKeyAC := nbv1alpha1ac.SetupKey(req.Name, req.Namespace).WithFinalizers(SetupKeyFinalizer) - err = r.Client.Apply(ctx, setupKeyAC) + controllerutil.AddFinalizer(setupKey, nbv1alpha1.NetbirdFinalizer) + err = sp.Patch(ctx, setupKey) if err != nil { return ctrl.Result{}, err } // Check if setup key is up to date. ok, err := func() (bool, error) { - if setupKey.Status.SetupKeyID == nil { + if setupKey.Status.SetupKeyID == "" { return false, nil } // Check setup key in Netbird. - resp, err := r.Netbird.SetupKeys.Get(ctx, *setupKey.Status.SetupKeyID) + resp, err := r.Netbird.SetupKeys.Get(ctx, setupKey.Status.SetupKeyID) if netbird.IsNotFound(err) { return false, nil } @@ -121,7 +126,7 @@ func (r *SetupKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c setupKeyReq := api.PutApiSetupKeysKeyIdJSONRequestBody{ AutoGroups: autoGroupIDs, } - _, err = r.Netbird.SetupKeys.Update(ctx, *setupKey.Status.SetupKeyID, setupKeyReq) + _, err = r.Netbird.SetupKeys.Update(ctx, setupKey.Status.SetupKeyID, setupKeyReq) if err != nil { return false, err } @@ -154,19 +159,13 @@ func (r *SetupKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c if err != nil { return ctrl.Result{}, err } - - // Update the status with the id. - setupKeyAC = nbv1alpha1ac.SetupKey(req.Name, req.Namespace).WithStatus(nbv1alpha1ac.SetupKeyStatus().WithSetupKeyID(resp.Id)) - err = r.Client.Status().Apply(ctx, setupKeyAC) + setupKey.Status.SetupKeyID = resp.Id + err = sp.Patch(ctx, setupKey) if err != nil { return ctrl.Result{}, err } // Create the secret containing the key. - owner, err := ssautil.OwnerReference(&setupKey, r.Scheme()) - if err != nil { - return ctrl.Result{}, err - } data := map[string]string{ SetupKeySecretKey: resp.Key, } @@ -179,30 +178,34 @@ func (r *SetupKeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c } // Delete the old status key if we are recreating. - if oldSetupKeyID != nil { - err = r.Netbird.SetupKeys.Delete(ctx, *oldSetupKeyID) + if oldSetupKeyID != "" { + err = r.Netbird.SetupKeys.Delete(ctx, oldSetupKeyID) if err != nil && !netbird.IsNotFound(err) { return ctrl.Result{}, err } } - return ctrl.Result{RequeueAfter: 15 * time.Minute}, nil -} - -func (r *SetupKeyReconciler) reconcileDelete(ctx context.Context, setupKey nbv1alpha1.SetupKey) (ctrl.Result, error) { - if setupKey.Status.SetupKeyID != nil { - err := r.Netbird.SetupKeys.Delete(ctx, *setupKey.Status.SetupKeyID) - if err != nil && !netbird.IsNotFound(err) { - return ctrl.Result{}, err - } - } - - setupKeyAC := nbv1alpha1ac.SetupKey(setupKey.Name, setupKey.Namespace).WithFinalizers() - err := r.Client.Apply(ctx, setupKeyAC) + conditions.MarkTrue(setupKey, nbv1alpha1.ReadyCondition, nbv1alpha1.ReconciledReason, "") + err = sp.Patch(ctx, setupKey, patch.WithStatusObservedGeneration{}) if err != nil { return ctrl.Result{}, err } + return ctrl.Result{RequeueAfter: 15 * time.Minute}, nil +} +func (r *SetupKeyReconciler) reconcileDelete(ctx context.Context, sp *patch.SerialPatcher, setupKey *nbv1alpha1.SetupKey) (ctrl.Result, error) { + if setupKey.Status.SetupKeyID != "" { + err := r.Netbird.SetupKeys.Delete(ctx, setupKey.Status.SetupKeyID) + if err != nil && !netbird.IsNotFound(err) { + return ctrl.Result{}, err + } + } + + controllerutil.RemoveFinalizer(setupKey, nbv1alpha1.NetbirdFinalizer) + err := sp.Patch(ctx, setupKey) + if err != nil { + return ctrl.Result{}, err + } return ctrl.Result{}, nil } diff --git a/internal/controller/setupkey_controller_test.go b/internal/controller/setupkey_controller_test.go index 811d7af..585cb87 100644 --- a/internal/controller/setupkey_controller_test.go +++ b/internal/controller/setupkey_controller_test.go @@ -57,7 +57,8 @@ var _ = Describe("SetupKey Controller", func() { err = k8sClient.Get(ctx, nn, setupKey) Expect(err).NotTo(HaveOccurred()) - Expect(*setupKey.Status.SetupKeyID).NotTo(BeEmpty()) + Expect(setupKey.Status.ObservedGeneration).To(Equal(setupKey.Generation)) + Expect(setupKey.Status.SetupKeyID).NotTo(BeEmpty()) secret := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -68,7 +69,7 @@ var _ = Describe("SetupKey Controller", func() { err = k8sClient.Get(ctx, client.ObjectKeyFromObject(secret), secret) Expect(err).NotTo(HaveOccurred()) - resp, err := controllerReconciler.Netbird.SetupKeys.Get(ctx, *setupKey.Status.SetupKeyID) + resp, err := controllerReconciler.Netbird.SetupKeys.Get(ctx, setupKey.Status.SetupKeyID) Expect(err).NotTo(HaveOccurred()) Expect(string(secret.Data[SetupKeySecretKey])).To(Equal(resp.Key)) }) @@ -114,7 +115,7 @@ var _ = Describe("SetupKey Controller", func() { Expect(err).NotTo(HaveOccurred()) Expect(k8sClient.Delete(ctx, &secondSecret)).To(Succeed()) - Expect(*firstSetupKey.Status.SetupKeyID).ToNot(Equal(*secondSetupKey.Status.SetupKeyID)) + Expect(firstSetupKey.Status.SetupKeyID).ToNot(Equal(secondSetupKey.Status.SetupKeyID)) Expect(firstSecret.Data[SetupKeySecretKey]).ToNot(BeEquivalentTo(secondSecret.Data[SetupKeySecretKey])) }) }) diff --git a/pkg/applyconfigurations/api/v1alpha1/group.go b/pkg/applyconfigurations/api/v1alpha1/group.go index a812d6f..73fe628 100644 --- a/pkg/applyconfigurations/api/v1alpha1/group.go +++ b/pkg/applyconfigurations/api/v1alpha1/group.go @@ -11,15 +11,12 @@ import ( // GroupApplyConfiguration represents a declarative configuration of the Group type for use // with apply. // -// Group is the Schema for the groups API +// Group is the Schema for the groups API. type GroupApplyConfiguration struct { - v1.TypeMetaApplyConfiguration `json:",inline"` - // metadata is a standard object metadata + v1.TypeMetaApplyConfiguration `json:",inline"` *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"` + Spec *GroupSpecApplyConfiguration `json:"spec,omitempty"` + Status *GroupStatusApplyConfiguration `json:"status,omitempty"` } // Group constructs a declarative configuration of the Group type for use with diff --git a/pkg/applyconfigurations/api/v1alpha1/groupspec.go b/pkg/applyconfigurations/api/v1alpha1/groupspec.go index 7ccf93e..d7b1e67 100644 --- a/pkg/applyconfigurations/api/v1alpha1/groupspec.go +++ b/pkg/applyconfigurations/api/v1alpha1/groupspec.go @@ -5,9 +5,9 @@ package v1alpha1 // GroupSpecApplyConfiguration represents a declarative configuration of the GroupSpec type for use // with apply. // -// GroupSpec defines the desired state of Group +// GroupSpec defines the desired state of Group. type GroupSpecApplyConfiguration struct { - // name of the group. + // Name of the group. Name *string `json:"name,omitempty"` } diff --git a/pkg/applyconfigurations/api/v1alpha1/groupstatus.go b/pkg/applyconfigurations/api/v1alpha1/groupstatus.go index 4a1d54c..557b72e 100644 --- a/pkg/applyconfigurations/api/v1alpha1/groupstatus.go +++ b/pkg/applyconfigurations/api/v1alpha1/groupstatus.go @@ -11,9 +11,12 @@ import ( // // 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. + // ObservedGeneration is the last reconciled generation. + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + // Conditions holds the conditions for the Group. Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"` + // GroupID is the id of the created group. + GroupID *string `json:"groupID,omitempty"` } // GroupStatusApplyConfiguration constructs a declarative configuration of the GroupStatus type for use with @@ -22,11 +25,11 @@ func GroupStatus() *GroupStatusApplyConfiguration { return &GroupStatusApplyConfiguration{} } -// WithGroupID sets the GroupID field in the declarative configuration to the given value +// WithObservedGeneration sets the ObservedGeneration 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 +// If called multiple times, the ObservedGeneration field is set to the value of the last call. +func (b *GroupStatusApplyConfiguration) WithObservedGeneration(value int64) *GroupStatusApplyConfiguration { + b.ObservedGeneration = &value return b } @@ -42,3 +45,11 @@ func (b *GroupStatusApplyConfiguration) WithConditions(values ...*v1.ConditionAp } return b } + +// 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 +} diff --git a/pkg/applyconfigurations/api/v1alpha1/setupkey.go b/pkg/applyconfigurations/api/v1alpha1/setupkey.go index 1d46c98..88bb856 100644 --- a/pkg/applyconfigurations/api/v1alpha1/setupkey.go +++ b/pkg/applyconfigurations/api/v1alpha1/setupkey.go @@ -11,15 +11,12 @@ import ( // SetupKeyApplyConfiguration represents a declarative configuration of the SetupKey type for use // with apply. // -// SetupKey is the Schema for the setupkeys API +// SetupKey is the Schema for the setupkeys API. type SetupKeyApplyConfiguration struct { - v1.TypeMetaApplyConfiguration `json:",inline"` - // metadata is a standard object metadata + v1.TypeMetaApplyConfiguration `json:",inline"` *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - // spec defines the desired state of SetupKey - Spec *SetupKeySpecApplyConfiguration `json:"spec,omitempty"` - // status defines the observed state of SetupKey - Status *SetupKeyStatusApplyConfiguration `json:"status,omitempty"` + Spec *SetupKeySpecApplyConfiguration `json:"spec,omitempty"` + Status *SetupKeyStatusApplyConfiguration `json:"status,omitempty"` } // SetupKey constructs a declarative configuration of the SetupKey type for use with diff --git a/pkg/applyconfigurations/api/v1alpha1/setupkeyspec.go b/pkg/applyconfigurations/api/v1alpha1/setupkeyspec.go index 50ef2e8..66457b4 100644 --- a/pkg/applyconfigurations/api/v1alpha1/setupkeyspec.go +++ b/pkg/applyconfigurations/api/v1alpha1/setupkeyspec.go @@ -9,13 +9,13 @@ import ( // SetupKeySpecApplyConfiguration represents a declarative configuration of the SetupKeySpec type for use // with apply. // -// SetupKeySpec defines the desired state of SetupKey +// SetupKeySpec defines the desired state of SetupKey. type SetupKeySpecApplyConfiguration struct { // Ephemeral decides if peers added with the key are ephemeral or not. 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 are groups that will be automatically assigned to peers using setup key. AutoGroups []ResourceReferenceApplyConfiguration `json:"autoGroups,omitempty"` } diff --git a/pkg/applyconfigurations/api/v1alpha1/setupkeystatus.go b/pkg/applyconfigurations/api/v1alpha1/setupkeystatus.go index a323a73..08b22d3 100644 --- a/pkg/applyconfigurations/api/v1alpha1/setupkeystatus.go +++ b/pkg/applyconfigurations/api/v1alpha1/setupkeystatus.go @@ -11,10 +11,12 @@ import ( // // SetupKeyStatus defines the observed state of SetupKey. type SetupKeyStatusApplyConfiguration struct { - // SetupKeyID of the setup key. - SetupKeyID *string `json:"setupKeyID,omitempty"` - // The status of each condition is one of True, False, or Unknown. + // ObservedGeneration is the last reconciled generation. + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + // Conditions holds the conditions for the SetupKey. Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"` + // SetupKeyID is the id of the created setup key. + SetupKeyID *string `json:"setupKeyID,omitempty"` } // SetupKeyStatusApplyConfiguration constructs a declarative configuration of the SetupKeyStatus type for use with @@ -23,11 +25,11 @@ func SetupKeyStatus() *SetupKeyStatusApplyConfiguration { return &SetupKeyStatusApplyConfiguration{} } -// WithSetupKeyID sets the SetupKeyID field in the declarative configuration to the given value +// WithObservedGeneration sets the ObservedGeneration 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 SetupKeyID field is set to the value of the last call. -func (b *SetupKeyStatusApplyConfiguration) WithSetupKeyID(value string) *SetupKeyStatusApplyConfiguration { - b.SetupKeyID = &value +// If called multiple times, the ObservedGeneration field is set to the value of the last call. +func (b *SetupKeyStatusApplyConfiguration) WithObservedGeneration(value int64) *SetupKeyStatusApplyConfiguration { + b.ObservedGeneration = &value return b } @@ -43,3 +45,11 @@ func (b *SetupKeyStatusApplyConfiguration) WithConditions(values ...*v1.Conditio } return b } + +// WithSetupKeyID sets the SetupKeyID 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 SetupKeyID field is set to the value of the last call. +func (b *SetupKeyStatusApplyConfiguration) WithSetupKeyID(value string) *SetupKeyStatusApplyConfiguration { + b.SetupKeyID = &value + return b +}