mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 18:59:09 +00:00
Implement new setup key resource (#178)
This change implements a new resource called SetupKey that manages the lifecycle of setup keys and stores them in secrets. A major change here is that we are also switching to using SSA for resource management. Part of #172 Signed-off-by: Philip Laine <philip.laine@gmail.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Package v1alpha1 contains API Schema definitions for the v1alpha1 API group.
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=netbird.io
|
||||
// +kubebuilder:ac:generate=true
|
||||
// +kubebuilder:ac:output:package=../../pkg/applyconfigurations
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects.
|
||||
GroupVersion = schema.GroupVersion{Group: "netbird.io", Version: "v1alpha1"}
|
||||
SchemeGroupVersion = GroupVersion
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
@@ -0,0 +1,67 @@
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// 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"
|
||||
Ephemeral bool `json:"ephemeral"`
|
||||
|
||||
// Duration sets how long the setup key is valid for.
|
||||
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="duration is immutable"
|
||||
// +optional
|
||||
Duration *metav1.Duration `json:"duration,omitempty"`
|
||||
}
|
||||
|
||||
// SetupKeyStatus defines the observed state of SetupKey.
|
||||
type SetupKeyStatus struct {
|
||||
// SetupKeyID of the setup key.
|
||||
SetupKeyID *string `json:"setupKeyID,omitempty"`
|
||||
|
||||
// The status of each condition is one of True, False, or Unknown.
|
||||
// +listType=map
|
||||
// +listMapKey=type
|
||||
// +optional
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:resource
|
||||
|
||||
// SetupKey is the Schema for the setupkeys API
|
||||
type SetupKey struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
func (sk SetupKey) SecretName() string {
|
||||
return "setup-key-" + sk.Name
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// SetupKeyList contains a list of SetupKey
|
||||
type SetupKeyList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitzero"`
|
||||
Items []SetupKey `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&SetupKey{}, &SetupKeyList{})
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
//go:build !ignore_autogenerated
|
||||
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SetupKey) DeepCopyInto(out *SetupKey) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SetupKey.
|
||||
func (in *SetupKey) DeepCopy() *SetupKey {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SetupKey)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *SetupKey) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SetupKeyList) DeepCopyInto(out *SetupKeyList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]SetupKey, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SetupKeyList.
|
||||
func (in *SetupKeyList) DeepCopy() *SetupKeyList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SetupKeyList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *SetupKeyList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *SetupKeySpec) DeepCopyInto(out *SetupKeySpec) {
|
||||
*out = *in
|
||||
if in.Duration != nil {
|
||||
in, out := &in.Duration, &out.Duration
|
||||
*out = new(v1.Duration)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SetupKeySpec.
|
||||
func (in *SetupKeySpec) DeepCopy() *SetupKeySpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SetupKeySpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// 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))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SetupKeyStatus.
|
||||
func (in *SetupKeyStatus) DeepCopy() *SetupKeyStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(SetupKeyStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user