From 0d160b5f08e65d6bac87def6492688707c48a27d Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Tue, 12 May 2026 20:56:52 +0200 Subject: [PATCH 01/14] feat: transfer sample-controller --- Makefile | 3 + .../examples/crd-status-subresource.yaml | 41 + artifacts/examples/crd.yaml | 37 + artifacts/examples/example-foo.yaml | 7 + controller.go | 421 +++ controller_test.go | 316 ++ go.mod | 61 + go.sum | 143 + hack/boilerplate.go.txt | 16 + hack/tools.go | 22 + hack/update-codegen.sh | 59 + hack/verify-codegen.sh | 57 + main.go | 88 + pkg/apis/samplecontroller/v1alpha1/doc.go | 22 + pkg/apis/samplecontroller/v1alpha1/types.go | 54 + .../v1alpha1/zz_generated.deepcopy.go | 124 + .../v1alpha1/zz_generated.register.go | 71 + .../applyconfiguration/internal/internal.go | 72 + .../samplecontroller/v1alpha1/foo.go | 289 ++ .../samplecontroller/v1alpha1/foospec.go | 50 + .../samplecontroller/v1alpha1/foostatus.go | 41 + pkg/generated/applyconfiguration/utils.go | 48 + .../clientset/versioned/clientset.go | 120 + .../versioned/fake/clientset_generated.go | 142 + pkg/generated/clientset/versioned/fake/doc.go | 20 + .../clientset/versioned/fake/register.go | 56 + .../clientset/versioned/scheme/doc.go | 20 + .../clientset/versioned/scheme/register.go | 56 + .../typed/samplecontroller/v1alpha1/doc.go | 20 + .../samplecontroller/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_foo.go | 49 + .../fake/fake_samplecontroller_client.go | 40 + .../typed/samplecontroller/v1alpha1/foo.go | 74 + .../v1alpha1/generated_expansion.go | 21 + .../v1alpha1/samplecontroller_client.go | 101 + .../informers/externalversions/factory.go | 333 ++ .../informers/externalversions/generic.go | 62 + .../internalinterfaces/factory_interfaces.go | 59 + .../samplecontroller/interface.go | 46 + .../samplecontroller/v1alpha1/foo.go | 116 + .../samplecontroller/v1alpha1/interface.go | 45 + .../v1alpha1/expansion_generated.go | 27 + .../listers/samplecontroller/v1alpha1/foo.go | 70 + .../openapi/cmd/models-schema/main.go | 76 + pkg/generated/openapi/zz_generated.openapi.go | 2943 +++++++++++++++++ pkg/signals/signal.go | 44 + pkg/signals/signal_posix.go | 26 + pkg/signals/signal_windows.go | 23 + 48 files changed, 6651 insertions(+) create mode 100644 artifacts/examples/crd-status-subresource.yaml create mode 100644 artifacts/examples/crd.yaml create mode 100644 artifacts/examples/example-foo.yaml create mode 100644 controller.go create mode 100644 controller_test.go create mode 100644 go.sum create mode 100644 hack/boilerplate.go.txt create mode 100644 hack/tools.go create mode 100755 hack/update-codegen.sh create mode 100755 hack/verify-codegen.sh create mode 100644 main.go create mode 100644 pkg/apis/samplecontroller/v1alpha1/doc.go create mode 100644 pkg/apis/samplecontroller/v1alpha1/types.go create mode 100644 pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go create mode 100644 pkg/generated/applyconfiguration/internal/internal.go create mode 100644 pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go create mode 100644 pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go create mode 100644 pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go create mode 100644 pkg/generated/applyconfiguration/utils.go create mode 100644 pkg/generated/clientset/versioned/clientset.go create mode 100644 pkg/generated/clientset/versioned/fake/clientset_generated.go create mode 100644 pkg/generated/clientset/versioned/fake/doc.go create mode 100644 pkg/generated/clientset/versioned/fake/register.go create mode 100644 pkg/generated/clientset/versioned/scheme/doc.go create mode 100644 pkg/generated/clientset/versioned/scheme/register.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/doc.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go create mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go create mode 100644 pkg/generated/informers/externalversions/factory.go create mode 100644 pkg/generated/informers/externalversions/generic.go create mode 100644 pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/generated/informers/externalversions/samplecontroller/interface.go create mode 100644 pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go create mode 100644 pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go create mode 100644 pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go create mode 100644 pkg/generated/listers/samplecontroller/v1alpha1/foo.go create mode 100644 pkg/generated/openapi/cmd/models-schema/main.go create mode 100644 pkg/generated/openapi/zz_generated.openapi.go create mode 100644 pkg/signals/signal.go create mode 100644 pkg/signals/signal_posix.go create mode 100644 pkg/signals/signal_windows.go diff --git a/Makefile b/Makefile index c5404c4..728f6bc 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,6 @@ build: run: make build ./main + +codegen: + ./hack/update-codegen.sh diff --git a/artifacts/examples/crd-status-subresource.yaml b/artifacts/examples/crd-status-subresource.yaml new file mode 100644 index 0000000..90b70d1 --- /dev/null +++ b/artifacts/examples/crd-status-subresource.yaml @@ -0,0 +1,41 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: foos.samplecontroller.k8s.io + # for more information on the below annotation, please see + # https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2337-k8s.io-group-protection/README.md + annotations: + "api-approved.kubernetes.io": "unapproved, experimental-only; please get an approval from Kubernetes API reviewers if you're trying to develop a CRD in the *.k8s.io or *.kubernetes.io groups" +spec: + group: samplecontroller.k8s.io + versions: + - name: v1alpha1 + served: true + storage: true + schema: + # schema used for validation + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + deploymentName: + type: string + replicas: + type: integer + minimum: 1 + maximum: 10 + status: + type: object + properties: + availableReplicas: + type: integer + # subresources for the custom resource + subresources: + # enables the status subresource + status: {} + names: + kind: Foo + plural: foos + scope: Namespaced diff --git a/artifacts/examples/crd.yaml b/artifacts/examples/crd.yaml new file mode 100644 index 0000000..8ac6e60 --- /dev/null +++ b/artifacts/examples/crd.yaml @@ -0,0 +1,37 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: foos.samplecontroller.k8s.io + # for more information on the below annotation, please see + # https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2337-k8s.io-group-protection/README.md + annotations: + "api-approved.kubernetes.io": "unapproved, experimental-only; please get an approval from Kubernetes API reviewers if you're trying to develop a CRD in the *.k8s.io or *.kubernetes.io groups" +spec: + group: samplecontroller.k8s.io + versions: + - name: v1alpha1 + served: true + storage: true + schema: + # schema used for validation + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + deploymentName: + type: string + replicas: + type: integer + minimum: 1 + maximum: 10 + status: + type: object + properties: + availableReplicas: + type: integer + names: + kind: Foo + plural: foos + scope: Namespaced diff --git a/artifacts/examples/example-foo.yaml b/artifacts/examples/example-foo.yaml new file mode 100644 index 0000000..897059c --- /dev/null +++ b/artifacts/examples/example-foo.yaml @@ -0,0 +1,7 @@ +apiVersion: samplecontroller.k8s.io/v1alpha1 +kind: Foo +metadata: + name: example-foo +spec: + deploymentName: example-foo + replicas: 1 diff --git a/controller.go b/controller.go new file mode 100644 index 0000000..5553509 --- /dev/null +++ b/controller.go @@ -0,0 +1,421 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + "fmt" + "time" + + "golang.org/x/time/rate" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/apimachinery/pkg/util/wait" + appsinformers "k8s.io/client-go/informers/apps/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/kubernetes/scheme" + typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" + appslisters "k8s.io/client-go/listers/apps/v1" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/tools/record" + "k8s.io/client-go/util/workqueue" + "k8s.io/klog/v2" + + samplev1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + samplescheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" + informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/samplecontroller/v1alpha1" + listers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/samplecontroller/v1alpha1" +) + +const controllerAgentName = "sample-controller" + +const ( + // SuccessSynced is used as part of the Event 'reason' when a Foo is synced + SuccessSynced = "Synced" + // ErrResourceExists is used as part of the Event 'reason' when a Foo fails + // to sync due to a Deployment of the same name already existing. + ErrResourceExists = "ErrResourceExists" + + // MessageResourceExists is the message used for Events when a resource + // fails to sync due to a Deployment already existing + MessageResourceExists = "Resource %q already exists and is not managed by Foo" + // MessageResourceSynced is the message used for an Event fired when a Foo + // is synced successfully + MessageResourceSynced = "Foo synced successfully" + // FieldManager distinguishes this controller from other things writing to API objects + FieldManager = controllerAgentName +) + +// Controller is the controller implementation for Foo resources +type Controller struct { + // kubeclientset is a standard kubernetes clientset + kubeclientset kubernetes.Interface + // sampleclientset is a clientset for our own API group + sampleclientset clientset.Interface + + deploymentsLister appslisters.DeploymentLister + deploymentsSynced cache.InformerSynced + foosLister listers.FooLister + foosSynced cache.InformerSynced + + // workqueue is a rate limited work queue. This is used to queue work to be + // processed instead of performing it as soon as a change happens. This + // means we can ensure we only process a fixed amount of resources at a + // time, and makes it easy to ensure we are never processing the same item + // simultaneously in two different workers. + workqueue workqueue.TypedRateLimitingInterface[cache.ObjectName] + // recorder is an event recorder for recording Event resources to the + // Kubernetes API. + recorder record.EventRecorder +} + +// NewController returns a new sample controller +func NewController( + ctx context.Context, + kubeclientset kubernetes.Interface, + sampleclientset clientset.Interface, + deploymentInformer appsinformers.DeploymentInformer, + fooInformer informers.FooInformer) *Controller { + logger := klog.FromContext(ctx) + + // Create event broadcaster + // Add sample-controller types to the default Kubernetes Scheme so Events can be + // logged for sample-controller types. + utilruntime.Must(samplescheme.AddToScheme(scheme.Scheme)) + logger.V(4).Info("Creating event broadcaster") + + eventBroadcaster := record.NewBroadcaster(record.WithContext(ctx)) + eventBroadcaster.StartStructuredLogging(0) + eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeclientset.CoreV1().Events("")}) + recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName}) + ratelimiter := workqueue.NewTypedMaxOfRateLimiter( + workqueue.NewTypedItemExponentialFailureRateLimiter[cache.ObjectName](5*time.Millisecond, 1000*time.Second), + &workqueue.TypedBucketRateLimiter[cache.ObjectName]{Limiter: rate.NewLimiter(rate.Limit(50), 300)}, + ) + + controller := &Controller{ + kubeclientset: kubeclientset, + sampleclientset: sampleclientset, + deploymentsLister: deploymentInformer.Lister(), + deploymentsSynced: deploymentInformer.Informer().HasSynced, + foosLister: fooInformer.Lister(), + foosSynced: fooInformer.Informer().HasSynced, + workqueue: workqueue.NewTypedRateLimitingQueue(ratelimiter), + recorder: recorder, + } + + logger.Info("Setting up event handlers") + // Set up an event handler for when Foo resources change + fooInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: controller.enqueueFoo, + UpdateFunc: func(old, new interface{}) { + controller.enqueueFoo(new) + }, + }) + // Set up an event handler for when Deployment resources change. This + // handler will lookup the owner of the given Deployment, and if it is + // owned by a Foo resource then the handler will enqueue that Foo resource for + // processing. This way, we don't need to implement custom logic for + // handling Deployment resources. More info on this pattern: + // https://github.com/kubernetes/community/blob/8cafef897a22026d42f5e5bb3f104febe7e29830/contributors/devel/controllers.md + deploymentInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: controller.handleObject, + UpdateFunc: func(old, new interface{}) { + newDepl := new.(*appsv1.Deployment) + oldDepl := old.(*appsv1.Deployment) + if newDepl.ResourceVersion == oldDepl.ResourceVersion { + // Periodic resync will send update events for all known Deployments. + // Two different versions of the same Deployment will always have different RVs. + return + } + controller.handleObject(new) + }, + DeleteFunc: controller.handleObject, + }) + + return controller +} + +// Run will set up the event handlers for types we are interested in, as well +// as syncing informer caches and starting workers. It will block until stopCh +// is closed, at which point it will shutdown the workqueue and wait for +// workers to finish processing their current work items. +func (c *Controller) Run(ctx context.Context, workers int) error { + defer utilruntime.HandleCrash() + defer c.workqueue.ShutDown() + logger := klog.FromContext(ctx) + + // Start the informer factories to begin populating the informer caches + logger.Info("Starting Foo controller") + + // Wait for the caches to be synced before starting workers + logger.Info("Waiting for informer caches to sync") + + if ok := cache.WaitForCacheSync(ctx.Done(), c.deploymentsSynced, c.foosSynced); !ok { + return fmt.Errorf("failed to wait for caches to sync") + } + + logger.Info("Starting workers", "count", workers) + // Launch two workers to process Foo resources + for i := 0; i < workers; i++ { + go wait.UntilWithContext(ctx, c.runWorker, time.Second) + } + + logger.Info("Started workers") + <-ctx.Done() + logger.Info("Shutting down workers") + + return nil +} + +// runWorker is a long-running function that will continually call the +// processNextWorkItem function in order to read and process a message on the +// workqueue. +func (c *Controller) runWorker(ctx context.Context) { + for c.processNextWorkItem(ctx) { + } +} + +// processNextWorkItem will read a single work item off the workqueue and +// attempt to process it, by calling the syncHandler. +func (c *Controller) processNextWorkItem(ctx context.Context) bool { + objRef, shutdown := c.workqueue.Get() + logger := klog.FromContext(ctx) + + if shutdown { + return false + } + + // We call Done at the end of this func so the workqueue knows we have + // finished processing this item. We also must remember to call Forget + // if we do not want this work item being re-queued. For example, we do + // not call Forget if a transient error occurs, instead the item is + // put back on the workqueue and attempted again after a back-off + // period. + defer c.workqueue.Done(objRef) + + // Run the syncHandler, passing it the structured reference to the object to be synced. + err := c.syncHandler(ctx, objRef) + if err == nil { + // If no error occurs then we Forget this item so it does not + // get queued again until another change happens. + c.workqueue.Forget(objRef) + logger.Info("Successfully synced", "objectName", objRef) + return true + } + // there was a failure so be sure to report it. This method allows for + // pluggable error handling which can be used for things like + // cluster-monitoring. + utilruntime.HandleErrorWithContext(ctx, err, "Error syncing; requeuing for later retry", "objectReference", objRef) + // since we failed, we should requeue the item to work on later. This + // method will add a backoff to avoid hotlooping on particular items + // (they're probably still not going to work right away) and overall + // controller protection (everything I've done is broken, this controller + // needs to calm down or it can starve other useful work) cases. + c.workqueue.AddRateLimited(objRef) + return true +} + +// syncHandler compares the actual state with the desired, and attempts to +// converge the two. It then updates the Status block of the Foo resource +// with the current status of the resource. +func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName) error { + logger := klog.LoggerWithValues(klog.FromContext(ctx), "objectRef", objectRef) + + // Get the Foo resource with this namespace/name + foo, err := c.foosLister.Foos(objectRef.Namespace).Get(objectRef.Name) + if err != nil { + // The Foo resource may no longer exist, in which case we stop + // processing. + if errors.IsNotFound(err) { + utilruntime.HandleErrorWithContext(ctx, err, "Foo referenced by item in work queue no longer exists", "objectReference", objectRef) + return nil + } + + return err + } + + deploymentName := foo.Spec.DeploymentName + if deploymentName == "" { + // We choose to absorb the error here as the worker would requeue the + // resource otherwise. Instead, the next time the resource is updated + // the resource will be queued again. + utilruntime.HandleErrorWithContext(ctx, nil, "Deployment name missing from object reference", "objectReference", objectRef) + return nil + } + + // Get the deployment with the name specified in Foo.spec + deployment, err := c.deploymentsLister.Deployments(foo.Namespace).Get(deploymentName) + // If the resource doesn't exist, we'll create it + if errors.IsNotFound(err) { + deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Create(ctx, newDeployment(foo), metav1.CreateOptions{FieldManager: FieldManager}) + } + + // If an error occurs during Get/Create, we'll requeue the item so we can + // attempt processing again later. This could have been caused by a + // temporary network failure, or any other transient reason. + if err != nil { + return err + } + + // If the Deployment is not controlled by this Foo resource, we should log + // a warning to the event recorder and return error msg. + if !metav1.IsControlledBy(deployment, foo) { + msg := fmt.Sprintf(MessageResourceExists, deployment.Name) + c.recorder.Event(foo, corev1.EventTypeWarning, ErrResourceExists, msg) + return fmt.Errorf("%s", msg) + } + + // If this number of the replicas on the Foo resource is specified, and the + // number does not equal the current desired replicas on the Deployment, we + // should update the Deployment resource. + if foo.Spec.Replicas != nil && *foo.Spec.Replicas != *deployment.Spec.Replicas { + logger.V(4).Info("Update deployment resource", "currentReplicas", *deployment.Spec.Replicas, "desiredReplicas", *foo.Spec.Replicas) + deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Update(ctx, newDeployment(foo), metav1.UpdateOptions{FieldManager: FieldManager}) + } + + // If an error occurs during Update, we'll requeue the item so we can + // attempt processing again later. This could have been caused by a + // temporary network failure, or any other transient reason. + if err != nil { + return err + } + + // Finally, we update the status block of the Foo resource to reflect the + // current state of the world + err = c.updateFooStatus(ctx, foo, deployment) + if err != nil { + return err + } + + c.recorder.Event(foo, corev1.EventTypeNormal, SuccessSynced, MessageResourceSynced) + return nil +} + +func (c *Controller) updateFooStatus(ctx context.Context, foo *samplev1alpha1.Foo, deployment *appsv1.Deployment) error { + // NEVER modify objects from the store. It's a read-only, local cache. + // You can use DeepCopy() to make a deep copy of original object and modify this copy + // Or create a copy manually for better performance + fooCopy := foo.DeepCopy() + fooCopy.Status.AvailableReplicas = deployment.Status.AvailableReplicas + // If the CustomResourceSubresources feature gate is not enabled, + // we must use Update instead of UpdateStatus to update the Status block of the Foo resource. + // UpdateStatus will not allow changes to the Spec of the resource, + // which is ideal for ensuring nothing other than resource status has been updated. + _, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).UpdateStatus(ctx, fooCopy, metav1.UpdateOptions{FieldManager: FieldManager}) + return err +} + +// enqueueFoo takes a Foo resource and converts it into a namespace/name +// string which is then put onto the work queue. This method should *not* be +// passed resources of any type other than Foo. +func (c *Controller) enqueueFoo(obj interface{}) { + if objectRef, err := cache.ObjectToName(obj); err != nil { + utilruntime.HandleError(err) + return + } else { + c.workqueue.Add(objectRef) + } +} + +// handleObject will take any resource implementing metav1.Object and attempt +// to find the Foo resource that 'owns' it. It does this by looking at the +// objects metadata.ownerReferences field for an appropriate OwnerReference. +// It then enqueues that Foo resource to be processed. If the object does not +// have an appropriate OwnerReference, it will simply be skipped. +func (c *Controller) handleObject(obj interface{}) { + var object metav1.Object + var ok bool + logger := klog.FromContext(context.Background()) + if object, ok = obj.(metav1.Object); !ok { + tombstone, ok := obj.(cache.DeletedFinalStateUnknown) + if !ok { + // If the object value is not too big and does not contain sensitive information then + // it may be useful to include it. + utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object, invalid type", "type", fmt.Sprintf("%T", obj)) + return + } + object, ok = tombstone.Obj.(metav1.Object) + if !ok { + // If the object value is not too big and does not contain sensitive information then + // it may be useful to include it. + utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object tombstone, invalid type", "type", fmt.Sprintf("%T", tombstone.Obj)) + return + } + logger.V(4).Info("Recovered deleted object", "resourceName", object.GetName()) + } + logger.V(4).Info("Processing object", "object", klog.KObj(object)) + if ownerRef := metav1.GetControllerOf(object); ownerRef != nil { + // If this object is not owned by a Foo, we should not do anything more + // with it. + if ownerRef.Kind != "Foo" { + return + } + + foo, err := c.foosLister.Foos(object.GetNamespace()).Get(ownerRef.Name) + if err != nil { + logger.V(4).Info("Ignore orphaned object", "object", klog.KObj(object), "foo", ownerRef.Name) + return + } + + c.enqueueFoo(foo) + return + } +} + +// newDeployment creates a new Deployment for a Foo resource. It also sets +// the appropriate OwnerReferences on the resource so handleObject can discover +// the Foo resource that 'owns' it. +func newDeployment(foo *samplev1alpha1.Foo) *appsv1.Deployment { + labels := map[string]string{ + "app": "nginx", + "controller": foo.Name, + } + return &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: foo.Spec.DeploymentName, + Namespace: foo.Namespace, + OwnerReferences: []metav1.OwnerReference{ + *metav1.NewControllerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")), + }, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: foo.Spec.Replicas, + Selector: &metav1.LabelSelector{ + MatchLabels: labels, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: labels, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "nginx", + Image: "nginx:latest", + }, + }, + }, + }, + }, + } +} diff --git a/controller_test.go b/controller_test.go new file mode 100644 index 0000000..5ae6321 --- /dev/null +++ b/controller_test.go @@ -0,0 +1,316 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "context" + "fmt" + "reflect" + "testing" + "time" + + apps "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/diff" + kubeinformers "k8s.io/client-go/informers" + k8sfake "k8s.io/client-go/kubernetes/fake" + core "k8s.io/client-go/testing" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/tools/record" + "k8s.io/klog/v2/ktesting" + "k8s.io/utils/ptr" + + samplecontroller "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/fake" + informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions" +) + +var ( + alwaysReady = func() bool { return true } + noResyncPeriodFunc = func() time.Duration { return 0 } +) + +type fixture struct { + t *testing.T + + client *fake.Clientset + kubeclient *k8sfake.Clientset + // Objects to put in the store. + fooLister []*samplecontroller.Foo + deploymentLister []*apps.Deployment + // Actions expected to happen on the client. + kubeactions []core.Action + actions []core.Action + // Objects from here preloaded into NewSimpleFake. + kubeobjects []runtime.Object + objects []runtime.Object +} + +func newFixture(t *testing.T) *fixture { + f := &fixture{} + f.t = t + f.objects = []runtime.Object{} + f.kubeobjects = []runtime.Object{} + return f +} + +func newFoo(name string, replicas *int32) *samplecontroller.Foo { + return &samplecontroller.Foo{ + TypeMeta: metav1.TypeMeta{APIVersion: samplecontroller.SchemeGroupVersion.String()}, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: metav1.NamespaceDefault, + }, + Spec: samplecontroller.FooSpec{ + DeploymentName: fmt.Sprintf("%s-deployment", name), + Replicas: replicas, + }, + } +} + +func (f *fixture) newController(ctx context.Context) (*Controller, informers.SharedInformerFactory, kubeinformers.SharedInformerFactory) { + f.client = fake.NewClientset(f.objects...) + f.kubeclient = k8sfake.NewClientset(f.kubeobjects...) + + i := informers.NewSharedInformerFactory(f.client, noResyncPeriodFunc()) + k8sI := kubeinformers.NewSharedInformerFactory(f.kubeclient, noResyncPeriodFunc()) + + c := NewController(ctx, f.kubeclient, f.client, + k8sI.Apps().V1().Deployments(), i.Samplecontroller().V1alpha1().Foos()) + + c.foosSynced = alwaysReady + c.deploymentsSynced = alwaysReady + c.recorder = &record.FakeRecorder{} + + for _, f := range f.fooLister { + i.Samplecontroller().V1alpha1().Foos().Informer().GetIndexer().Add(f) + } + + for _, d := range f.deploymentLister { + k8sI.Apps().V1().Deployments().Informer().GetIndexer().Add(d) + } + + return c, i, k8sI +} + +func (f *fixture) run(ctx context.Context, fooRef cache.ObjectName) { + f.runController(ctx, fooRef, true, false) +} + +func (f *fixture) runExpectError(ctx context.Context, fooRef cache.ObjectName) { + f.runController(ctx, fooRef, true, true) +} + +func (f *fixture) runController(ctx context.Context, fooRef cache.ObjectName, startInformers bool, expectError bool) { + c, i, k8sI := f.newController(ctx) + if startInformers { + i.Start(ctx.Done()) + k8sI.Start(ctx.Done()) + } + + err := c.syncHandler(ctx, fooRef) + if !expectError && err != nil { + f.t.Errorf("error syncing foo: %v", err) + } else if expectError && err == nil { + f.t.Error("expected error syncing foo, got nil") + } + + actions := filterInformerActions(f.client.Actions()) + for i, action := range actions { + if len(f.actions) < i+1 { + f.t.Errorf("%d unexpected actions: %+v", len(actions)-len(f.actions), actions[i:]) + break + } + + expectedAction := f.actions[i] + checkAction(expectedAction, action, f.t) + } + + if len(f.actions) > len(actions) { + f.t.Errorf("%d additional expected actions:%+v", len(f.actions)-len(actions), f.actions[len(actions):]) + } + + k8sActions := filterInformerActions(f.kubeclient.Actions()) + for i, action := range k8sActions { + if len(f.kubeactions) < i+1 { + f.t.Errorf("%d unexpected actions: %+v", len(k8sActions)-len(f.kubeactions), k8sActions[i:]) + break + } + + expectedAction := f.kubeactions[i] + checkAction(expectedAction, action, f.t) + } + + if len(f.kubeactions) > len(k8sActions) { + f.t.Errorf("%d additional expected actions:%+v", len(f.kubeactions)-len(k8sActions), f.kubeactions[len(k8sActions):]) + } +} + +// checkAction verifies that expected and actual actions are equal and both have +// same attached resources +func checkAction(expected, actual core.Action, t *testing.T) { + if !(expected.Matches(actual.GetVerb(), actual.GetResource().Resource) && actual.GetSubresource() == expected.GetSubresource()) { + t.Errorf("Expected\n\t%#v\ngot\n\t%#v", expected, actual) + return + } + + if reflect.TypeOf(actual) != reflect.TypeOf(expected) { + t.Errorf("Action has wrong type. Expected: %t. Got: %t", expected, actual) + return + } + + switch a := actual.(type) { + case core.CreateActionImpl: + e, _ := expected.(core.CreateActionImpl) + expObject := e.GetObject() + object := a.GetObject() + + if !reflect.DeepEqual(expObject, object) { + t.Errorf("Action %s %s has wrong object\nDiff:\n %s", + a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object)) + } + case core.UpdateActionImpl: + e, _ := expected.(core.UpdateActionImpl) + expObject := e.GetObject() + object := a.GetObject() + + if !reflect.DeepEqual(expObject, object) { + t.Errorf("Action %s %s has wrong object\nDiff:\n %s", + a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object)) + } + case core.PatchActionImpl: + e, _ := expected.(core.PatchActionImpl) + expPatch := e.GetPatch() + patch := a.GetPatch() + + if !reflect.DeepEqual(expPatch, patch) { + t.Errorf("Action %s %s has wrong patch\nDiff:\n %s", + a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expPatch, patch)) + } + default: + t.Errorf("Uncaptured Action %s %s, you should explicitly add a case to capture it", + actual.GetVerb(), actual.GetResource().Resource) + } +} + +// filterInformerActions filters list and watch actions for testing resources. +// Since list and watch don't change resource state we can filter it to lower +// nose level in our tests. +func filterInformerActions(actions []core.Action) []core.Action { + ret := []core.Action{} + for _, action := range actions { + if len(action.GetNamespace()) == 0 && + (action.Matches("list", "foos") || + action.Matches("watch", "foos") || + action.Matches("list", "deployments") || + action.Matches("watch", "deployments")) { + continue + } + ret = append(ret, action) + } + + return ret +} + +func (f *fixture) expectCreateDeploymentAction(d *apps.Deployment) { + f.kubeactions = append(f.kubeactions, core.NewCreateAction(schema.GroupVersionResource{Resource: "deployments"}, d.Namespace, d)) +} + +func (f *fixture) expectUpdateDeploymentAction(d *apps.Deployment) { + f.kubeactions = append(f.kubeactions, core.NewUpdateAction(schema.GroupVersionResource{Resource: "deployments"}, d.Namespace, d)) +} + +func (f *fixture) expectUpdateFooStatusAction(foo *samplecontroller.Foo) { + action := core.NewUpdateSubresourceAction(schema.GroupVersionResource{Resource: "foos"}, "status", foo.Namespace, foo) + f.actions = append(f.actions, action) +} + +func getRef(foo *samplecontroller.Foo, t *testing.T) cache.ObjectName { + ref := cache.MetaObjectToName(foo) + return ref +} + +func TestCreatesDeployment(t *testing.T) { + f := newFixture(t) + foo := newFoo("test", ptr.To[int32](1)) + _, ctx := ktesting.NewTestContext(t) + + f.fooLister = append(f.fooLister, foo) + f.objects = append(f.objects, foo) + + expDeployment := newDeployment(foo) + f.expectCreateDeploymentAction(expDeployment) + f.expectUpdateFooStatusAction(foo) + + f.run(ctx, getRef(foo, t)) +} + +func TestDoNothing(t *testing.T) { + f := newFixture(t) + foo := newFoo("test", ptr.To[int32](1)) + _, ctx := ktesting.NewTestContext(t) + + d := newDeployment(foo) + + f.fooLister = append(f.fooLister, foo) + f.objects = append(f.objects, foo) + f.deploymentLister = append(f.deploymentLister, d) + f.kubeobjects = append(f.kubeobjects, d) + + f.expectUpdateFooStatusAction(foo) + f.run(ctx, getRef(foo, t)) +} + +func TestUpdateDeployment(t *testing.T) { + f := newFixture(t) + foo := newFoo("test", ptr.To[int32](1)) + _, ctx := ktesting.NewTestContext(t) + + d := newDeployment(foo) + + // Update replicas + foo.Spec.Replicas = ptr.To[int32](2) + expDeployment := newDeployment(foo) + + f.fooLister = append(f.fooLister, foo) + f.objects = append(f.objects, foo) + f.deploymentLister = append(f.deploymentLister, d) + f.kubeobjects = append(f.kubeobjects, d) + + f.expectUpdateFooStatusAction(foo) + f.expectUpdateDeploymentAction(expDeployment) + f.run(ctx, getRef(foo, t)) +} + +func TestNotControlledByUs(t *testing.T) { + f := newFixture(t) + foo := newFoo("test", ptr.To[int32](1)) + _, ctx := ktesting.NewTestContext(t) + + d := newDeployment(foo) + + d.ObjectMeta.OwnerReferences = []metav1.OwnerReference{} + + f.fooLister = append(f.fooLister, foo) + f.objects = append(f.objects, foo) + f.deploymentLister = append(f.deploymentLister, d) + f.kubeobjects = append(f.kubeobjects, d) + + f.runExpectError(ctx, getRef(foo, t)) +} diff --git a/go.mod b/go.mod index 949962d..0e5e94b 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,64 @@ module gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator go 1.26.3 + +godebug default=go1.26 + +require ( + golang.org/x/time v0.15.0 + k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec + k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5 + k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940 + k8s.io/code-generator v0.0.0-20260509210052-5595d1310975 + k8s.io/klog/v2 v2.140.0 + k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b + k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 + sigs.k8s.io/structured-merge-diff/v6 v6.3.2 +) + +require ( + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.13.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.1 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-openapi/jsonpointer v0.22.4 // indirect + github.com/go-openapi/jsonreference v0.21.4 // indirect + github.com/go-openapi/swag v0.25.4 // indirect + github.com/go-openapi/swag/cmdutils v0.25.4 // indirect + github.com/go-openapi/swag/conv v0.25.4 // indirect + github.com/go-openapi/swag/fileutils v0.25.4 // indirect + github.com/go-openapi/swag/jsonname v0.25.4 // indirect + github.com/go-openapi/swag/jsonutils v0.25.4 // indirect + github.com/go-openapi/swag/loading v0.25.4 // indirect + github.com/go-openapi/swag/mangling v0.25.4 // indirect + github.com/go-openapi/swag/netutils v0.25.4 // indirect + github.com/go-openapi/swag/stringutils v0.25.4 // indirect + github.com/go-openapi/swag/typeutils v0.25.4 // indirect + github.com/go-openapi/swag/yamlutils v0.25.4 // indirect + github.com/google/gnostic-models v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/spf13/pflag v1.0.10 // indirect + github.com/x448/float16 v0.8.4 // indirect + go.yaml.in/yaml/v2 v2.4.4 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/mod v0.35.0 // indirect + golang.org/x/net v0.53.0 // indirect + golang.org/x/oauth2 v0.36.0 // indirect + golang.org/x/sync v0.20.0 // indirect + golang.org/x/sys v0.43.0 // indirect + golang.org/x/term v0.42.0 // indirect + golang.org/x/text v0.36.0 // indirect + golang.org/x/tools v0.44.0 // indirect + google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect + gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..fd8673a --- /dev/null +++ b/go.sum @@ -0,0 +1,143 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= +github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ= +github.com/fxamacker/cbor/v2 v2.9.1/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4= +github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80= +github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8= +github.com/go-openapi/jsonreference v0.21.4/go.mod h1:rIENPTjDbLpzQmQWCj5kKj3ZlmEh+EFVbz3RTUh30/4= +github.com/go-openapi/swag v0.25.4 h1:OyUPUFYDPDBMkqyxOTkqDYFnrhuhi9NR6QVUvIochMU= +github.com/go-openapi/swag v0.25.4/go.mod h1:zNfJ9WZABGHCFg2RnY0S4IOkAcVTzJ6z2Bi+Q4i6qFQ= +github.com/go-openapi/swag/cmdutils v0.25.4 h1:8rYhB5n6WawR192/BfUu2iVlxqVR9aRgGJP6WaBoW+4= +github.com/go-openapi/swag/cmdutils v0.25.4/go.mod h1:pdae/AFo6WxLl5L0rq87eRzVPm/XRHM3MoYgRMvG4A0= +github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4= +github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU= +github.com/go-openapi/swag/fileutils v0.25.4 h1:2oI0XNW5y6UWZTC7vAxC8hmsK/tOkWXHJQH4lKjqw+Y= +github.com/go-openapi/swag/fileutils v0.25.4/go.mod h1:cdOT/PKbwcysVQ9Tpr0q20lQKH7MGhOEb6EwmHOirUk= +github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI= +github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag= +github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA= +github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4 h1:IACsSvBhiNJwlDix7wq39SS2Fh7lUOCJRmx/4SN4sVo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4/go.mod h1:Mt0Ost9l3cUzVv4OEZG+WSeoHwjWLnarzMePNDAOBiM= +github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s= +github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE= +github.com/go-openapi/swag/mangling v0.25.4 h1:2b9kBJk9JvPgxr36V23FxJLdwBrpijI26Bx5JH4Hp48= +github.com/go-openapi/swag/mangling v0.25.4/go.mod h1:6dxwu6QyORHpIIApsdZgb6wBk/DPU15MdyYj/ikn0Hg= +github.com/go-openapi/swag/netutils v0.25.4 h1:Gqe6K71bGRb3ZQLusdI8p/y1KLgV4M/k+/HzVSqT8H0= +github.com/go-openapi/swag/netutils v0.25.4/go.mod h1:m2W8dtdaoX7oj9rEttLyTeEFFEBvnAx9qHd5nJEBzYg= +github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8= +github.com/go-openapi/swag/stringutils v0.25.4/go.mod h1:GTsRvhJW5xM5gkgiFe0fV3PUlFm0dr8vki6/VSRaZK0= +github.com/go-openapi/swag/typeutils v0.25.4 h1:1/fbZOUN472NTc39zpa+YGHn3jzHWhv42wAJSN91wRw= +github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE= +github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw= +github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +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= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= +golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= +golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= +golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= +golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= +golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= +golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= +golang.org/x/term v0.42.0/go.mod h1:Dq/D+snpsbazcBG5+F9Q1n2rXV8Ma+71xEjTRufARgY= +golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= +golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= +golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= +golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= +golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= +golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= +golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= +gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec h1:xf12Yh3ltN4fnNyP0CyyM0TwNVnZDfLJjV3+bf9fPFY= +k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec/go.mod h1:C+fcNlNQ9TcKHspN+DD7UybdfnjDAGyBjfCd6W7ogbY= +k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5 h1:k2HBxRBq6w2QCj14oAhBosjMqqgNlj4dmLXFj8f1A+8= +k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5/go.mod h1:37ALVDWo0LgW74Y9rAdewmZo20SVCGGH34806wUMrko= +k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940 h1:n5t5Jx3VpLdiAGxIvIHsZDmsExtZVwghUPLM3wFi6Go= +k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940/go.mod h1:0e7OLwg7kdXISVFwn7ishFdvxfVgi7wsqHqsQPHl61w= +k8s.io/code-generator v0.0.0-20260509210052-5595d1310975 h1:hDrusFgTzvqcDJ7p13A9Eid4i8Y9uNSs/67lniaYHwM= +k8s.io/code-generator v0.0.0-20260509210052-5595d1310975/go.mod h1:mQXg0n0EeF4oU8aTwm9mzwoyAKqVRmUb9wLhjHnRq3I= +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.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= +k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= +k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b h1:WrpNVPKkCaOO9h77E1P2HLnhWDQxrxzpf2jfsM8WevY= +k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b/go.mod h1:V/QaCUYDa+0QpcHhVVc5l99Uz56wEMEXBSj9oCDkNDY= +k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 h1:AZYQSJemyQB5eRxqcPky+/7EdBj0xi3g0ZcxxJ7vbWU= +k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.2 h1:kwVWMx5yS1CrnFWA/2QHyRVJ8jM6dBA80uLmm0wJkk8= +sigs.k8s.io/structured-merge-diff/v6 v6.3.2/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt new file mode 100644 index 0000000..b7c650d --- /dev/null +++ b/hack/boilerplate.go.txt @@ -0,0 +1,16 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + diff --git a/hack/tools.go b/hack/tools.go new file mode 100644 index 0000000..3e2ab98 --- /dev/null +++ b/hack/tools.go @@ -0,0 +1,22 @@ +//go:build tools + +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This package imports things required by build scripts, to force `go mod` to see them as dependencies +package tools + +import _ "k8s.io/code-generator" diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh new file mode 100755 index 0000000..31d9dae --- /dev/null +++ b/hack/update-codegen.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} + +source "${CODEGEN_PKG}/kube_codegen.sh" + +THIS_PKG="gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator" + +kube::codegen::gen_helpers \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + "${SCRIPT_ROOT}/pkg/apis" + +if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then + report_filename="${API_KNOWN_VIOLATIONS_DIR}/sample_controller_violation_exceptions.list" + if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then + update_report="--update-report" + fi +fi + +kube::codegen::gen_openapi \ + --output-dir "${SCRIPT_ROOT}/pkg/generated/openapi" \ + --output-pkg "k8s.io/${THIS_PKG}/pkg/generated/openapi" \ + --report-filename "${report_filename:-"/dev/null"}" \ + --output-model-name-file "zz_generated.model_name.go" \ + ${update_report:+"${update_report}"} \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + "${SCRIPT_ROOT}/pkg/apis" + +kube::codegen::gen_client \ + --with-watch \ + --with-applyconfig \ + --applyconfig-openapi-schema <(go run gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/openapi/cmd/models-schema) \ + --output-dir "${SCRIPT_ROOT}/pkg/generated" \ + --output-pkg "${THIS_PKG}/pkg/generated" \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + "${SCRIPT_ROOT}/pkg/apis" + +kube::codegen::gen_register \ + --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ + "${SCRIPT_ROOT}/pkg/apis" diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh new file mode 100755 index 0000000..0af433f --- /dev/null +++ b/hack/verify-codegen.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o nounset +set -o pipefail + +SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +DIFFROOT="${SCRIPT_ROOT}/pkg" +TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg" + +cleanup() { + rm -rf "${TMP_DIFFROOT}" +} +trap "cleanup" EXIT SIGINT + +cleanup + +# Ensure model-schema generator matches the version from +# k8s.io/kubernetes/pkg/generated/openapi/cmd/models-schema/main.go +echo "Ensuring models-schema is up-to-date" +K8S_MODELS_SCHEMA="${SCRIPT_ROOT}/../../../../pkg/generated/openapi/cmd/models-schema/main.go" +SAMPLE_CONTROLLER_MODELS_SCHEMA="${SCRIPT_ROOT}/pkg/generated/openapi/cmd/models-schema/main.go" +# these two files will only differ in the imported lines for generated openapi +if ! diff -I "k8s.io/kubernetes/pkg/generated/openapi" \ + -I "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/openapi" \ + "${K8S_MODELS_SCHEMA}" "${SAMPLE_CONTROLLER_MODELS_SCHEMA}"; then + echo "${SAMPLE_CONTROLLER_MODELS_SCHEMA} is out of date. Compare changes with ${K8S_MODELS_SCHEMA}" + exit 1 +fi + +mkdir -p "${TMP_DIFFROOT}" +cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" + +"${SCRIPT_ROOT}/hack/update-codegen.sh" +echo "diffing ${DIFFROOT} against freshly generated codegen" +ret=0 +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +if [[ $ret -eq 0 ]]; then + echo "${DIFFROOT} up to date." +else + echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" +fi +exit $ret diff --git a/main.go b/main.go new file mode 100644 index 0000000..fac31a3 --- /dev/null +++ b/main.go @@ -0,0 +1,88 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "flag" + "time" + + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/signals" + kubeinformers "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/clientcmd" + "k8s.io/klog/v2" + + // Uncomment the following line to load the gcp plugin (only required to authenticate against GKE clusters). + // _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + + clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions" +) + +var ( + masterURL string + kubeconfig string +) + +func main() { + klog.InitFlags(nil) + flag.Parse() + + // set up signals so we handle the shutdown signal gracefully + ctx := signals.SetupSignalHandler() + logger := klog.FromContext(ctx) + + cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig) + if err != nil { + logger.Error(err, "Error building kubeconfig") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } + + kubeClient, err := kubernetes.NewForConfig(cfg) + if err != nil { + logger.Error(err, "Error building kubernetes clientset") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } + + exampleClient, err := clientset.NewForConfig(cfg) + if err != nil { + logger.Error(err, "Error building kubernetes clientset") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } + + kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30) + exampleInformerFactory := informers.NewSharedInformerFactory(exampleClient, time.Second*30) + + controller := NewController(ctx, kubeClient, exampleClient, + kubeInformerFactory.Apps().V1().Deployments(), + exampleInformerFactory.Samplecontroller().V1alpha1().Foos()) + + // notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(ctx.done()) + // Start method is non-blocking and runs all registered informers in a dedicated goroutine. + kubeInformerFactory.Start(ctx.Done()) + exampleInformerFactory.Start(ctx.Done()) + + if err = controller.Run(ctx, 2); err != nil { + logger.Error(err, "Error running controller") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } +} + +func init() { + flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") + flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") +} diff --git a/pkg/apis/samplecontroller/v1alpha1/doc.go b/pkg/apis/samplecontroller/v1alpha1/doc.go new file mode 100644 index 0000000..72ef5ae --- /dev/null +++ b/pkg/apis/samplecontroller/v1alpha1/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:openapi-gen=true +// +groupName=samplecontroller.k8s.io + +// Package v1alpha1 is the v1alpha1 version of the API. +package v1alpha1 diff --git a/pkg/apis/samplecontroller/v1alpha1/types.go b/pkg/apis/samplecontroller/v1alpha1/types.go new file mode 100644 index 0000000..e387d34 --- /dev/null +++ b/pkg/apis/samplecontroller/v1alpha1/types.go @@ -0,0 +1,54 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Foo is a specification for a Foo resource +type Foo struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec FooSpec `json:"spec"` + Status FooStatus `json:"status"` +} + +// FooSpec is the spec for a Foo resource +type FooSpec struct { + DeploymentName string `json:"deploymentName"` + Replicas *int32 `json:"replicas"` +} + +// FooStatus is the status for a Foo resource +type FooStatus struct { + AvailableReplicas int32 `json:"availableReplicas"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// FooList is a list of Foo resources +type FooList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []Foo `json:"items"` +} diff --git a/pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000..2619460 --- /dev/null +++ b/pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,124 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + 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 *Foo) DeepCopyInto(out *Foo) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Foo. +func (in *Foo) DeepCopy() *Foo { + if in == nil { + return nil + } + out := new(Foo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Foo) 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 *FooList) DeepCopyInto(out *FooList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Foo, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooList. +func (in *FooList) DeepCopy() *FooList { + if in == nil { + return nil + } + out := new(FooList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FooList) 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 *FooSpec) DeepCopyInto(out *FooSpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooSpec. +func (in *FooSpec) DeepCopy() *FooSpec { + if in == nil { + return nil + } + out := new(FooSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FooStatus) DeepCopyInto(out *FooStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooStatus. +func (in *FooStatus) DeepCopy() *FooStatus { + if in == nil { + return nil + } + out := new(FooStatus) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go b/pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go new file mode 100644 index 0000000..146e82e --- /dev/null +++ b/pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go @@ -0,0 +1,71 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by register-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName specifies the group name used to register the objects. +const GroupName = "samplecontroller.k8s.io" + +// GroupVersion specifies the group and the version used to register the objects. +var GroupVersion = v1.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// SchemeGroupVersion is group version used to register these objects +// +// Deprecated: use GroupVersion instead. +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. + SchemeBuilder runtime.SchemeBuilder + localSchemeBuilder = &SchemeBuilder + // Deprecated: use Install instead + AddToScheme = localSchemeBuilder.AddToScheme + Install = localSchemeBuilder.AddToScheme +) + +func init() { + // We only register manually written functions here. The registration of the + // generated functions takes place in the generated files. The separation + // makes the code compile even when the generated files are missing. + localSchemeBuilder.Register(addKnownTypes) +} + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Foo{}, + &FooList{}, + ) + // AddToGroupVersion allows the serialization of client types like ListOptions. + v1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/generated/applyconfiguration/internal/internal.go b/pkg/generated/applyconfiguration/internal/internal.go new file mode 100644 index 0000000..66a908c --- /dev/null +++ b/pkg/generated/applyconfiguration/internal/internal.go @@ -0,0 +1,72 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package internal + +import ( + fmt "fmt" + sync "sync" + + typed "sigs.k8s.io/structured-merge-diff/v6/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: io.k8s.sample-controller.pkg.apis.samplecontroller.v1alpha1.Foo + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go new file mode 100644 index 0000000..b55eeff --- /dev/null +++ b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go @@ -0,0 +1,289 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + internal "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/internal" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// FooApplyConfiguration represents a declarative configuration of the Foo type for use +// with apply. +// +// Foo is a specification for a Foo resource +type FooApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *FooSpecApplyConfiguration `json:"spec,omitempty"` + Status *FooStatusApplyConfiguration `json:"status,omitempty"` +} + +// Foo constructs a declarative configuration of the Foo type for use with +// apply. +func Foo(name, namespace string) *FooApplyConfiguration { + b := &FooApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Foo") + b.WithAPIVersion("samplecontroller.k8s.io/v1alpha1") + return b +} + +// ExtractFooFrom extracts the applied configuration owned by fieldManager from +// foo for the specified subresource. Pass an empty string for subresource to extract +// the main resource. Common subresources include "status", "scale", etc. +// foo must be a unmodified Foo API object that was retrieved from the Kubernetes API. +// ExtractFooFrom provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +func ExtractFooFrom(foo *samplecontrollerv1alpha1.Foo, fieldManager string, subresource string) (*FooApplyConfiguration, error) { + b := &FooApplyConfiguration{} + err := managedfields.ExtractInto(foo, internal.Parser().Type("io.k8s.sample-controller.pkg.apis.samplecontroller.v1alpha1.Foo"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(foo.Name) + b.WithNamespace(foo.Namespace) + + b.WithKind("Foo") + b.WithAPIVersion("samplecontroller.k8s.io/v1alpha1") + return b, nil +} + +// ExtractFoo extracts the applied configuration owned by fieldManager from +// foo. If no managedFields are found in foo for fieldManager, a +// FooApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// foo must be a unmodified Foo API object that was retrieved from the Kubernetes API. +// ExtractFoo provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +func ExtractFoo(foo *samplecontrollerv1alpha1.Foo, fieldManager string) (*FooApplyConfiguration, error) { + return ExtractFooFrom(foo, fieldManager, "") +} + +// ExtractFooStatus extracts the applied configuration owned by fieldManager from +// foo for the status subresource. +func ExtractFooStatus(foo *samplecontrollerv1alpha1.Foo, fieldManager string) (*FooApplyConfiguration, error) { + return ExtractFooFrom(foo, fieldManager, "status") +} + +func (b FooApplyConfiguration) 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 *FooApplyConfiguration) WithKind(value string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithAPIVersion(value string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithName(value string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithGenerateName(value string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithNamespace(value string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithUID(value types.UID) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithResourceVersion(value string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithGeneration(value int64) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithCreationTimestamp(value metav1.Time) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithLabels(entries map[string]string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithAnnotations(entries map[string]string) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithFinalizers(values ...string) *FooApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *FooApplyConfiguration) 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 *FooApplyConfiguration) WithSpec(value *FooSpecApplyConfiguration) *FooApplyConfiguration { + 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 *FooApplyConfiguration) WithStatus(value *FooStatusApplyConfiguration) *FooApplyConfiguration { + b.Status = value + return b +} + +// GetKind retrieves the value of the Kind field in the declarative configuration. +func (b *FooApplyConfiguration) GetKind() *string { + return b.TypeMetaApplyConfiguration.Kind +} + +// GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. +func (b *FooApplyConfiguration) GetAPIVersion() *string { + return b.TypeMetaApplyConfiguration.APIVersion +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *FooApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} + +// GetNamespace retrieves the value of the Namespace field in the declarative configuration. +func (b *FooApplyConfiguration) GetNamespace() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Namespace +} diff --git a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go new file mode 100644 index 0000000..91a1410 --- /dev/null +++ b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go @@ -0,0 +1,50 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// FooSpecApplyConfiguration represents a declarative configuration of the FooSpec type for use +// with apply. +// +// FooSpec is the spec for a Foo resource +type FooSpecApplyConfiguration struct { + DeploymentName *string `json:"deploymentName,omitempty"` + Replicas *int32 `json:"replicas,omitempty"` +} + +// FooSpecApplyConfiguration constructs a declarative configuration of the FooSpec type for use with +// apply. +func FooSpec() *FooSpecApplyConfiguration { + return &FooSpecApplyConfiguration{} +} + +// WithDeploymentName sets the DeploymentName 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 DeploymentName field is set to the value of the last call. +func (b *FooSpecApplyConfiguration) WithDeploymentName(value string) *FooSpecApplyConfiguration { + b.DeploymentName = &value + return b +} + +// WithReplicas sets the Replicas 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 Replicas field is set to the value of the last call. +func (b *FooSpecApplyConfiguration) WithReplicas(value int32) *FooSpecApplyConfiguration { + b.Replicas = &value + return b +} diff --git a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go new file mode 100644 index 0000000..f170c81 --- /dev/null +++ b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go @@ -0,0 +1,41 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +// FooStatusApplyConfiguration represents a declarative configuration of the FooStatus type for use +// with apply. +// +// FooStatus is the status for a Foo resource +type FooStatusApplyConfiguration struct { + AvailableReplicas *int32 `json:"availableReplicas,omitempty"` +} + +// FooStatusApplyConfiguration constructs a declarative configuration of the FooStatus type for use with +// apply. +func FooStatus() *FooStatusApplyConfiguration { + return &FooStatusApplyConfiguration{} +} + +// WithAvailableReplicas sets the AvailableReplicas 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 AvailableReplicas field is set to the value of the last call. +func (b *FooStatusApplyConfiguration) WithAvailableReplicas(value int32) *FooStatusApplyConfiguration { + b.AvailableReplicas = &value + return b +} diff --git a/pkg/generated/applyconfiguration/utils.go b/pkg/generated/applyconfiguration/utils.go new file mode 100644 index 0000000..2e03b62 --- /dev/null +++ b/pkg/generated/applyconfiguration/utils.go @@ -0,0 +1,48 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package applyconfiguration + +import ( + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + internal "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/internal" + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/samplecontroller/v1alpha1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" +) + +// ForKind returns an apply configuration type for the given GroupVersionKind, or nil if no +// apply configuration type exists for the given GroupVersionKind. +func ForKind(kind schema.GroupVersionKind) interface{} { + switch kind { + // Group=samplecontroller.k8s.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("Foo"): + return &samplecontrollerv1alpha1.FooApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("FooSpec"): + return &samplecontrollerv1alpha1.FooSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("FooStatus"): + return &samplecontrollerv1alpha1.FooStatusApplyConfiguration{} + + } + return nil +} + +func NewTypeConverter(scheme *runtime.Scheme) managedfields.TypeConverter { + return managedfields.NewSchemeTypeConverter(scheme, internal.Parser()) +} diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go new file mode 100644 index 0000000..2339bde --- /dev/null +++ b/pkg/generated/clientset/versioned/clientset.go @@ -0,0 +1,120 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + fmt "fmt" + http "net/http" + + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + samplecontrollerV1alpha1 *samplecontrollerv1alpha1.SamplecontrollerV1alpha1Client +} + +// SamplecontrollerV1alpha1 retrieves the SamplecontrollerV1alpha1Client +func (c *Clientset) SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface { + return c.samplecontrollerV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.samplecontrollerV1alpha1, err = samplecontrollerv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.samplecontrollerV1alpha1 = samplecontrollerv1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 0000000..1a59e3d --- /dev/null +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,142 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + applyconfiguration "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration" + clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" + fakesamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + var opts metav1.ListOptions + if watchAction, ok := action.(testing.WatchActionImpl); ok { + opts = watchAction.ListOptions + } + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns, opts) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +// IsWatchListSemanticsUnSupported informs the reflector that this client +// doesn't support WatchList semantics. +// +// This is a synthetic method whose sole purpose is to satisfy the optional +// interface check performed by the reflector. +// Returning true signals that WatchList can NOT be used. +// No additional logic is implemented here. +func (c *Clientset) IsWatchListSemanticsUnSupported() bool { + return true +} + +// NewClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +// +// Compared to NewSimpleClientset, the Clientset returned here supports field tracking and thus +// server-side apply. Beware though that support in that for CRDs is missing +// (https://github.com/kubernetes/kubernetes/issues/126850). +func NewClientset(objects ...runtime.Object) *Clientset { + o := testing.NewFieldManagedObjectTracker( + scheme, + codecs.UniversalDecoder(), + applyconfiguration.NewTypeConverter(scheme), + ) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + var opts metav1.ListOptions + if watchAction, ok := action.(testing.WatchActionImpl); ok { + opts = watchAction.ListOptions + } + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns, opts) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +var ( + _ clientset.Interface = &Clientset{} + _ testing.FakeClient = &Clientset{} +) + +// SamplecontrollerV1alpha1 retrieves the SamplecontrollerV1alpha1Client +func (c *Clientset) SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface { + return &fakesamplecontrollerv1alpha1.FakeSamplecontrollerV1alpha1{Fake: &c.Fake} +} diff --git a/pkg/generated/clientset/versioned/fake/doc.go b/pkg/generated/clientset/versioned/fake/doc.go new file mode 100644 index 0000000..9b99e71 --- /dev/null +++ b/pkg/generated/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go new file mode 100644 index 0000000..4726554 --- /dev/null +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + samplecontrollerv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/pkg/generated/clientset/versioned/scheme/doc.go b/pkg/generated/clientset/versioned/scheme/doc.go new file mode 100644 index 0000000..7dc3756 --- /dev/null +++ b/pkg/generated/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go new file mode 100644 index 0000000..bcefc82 --- /dev/null +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + samplecontrollerv1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go new file mode 100644 index 0000000..df51baa --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/doc.go new file mode 100644 index 0000000..16f4439 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go new file mode 100644 index 0000000..ef2a943 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go @@ -0,0 +1,49 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/samplecontroller/v1alpha1" + typedsamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakeFoos implements FooInterface +type fakeFoos struct { + *gentype.FakeClientWithListAndApply[*v1alpha1.Foo, *v1alpha1.FooList, *samplecontrollerv1alpha1.FooApplyConfiguration] + Fake *FakeSamplecontrollerV1alpha1 +} + +func newFakeFoos(fake *FakeSamplecontrollerV1alpha1, namespace string) typedsamplecontrollerv1alpha1.FooInterface { + return &fakeFoos{ + gentype.NewFakeClientWithListAndApply[*v1alpha1.Foo, *v1alpha1.FooList, *samplecontrollerv1alpha1.FooApplyConfiguration]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("foos"), + v1alpha1.SchemeGroupVersion.WithKind("Foo"), + func() *v1alpha1.Foo { return &v1alpha1.Foo{} }, + func() *v1alpha1.FooList { return &v1alpha1.FooList{} }, + func(dst, src *v1alpha1.FooList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.FooList) []*v1alpha1.Foo { return gentype.ToPointerSlice(list.Items) }, + func(list *v1alpha1.FooList, items []*v1alpha1.Foo) { list.Items = gentype.FromPointerSlice(items) }, + ), + fake, + } +} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go new file mode 100644 index 0000000..a806837 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go @@ -0,0 +1,40 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeSamplecontrollerV1alpha1 struct { + *testing.Fake +} + +func (c *FakeSamplecontrollerV1alpha1) Foos(namespace string) v1alpha1.FooInterface { + return newFakeFoos(c, namespace) +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeSamplecontrollerV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go new file mode 100644 index 0000000..4abd819 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go @@ -0,0 +1,74 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + applyconfigurationsamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/samplecontroller/v1alpha1" + scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// FoosGetter has a method to return a FooInterface. +// A group's client should implement this interface. +type FoosGetter interface { + Foos(namespace string) FooInterface +} + +// FooInterface has methods to work with Foo resources. +type FooInterface interface { + Create(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.CreateOptions) (*samplecontrollerv1alpha1.Foo, error) + Update(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.UpdateOptions) (*samplecontrollerv1alpha1.Foo, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.UpdateOptions) (*samplecontrollerv1alpha1.Foo, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*samplecontrollerv1alpha1.Foo, error) + List(ctx context.Context, opts v1.ListOptions) (*samplecontrollerv1alpha1.FooList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *samplecontrollerv1alpha1.Foo, err error) + Apply(ctx context.Context, foo *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration, opts v1.ApplyOptions) (result *samplecontrollerv1alpha1.Foo, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, foo *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration, opts v1.ApplyOptions) (result *samplecontrollerv1alpha1.Foo, err error) + FooExpansion +} + +// foos implements FooInterface +type foos struct { + *gentype.ClientWithListAndApply[*samplecontrollerv1alpha1.Foo, *samplecontrollerv1alpha1.FooList, *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration] +} + +// newFoos returns a Foos +func newFoos(c *SamplecontrollerV1alpha1Client, namespace string) *foos { + return &foos{ + gentype.NewClientWithListAndApply[*samplecontrollerv1alpha1.Foo, *samplecontrollerv1alpha1.FooList, *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration]( + "foos", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *samplecontrollerv1alpha1.Foo { return &samplecontrollerv1alpha1.Foo{} }, + func() *samplecontrollerv1alpha1.FooList { return &samplecontrollerv1alpha1.FooList{} }, + ), + } +} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go new file mode 100644 index 0000000..b64ea02 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type FooExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go new file mode 100644 index 0000000..a3e621d --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go @@ -0,0 +1,101 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + http "net/http" + + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type SamplecontrollerV1alpha1Interface interface { + RESTClient() rest.Interface + FoosGetter +} + +// SamplecontrollerV1alpha1Client is used to interact with features provided by the samplecontroller.k8s.io group. +type SamplecontrollerV1alpha1Client struct { + restClient rest.Interface +} + +func (c *SamplecontrollerV1alpha1Client) Foos(namespace string) FooInterface { + return newFoos(c, namespace) +} + +// NewForConfig creates a new SamplecontrollerV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*SamplecontrollerV1alpha1Client, error) { + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new SamplecontrollerV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SamplecontrollerV1alpha1Client, error) { + config := *c + setConfigDefaults(&config) + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &SamplecontrollerV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new SamplecontrollerV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *SamplecontrollerV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new SamplecontrollerV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *SamplecontrollerV1alpha1Client { + return &SamplecontrollerV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) { + gv := samplecontrollerv1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *SamplecontrollerV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go new file mode 100644 index 0000000..6b1a26a --- /dev/null +++ b/pkg/generated/informers/externalversions/factory.go @@ -0,0 +1,333 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + context "context" + reflect "reflect" + sync "sync" + time "time" + + versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" + samplecontroller "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/samplecontroller" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + wait "k8s.io/apimachinery/pkg/util/wait" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + transform cache.TransformFunc + informerName *cache.InformerName + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// WithTransform sets a transform on all informers. +func WithTransform(transform cache.TransformFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.transform = transform + return factory + } +} + +// WithInformerName sets the InformerName for informer identity used in metrics. +// The InformerName must be created via cache.NewInformerName() at startup, +// which validates global uniqueness. Each informer type will register its +// GVR under this name. +func WithInformerName(informerName *cache.InformerName) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.informerName = informerName + return factory + } +} + +func (f *sharedInformerFactory) InformerName() *cache.InformerName { + return f.informerName +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.StartWithContext(wait.ContextForChannel(stopCh)) +} + +func (f *sharedInformerFactory) StartWithContext(ctx context.Context) { + f.lock.Lock() + defer f.lock.Unlock() + + if f.shuttingDown { + return + } + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + f.wg.Go(func() { + informer.RunWithContext(ctx) + }) + f.startedInformers[informerType] = true + } + } +} + +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() + f.informerName.Release() +} + +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + result := f.WaitForCacheSyncWithContext(wait.ContextForChannel(stopCh)) + return result.Synced +} + +func (f *sharedInformerFactory) WaitForCacheSyncWithContext(ctx context.Context) cache.SyncResult { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + // Wait for informers to sync, without polling. + cacheSyncs := make([]cache.DoneChecker, 0, len(informers)) + for _, informer := range informers { + cacheSyncs = append(cacheSyncs, informer.HasSyncedChecker()) + } + cache.WaitFor(ctx, "" /* no logging */, cacheSyncs...) + + res := cache.SyncResult{ + Synced: make(map[reflect.Type]bool, len(informers)), + } + failed := false + for informType, informer := range informers { + hasSynced := informer.HasSynced() + if !hasSynced { + failed = true + } + res.Synced[informType] = hasSynced + } + if failed { + // context.Cause is more informative than ctx.Err(). + // This must be non-nil, otherwise WaitFor wouldn't have stopped + // prematurely. + res.Err = context.Cause(ctx) + } + + return res +} + +// InformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + if f.transform != nil { + informer.SetTransform(f.transform) + } + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.WithCancel(context.Background()) +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.Shutdown() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// handle, err := typeInformer.Informer().AddEventHandler(...) +// if err != nil { +// return fmt.Errorf("register event handler: %v", err) +// } +// defer typeInformer.Informer().RemoveEventHandler(handle) // Avoids leaking goroutines. +// factory.StartWithContext(ctx) // Start processing these informers. +// synced := factory.WaitForCacheSyncWithContext(ctx) +// if err := synced.AsError(); err != nil { +// return err +// } +// for v := range synced { +// // Only if desired log some information similar to this. +// fmt.Fprintf(os.Stdout, "cache synced: %s", v) +// } +// +// // Also make sure that all of the initial cache events have been delivered. +// if !WaitFor(ctx, "event handler sync", handle.HasSyncedChecker()) { +// // Must have failed because of context. +// return fmt.Errorf("sync event handler: %w", context.Cause(ctx)) +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.StartWithContext(ctx) +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + // Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync. + // + // Contextual logging: StartWithContext should be used instead of Start in code which supports contextual logging. + Start(stopCh <-chan struct{}) + + // StartWithContext initializes all requested informers. They are handled in goroutines + // which run until the context gets canceled. + // Warning: StartWithContext does not block. When run in a go-routine, it will race with a later WaitForCacheSync. + StartWithContext(ctx context.Context) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. + // + // Contextual logging: WaitForCacheSync should be used instead of WaitForCacheSync in code which supports contextual logging. It also returns a more useful result. + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + // WaitForCacheSyncWithContext blocks until all started informers' caches were synced + // or the context gets canceled. + WaitForCacheSyncWithContext(ctx context.Context) cache.SyncResult + + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + + Samplecontroller() samplecontroller.Interface +} + +func (f *sharedInformerFactory) Samplecontroller() samplecontroller.Interface { + return samplecontroller.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go new file mode 100644 index 0000000..a8563be --- /dev/null +++ b/pkg/generated/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + fmt "fmt" + + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=samplecontroller.k8s.io, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("foos"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Samplecontroller().V1alpha1().Foos().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 0000000..0234003 --- /dev/null +++ b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,59 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer + InformerName() *cache.InformerName +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) + +// InformerOptions holds the options for creating an informer. +type InformerOptions struct { + // ResyncPeriod is the resync period for this informer. + // If not set, defaults to 0 (no resync). + ResyncPeriod time.Duration + + // Indexers are the indexers for this informer. + Indexers cache.Indexers + + // InformerName is used to uniquely identify this informer for metrics. + // If not set, metrics will not be published for this informer. + // Use cache.NewInformerName() to create an InformerName at startup. + InformerName *cache.InformerName + + // TweakListOptions is an optional function to modify the list options. + TweakListOptions TweakListOptionsFunc +} diff --git a/pkg/generated/informers/externalversions/samplecontroller/interface.go b/pkg/generated/informers/externalversions/samplecontroller/interface.go new file mode 100644 index 0000000..acd7c61 --- /dev/null +++ b/pkg/generated/informers/externalversions/samplecontroller/interface.go @@ -0,0 +1,46 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package samplecontroller + +import ( + internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/samplecontroller/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go new file mode 100644 index 0000000..cb7fa39 --- /dev/null +++ b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go @@ -0,0 +1,116 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + time "time" + + apissamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/samplecontroller/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// FooInformer provides access to a shared informer and lister for +// Foos. +type FooInformer interface { + Informer() cache.SharedIndexInformer + Lister() samplecontrollerv1alpha1.FooLister +} + +type fooInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewFooInformer constructs a new informer for Foo type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers}) +} + +// NewFilteredFooInformer constructs a new informer for Foo type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return NewFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions}) +} + +// NewFooInformerWithOptions constructs a new informer for Foo type with additional options. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFooInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { + gvr := schema.GroupVersionResource{Group: "samplecontroller.k8s.io", Version: "v1alpha1", Resource: "foos"} + identifier := options.InformerName.WithResource(gvr) + tweakListOptions := options.TweakListOptions + return cache.NewSharedIndexInformerWithOptions( + cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ + ListFunc: func(opts v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.Background(), opts) + }, + WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.Background(), opts) + }, + ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SamplecontrollerV1alpha1().Foos(namespace).List(ctx, opts) + }, + WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(ctx, opts) + }, + }, client), + &apissamplecontrollerv1alpha1.Foo{}, + cache.SharedIndexInformerOptions{ + ResyncPeriod: options.ResyncPeriod, + Indexers: options.Indexers, + Identifier: identifier, + }, + ) +} + +func (f *fooInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFooInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions}) +} + +func (f *fooInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apissamplecontrollerv1alpha1.Foo{}, f.defaultInformer) +} + +func (f *fooInformer) Lister() samplecontrollerv1alpha1.FooLister { + return samplecontrollerv1alpha1.NewFooLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go new file mode 100644 index 0000000..7fe2077 --- /dev/null +++ b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Foos returns a FooInformer. + Foos() FooInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Foos returns a FooInformer. +func (v *version) Foos() FooInformer { + return &fooInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go b/pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go new file mode 100644 index 0000000..9a34636 --- /dev/null +++ b/pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// FooListerExpansion allows custom methods to be added to +// FooLister. +type FooListerExpansion interface{} + +// FooNamespaceListerExpansion allows custom methods to be added to +// FooNamespaceLister. +type FooNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/samplecontroller/v1alpha1/foo.go b/pkg/generated/listers/samplecontroller/v1alpha1/foo.go new file mode 100644 index 0000000..b854564 --- /dev/null +++ b/pkg/generated/listers/samplecontroller/v1alpha1/foo.go @@ -0,0 +1,70 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// FooLister helps list Foos. +// All objects returned here must be treated as read-only. +type FooLister interface { + // List lists all Foos in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*samplecontrollerv1alpha1.Foo, err error) + // Foos returns an object that can list and get Foos. + Foos(namespace string) FooNamespaceLister + FooListerExpansion +} + +// fooLister implements the FooLister interface. +type fooLister struct { + listers.ResourceIndexer[*samplecontrollerv1alpha1.Foo] +} + +// NewFooLister returns a new FooLister. +func NewFooLister(indexer cache.Indexer) FooLister { + return &fooLister{listers.New[*samplecontrollerv1alpha1.Foo](indexer, samplecontrollerv1alpha1.Resource("foo"))} +} + +// Foos returns an object that can list and get Foos. +func (s *fooLister) Foos(namespace string) FooNamespaceLister { + return fooNamespaceLister{listers.NewNamespaced[*samplecontrollerv1alpha1.Foo](s.ResourceIndexer, namespace)} +} + +// FooNamespaceLister helps list and get Foos. +// All objects returned here must be treated as read-only. +type FooNamespaceLister interface { + // List lists all Foos in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*samplecontrollerv1alpha1.Foo, err error) + // Get retrieves the Foo from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*samplecontrollerv1alpha1.Foo, error) + FooNamespaceListerExpansion +} + +// fooNamespaceLister implements the FooNamespaceLister +// interface. +type fooNamespaceLister struct { + listers.ResourceIndexer[*samplecontrollerv1alpha1.Foo] +} diff --git a/pkg/generated/openapi/cmd/models-schema/main.go b/pkg/generated/openapi/cmd/models-schema/main.go new file mode 100644 index 0000000..f3e6b6e --- /dev/null +++ b/pkg/generated/openapi/cmd/models-schema/main.go @@ -0,0 +1,76 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "encoding/json" + "fmt" + "os" + + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/openapi" + "k8s.io/kube-openapi/pkg/common" + "k8s.io/kube-openapi/pkg/validation/spec" +) + +// Outputs openAPI schema JSON containing the schema definitions in zz_generated.openapi.go. +func main() { + err := output() + if err != nil { + fmt.Fprintf(os.Stderr, "Failed: %v", err) // nolint:errcheck + os.Exit(1) + } +} + +func output() error { + refFunc := func(name string) spec.Ref { + return spec.MustCreateRef(fmt.Sprintf("#/definitions/%s", name)) + } + defs := openapi.GetOpenAPIDefinitions(refFunc) + schemaDefs := make(map[string]spec.Schema, len(defs)) + for k, v := range defs { + // Replace top-level schema with v2 if a v2 schema is embedded + // so that the output of this program is always in OpenAPI v2. + // This is done by looking up an extension that marks the embedded v2 + // schema, and, if the v2 schema is found, make it the resulting schema for + // the type. + if schema, ok := v.Schema.Extensions[common.ExtensionV2Schema]; ok { + if v2Schema, isOpenAPISchema := schema.(spec.Schema); isOpenAPISchema { + schemaDefs[k] = v2Schema + continue + } + } + + schemaDefs[k] = v.Schema + } + data, err := json.Marshal(&spec.Swagger{ + SwaggerProps: spec.SwaggerProps{ + Definitions: schemaDefs, + Info: &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "Kubernetes", + Version: "unversioned", + }, + }, + Swagger: "2.0", + }, + }) + if err != nil { + return fmt.Errorf("error serializing api definitions: %w", err) + } + os.Stdout.Write(data) // nolint:errcheck + return nil +} diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go new file mode 100644 index 0000000..d825901 --- /dev/null +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -0,0 +1,2943 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by openapi-gen. DO NOT EDIT. + +package openapi + +import ( + resource "k8s.io/apimachinery/pkg/api/resource" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + version "k8s.io/apimachinery/pkg/version" + common "k8s.io/kube-openapi/pkg/common" + spec "k8s.io/kube-openapi/pkg/validation/spec" +) + +func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { + return map[string]common.OpenAPIDefinition{ + resource.Quantity{}.OpenAPIModelName(): schema_apimachinery_pkg_api_resource_Quantity(ref), + v1.APIGroup{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroup(ref), + v1.APIGroupList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroupList(ref), + v1.APIResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIResource(ref), + v1.APIResourceList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIResourceList(ref), + v1.APIVersions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIVersions(ref), + v1.ApplyOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ApplyOptions(ref), + v1.Condition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Condition(ref), + v1.CreateOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_CreateOptions(ref), + v1.DeleteOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_DeleteOptions(ref), + v1.Duration{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Duration(ref), + v1.FieldSelectorRequirement{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref), + v1.FieldsV1{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_FieldsV1(ref), + v1.GetOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GetOptions(ref), + v1.GroupKind{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupKind(ref), + v1.GroupResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupResource(ref), + v1.GroupVersion{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersion(ref), + v1.GroupVersionForDiscovery{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref), + v1.GroupVersionKind{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionKind(ref), + v1.GroupVersionResource{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_GroupVersionResource(ref), + v1.InternalEvent{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_InternalEvent(ref), + v1.LabelSelector{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_LabelSelector(ref), + v1.LabelSelectorRequirement{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref), + v1.List{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_List(ref), + v1.ListMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ListMeta(ref), + v1.ListOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ListOptions(ref), + v1.ManagedFieldsEntry{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref), + v1.MicroTime{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_MicroTime(ref), + v1.ObjectMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ObjectMeta(ref), + v1.OwnerReference{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_OwnerReference(ref), + v1.PartialObjectMetadata{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PartialObjectMetadata(ref), + v1.PartialObjectMetadataList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref), + v1.Patch{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Patch(ref), + v1.PatchOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_PatchOptions(ref), + v1.Preconditions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Preconditions(ref), + v1.RootPaths{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_RootPaths(ref), + v1.ServerAddressByClientCIDR{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref), + v1.ShardInfo{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_ShardInfo(ref), + v1.Status{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Status(ref), + v1.StatusCause{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_StatusCause(ref), + v1.StatusDetails{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_StatusDetails(ref), + v1.Table{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Table(ref), + v1.TableColumnDefinition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableColumnDefinition(ref), + v1.TableOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableOptions(ref), + v1.TableRow{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableRow(ref), + v1.TableRowCondition{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TableRowCondition(ref), + v1.Time{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Time(ref), + v1.Timestamp{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_Timestamp(ref), + v1.TypeMeta{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_TypeMeta(ref), + v1.UpdateOptions{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_UpdateOptions(ref), + v1.WatchEvent{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_WatchEvent(ref), + runtime.RawExtension{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref), + runtime.TypeMeta{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref), + runtime.Unknown{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_Unknown(ref), + version.Info{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_version_Info(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.Foo": schema_pkg_apis_samplecontroller_v1alpha1_Foo(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooList": schema_pkg_apis_samplecontroller_v1alpha1_FooList(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooSpec": schema_pkg_apis_samplecontroller_v1alpha1_FooSpec(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooStatus": schema_pkg_apis_samplecontroller_v1alpha1_FooStatus(ref), + } +} + +func schema_apimachinery_pkg_api_resource_Quantity(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.EmbedOpenAPIDefinitionIntoV2Extension(common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation.", + OneOf: common.GenerateOpenAPIV3OneOfSchema(resource.Quantity{}.OpenAPIV3OneOfTypes()), + Format: resource.Quantity{}.OpenAPISchemaFormat(), + }, + }, + }, common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Quantity is a fixed-point representation of a number. It provides convenient marshaling/unmarshaling in JSON and YAML, in addition to String() and AsInt64() accessors.\n\nThe serialization format is:\n\n``` ::= \n\n\t(Note that may be empty, from the \"\" case in .)\n\n ::= 0 | 1 | ... | 9 ::= | ::= | . | . | . ::= \"+\" | \"-\" ::= | ::= | | ::= Ki | Mi | Gi | Ti | Pi | Ei\n\n\t(International System of units; See: http://physics.nist.gov/cuu/Units/binary.html)\n\n ::= m | \"\" | k | M | G | T | P | E\n\n\t(Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.)\n\n ::= \"e\" | \"E\" ```\n\nNo matter which of the three exponent forms is used, no quantity may represent a number greater than 2^63-1 in magnitude, nor may it have more than 3 decimal places. Numbers larger or more precise will be capped or rounded up. (E.g.: 0.1m will rounded up to 1m.) This may be extended in the future if we require larger or smaller quantities.\n\nWhen a Quantity is parsed from a string, it will remember the type of suffix it had, and will use the same type again when it is serialized.\n\nBefore serializing, Quantity will be put in \"canonical form\". This means that Exponent/suffix will be adjusted up or down (with a corresponding increase or decrease in Mantissa) such that:\n\n- No precision is lost - No fractional digits will be emitted - The exponent (or suffix) is as large as possible.\n\nThe sign will be omitted unless the number is negative.\n\nExamples:\n\n- 1.5 will be serialized as \"1500m\" - 1.5Gi will be serialized as \"1536Mi\"\n\nNote that the quantity will NEVER be internally represented by a floating point number. That is the whole point of this exercise.\n\nNon-canonical values will still parse as long as they are well formed, but will be re-emitted in their canonical form. (So always use canonical form, or don't diff.)\n\nThis format is intended to make it difficult to use these numbers without writing some sort of special handling code in the hopes that that will cause implementors to also use a fixed point implementation.", + Type: resource.Quantity{}.OpenAPISchemaType(), + Format: resource.Quantity{}.OpenAPISchemaFormat(), + }, + }, + }) +} + +func schema_apimachinery_pkg_api_resource_int64Amount(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "int64Amount represents a fixed precision numerator and arbitrary scale exponent. It is faster than operations on inf.Dec for values that can be represented as int64.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "value": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "scale": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"value", "scale"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_APIGroup(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIGroup contains the name, the supported versions, and the preferred version of a group.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the name of the group.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "versions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "versions are the versions supported in this group.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.GroupVersionForDiscovery{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + "preferredVersion": { + SchemaProps: spec.SchemaProps{ + Description: "preferredVersion is the version preferred by the API server, which probably is the storage version.", + Default: map[string]interface{}{}, + Ref: ref(v1.GroupVersionForDiscovery{}.OpenAPIModelName()), + }, + }, + "serverAddressByClientCIDRs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ServerAddressByClientCIDR{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"name", "versions"}, + }, + }, + Dependencies: []string{ + v1.GroupVersionForDiscovery{}.OpenAPIModelName(), v1.ServerAddressByClientCIDR{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_APIGroupList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIGroupList is a list of APIGroup, to allow clients to discover the API at /apis.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "groups": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "groups is a list of APIGroup.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.APIGroup{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"groups"}, + }, + }, + Dependencies: []string{ + v1.APIGroup{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIResource specifies the name of a resource and whether it is namespaced.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is the plural name of the resource.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "singularName": { + SchemaProps: spec.SchemaProps{ + Description: "singularName is the singular name of the resource. This allows clients to handle plural and singular opaquely. The singularName is more correct for reporting status on a single item and both singular and plural are allowed from the kubectl CLI interface.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "namespaced": { + SchemaProps: spec.SchemaProps{ + Description: "namespaced indicates if a resource is namespaced or not.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "group": { + SchemaProps: spec.SchemaProps{ + Description: "group is the preferred group of the resource. Empty implies the group of the containing resource list. For subresources, this may have a different value, for example: Scale\".", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Description: "version is the preferred version of the resource. Empty implies the version of the containing resource list For subresources, this may have a different value, for example: v1 (while inside a v1beta1 version of the core resource's group)\".", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "verbs": { + SchemaProps: spec.SchemaProps{ + Description: "verbs is a list of supported kube verbs (this includes get, list, watch, create, update, patch, delete, deletecollection, and proxy)", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "shortNames": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "shortNames is a list of suggested short names of the resource.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "categories": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "categories is a list of the grouped resources this resource belongs to (e.g. 'all')", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "storageVersionHash": { + SchemaProps: spec.SchemaProps{ + Description: "The hash value of the storage version, the version this resource is converted to when written to the data store. Value must be treated as opaque by clients. Only equality comparison on the value is valid. This is an alpha feature and may change or be removed in the future. The field is populated by the apiserver only if the StorageVersionHash feature gate is enabled. This field will remain optional even if it graduates.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "singularName", "namespaced", "kind", "verbs"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_APIResourceList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIResourceList is a list of APIResource, it is used to expose the name of the resources supported in a specific group and version, and if the resource is namespaced.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "groupVersion": { + SchemaProps: spec.SchemaProps{ + Description: "groupVersion is the group and version this APIResourceList is for.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "resources": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "resources contains the name of the resources and if they are namespaced.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.APIResource{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"groupVersion", "resources"}, + }, + }, + Dependencies: []string{ + v1.APIResource{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_APIVersions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "APIVersions lists the versions that are available, to allow clients to discover the API at /api, which is the root path of the legacy v1 API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "versions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "versions are the api versions that are available.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "serverAddressByClientCIDRs": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "a map of client CIDR to server address that is serving this group. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR. The server returns only those CIDRs that it thinks that the client can match. For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP. Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ServerAddressByClientCIDR{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"versions", "serverAddressByClientCIDRs"}, + }, + }, + Dependencies: []string{ + v1.ServerAddressByClientCIDR{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_ApplyOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ApplyOptions may be provided when applying an API object. FieldManager is required for apply requests. ApplyOptions is equivalent to PatchOptions. It is provided as a convenience with documentation that speaks specifically to how the options fields relate to apply.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "force": { + SchemaProps: spec.SchemaProps{ + Description: "Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people.", + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"force", "fieldManager"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Condition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Condition contains details for one aspect of the current state of this API Resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type of condition in CamelCase or in foo.example.com/CamelCase.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "observedGeneration": { + SchemaProps: spec.SchemaProps{ + Description: "observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "lastTransitionTime": { + SchemaProps: spec.SchemaProps{ + Description: "lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.", + Ref: ref(v1.Time{}.OpenAPIModelName()), + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "message is a human readable message indicating details about the transition. This may be an empty string.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status", "lastTransitionTime", "reason", "message"}, + }, + }, + Dependencies: []string{ + v1.Time{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_CreateOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "CreateOptions may be provided when creating an API object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldValidation": { + SchemaProps: spec.SchemaProps{ + Description: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_DeleteOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "DeleteOptions may be provided when deleting an API object.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "gracePeriodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "preconditions": { + SchemaProps: spec.SchemaProps{ + Description: "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.", + Ref: ref(v1.Preconditions{}.OpenAPIModelName()), + }, + }, + "orphanDependents": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "propagationPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "ignoreStoreReadErrorWithClusterBreakingPotential": { + SchemaProps: spec.SchemaProps{ + Description: "if set to true, it will trigger an unsafe deletion of the resource in case the normal deletion flow fails with a corrupt object error. A resource is considered corrupt if it can not be retrieved from the underlying storage successfully because of a) its data can not be transformed e.g. decryption failure, or b) it fails to decode into an object. NOTE: unsafe deletion ignores finalizer constraints, skips precondition checks, and removes the object from the storage. WARNING: This may potentially break the cluster if the workload associated with the resource being unsafe-deleted relies on normal deletion flow. Use only if you REALLY know what you are doing. The default value is false, and the user must opt in to enable it", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.Preconditions{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_Duration(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Duration is a wrapper around time.Duration which supports correct marshaling to YAML and JSON. In particular, it marshals into strings, which can be used as map keys in json.", + Type: v1.Duration{}.OpenAPISchemaType(), + Format: v1.Duration{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FieldSelectorRequirement is a selector that contains values, a key, and an operator that relates the key and values.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "key is the field selector key that the requirement applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. The list of operators may grow in the future.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "operator"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_FieldsV1(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format.\n\nEach key is either a '.' representing the field itself, and will always map to an empty set, or a string representing a sub-field or item. The string will follow one of these four formats: 'f:', where is the name of a field in a struct, or key in a map 'v:', where is the exact json formatted value of a list item 'i:', where is position of a item in a list 'k:', where is a map of a list item's key fields to their unique values If a key maps to an empty Fields value, the field that key represents is part of the set.\n\nThe exact format is defined in sigs.k8s.io/structured-merge-diff", + Type: []string{"object"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GetOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GetOptions is the standard query options to the standard REST get call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupKind specifies a Group and a Kind, but does not force a version. This is useful for identifying concepts during lookup stages without having partially valid types", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "kind"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupResource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupResource specifies a Group and a Resource, but does not force a version. This is useful for identifying concepts during lookup stages without having partially valid types", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "resource"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersion(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersion contains the \"group\" and the \"version\", which uniquely identifies the API.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersion contains the \"group/version\" and \"version\" string of a version. It is made a struct to keep extensibility.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "groupVersion": { + SchemaProps: spec.SchemaProps{ + Description: "groupVersion specifies the API group and version in the form \"group/version\"", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Description: "version specifies the version in the form of \"version\". This is to save the clients the trouble of splitting the GroupVersion.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"groupVersion", "version"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersionKind(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersionKind unambiguously identifies a kind. It doesn't anonymously include GroupVersion to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version", "kind"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_GroupVersionResource(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "GroupVersionResource unambiguously identifies a resource. It doesn't anonymously include GroupVersion to avoid automatic coercion. It doesn't use a GroupVersion to avoid custom marshalling", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "group": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "resource": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"group", "version", "resource"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_InternalEvent(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "InternalEvent makes watch.Event versioned", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "Type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "Object": { + SchemaProps: spec.SchemaProps{ + Description: "Object is:\n * If Type is Added or Modified: the new state of the object.\n * If Type is Deleted: the state of the object immediately before deletion.\n * If Type is Bookmark: the object (instance of a type being watched) where\n only ResourceVersion field is set. On successful restart of watch from a\n bookmark resourceVersion, client is guaranteed to not get repeat event\n nor miss any events.\n * If Type is Error: *api.Status is recommended; other types may make sense\n depending on context.", + }, + }, + }, + Required: []string{"Type", "Object"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_LabelSelector(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "matchLabels": { + SchemaProps: spec.SchemaProps{ + Description: "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "matchExpressions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "matchExpressions is a list of label selector requirements. The requirements are ANDed.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.LabelSelectorRequirement{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + Dependencies: []string{ + v1.LabelSelectorRequirement{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "key": { + SchemaProps: spec.SchemaProps{ + Description: "key is the label key that the selector applies to.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "operator": { + SchemaProps: spec.SchemaProps{ + Description: "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "values": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"key", "operator"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_List(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "List holds a list of objects, which may not be known by the server.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref(v1.ListMeta{}.OpenAPIModelName()), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "List of objects", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref(runtime.RawExtension{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + v1.ListMeta{}.OpenAPIModelName(), runtime.RawExtension{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_ListMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ListMeta describes metadata that synthetic resources must have, including lists and various status objects. A resource may have only one of {ObjectMeta, ListMeta}.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "selfLink": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "String that identifies the server's internal version of this object that can be used by clients to determine when objects have changed. Value must be treated as opaque by clients and passed unmodified back to the server. Populated by the system. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency", + Type: []string{"string"}, + Format: "", + }, + }, + "continue": { + SchemaProps: spec.SchemaProps{ + Description: "continue may be set if the user set a limit on the number of items returned, and indicates that the server has more data available. The value is opaque and may be used to issue another request to the endpoint that served this list to retrieve the next set of available objects. Continuing a consistent list may not be possible if the server configuration has changed or more than a few minutes have passed. The resourceVersion field returned when using this continue value will be identical to the value in the first response, unless you have received this token from an error message.", + Type: []string{"string"}, + Format: "", + }, + }, + "remainingItemCount": { + SchemaProps: spec.SchemaProps{ + Description: "remainingItemCount is the number of subsequent items in the list which are not included in this list response. If the list request contained label or field selectors, then the number of remaining items is unknown and the field will be left unset and omitted during serialization. If the list is complete (either because it is not chunking or because this is the last chunk), then there are no more remaining items and this field will be left unset and omitted during serialization. Servers older than v1.15 do not set this field. The intended use of the remainingItemCount is *estimating* the size of a collection. Clients should not rely on the remainingItemCount to be set or to be exact.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "shardInfo": { + SchemaProps: spec.SchemaProps{ + Description: "shardInfo is set when the list is a filtered subset of the full collection, as selected by a shard selector on the request. It echoes back the selector so clients can verify which shard they received and merge sharded responses. Clients should not cache sharded list responses as a full representation of the collection.\n\nThis is an alpha field and requires enabling the ShardedListAndWatch feature gate.", + Ref: ref(v1.ShardInfo{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.ShardInfo{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_ListOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ListOptions is the query options to a standard REST list call.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "labelSelector": { + SchemaProps: spec.SchemaProps{ + Description: "A selector to restrict the list of returned objects by their labels. Defaults to everything.", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldSelector": { + SchemaProps: spec.SchemaProps{ + Description: "A selector to restrict the list of returned objects by their fields. Defaults to everything.", + Type: []string{"string"}, + Format: "", + }, + }, + "watch": { + SchemaProps: spec.SchemaProps{ + Description: "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "allowWatchBookmarks": { + SchemaProps: spec.SchemaProps{ + Description: "allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersionMatch": { + SchemaProps: spec.SchemaProps{ + Description: "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset", + Type: []string{"string"}, + Format: "", + }, + }, + "timeoutSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "limit": { + SchemaProps: spec.SchemaProps{ + Description: "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "continue": { + SchemaProps: spec.SchemaProps{ + Description: "The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.", + Type: []string{"string"}, + Format: "", + }, + }, + "sendInitialEvents": { + SchemaProps: spec.SchemaProps{ + Description: "`sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic \"Bookmark\" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `\"k8s.io/initial-events-end\": \"true\"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched.\n\nWhen `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan\n is interpreted as \"data at least as new as the provided `resourceVersion`\"\n and the bookmark event is send when the state is synced\n to a `resourceVersion` at least as fresh as the one provided by the ListOptions.\n If `resourceVersion` is unset, this is interpreted as \"consistent read\" and the\n bookmark event is send when the state is synced at least to the moment\n when request started being processed.\n- `resourceVersionMatch` set to any other value or unset\n Invalid error is returned.\n\nDefaults to true if `resourceVersion=\"\"` or `resourceVersion=\"0\"` (for backward compatibility reasons) and to false otherwise.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "shardSelector": { + SchemaProps: spec.SchemaProps{ + Description: "shardSelector restricts the list of returned objects using a CEL-based shard selector expression. The format uses the shardRange() function combined with || (logical OR) to specify one or more hash ranges:\n\n shardRange(object.metadata.uid, '0x0', '0x8000000000000000')\n shardRange(object.metadata.uid, '0x0', '0x8000000000000000') || shardRange(object.metadata.uid, '0x8000000000000000', '0x10000000000000000')\n\nField paths use CEL-style object-rooted syntax (e.g. \"object.metadata.uid\"), NOT the fieldSelector format (\"metadata.uid\"). Currently supported paths:\n - object.metadata.uid\n - object.metadata.namespace\n\nhexStart and hexEnd are single-quoted CEL string literals with a '0x' prefix, defining the inclusive lower and exclusive upper bounds over the 64-bit FNV-1a hash space. The full range is [0x0, 0x10000000000000000), where the exclusive upper bound equals 2^64.\n\nExamples:\n 2-shard split:\n shard 0: shardRange(object.metadata.uid, '0x0000000000000000', '0x8000000000000000')\n shard 1: shardRange(object.metadata.uid, '0x8000000000000000', '0x10000000000000000')\n 4-shard split:\n shard 0: shardRange(object.metadata.uid, '0x0000000000000000', '0x4000000000000000')\n shard 1: shardRange(object.metadata.uid, '0x4000000000000000', '0x8000000000000000')\n shard 2: shardRange(object.metadata.uid, '0x8000000000000000', '0xc000000000000000')\n shard 3: shardRange(object.metadata.uid, '0xc000000000000000', '0x10000000000000000')\n\nThis is an alpha field and requires enabling the ShardedListAndWatch feature gate.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "manager": { + SchemaProps: spec.SchemaProps{ + Description: "Manager is an identifier of the workflow managing these fields.", + Type: []string{"string"}, + Format: "", + }, + }, + "operation": { + SchemaProps: spec.SchemaProps{ + Description: "Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'.", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the version of this resource that this field set applies to. The format is \"group/version\" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted.", + Type: []string{"string"}, + Format: "", + }, + }, + "time": { + SchemaProps: spec.SchemaProps{ + Description: "Time is the timestamp of when the ManagedFields entry was added. The timestamp will also be updated if a field is added, the manager changes any of the owned fields value or removes a field. The timestamp does not update when a field is removed from the entry because another manager took it over.", + Ref: ref(v1.Time{}.OpenAPIModelName()), + }, + }, + "fieldsType": { + SchemaProps: spec.SchemaProps{ + Description: "FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: \"FieldsV1\"", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldsV1": { + SchemaProps: spec.SchemaProps{ + Description: "FieldsV1 holds the first JSON version format as described in the \"FieldsV1\" type.", + Ref: ref(v1.FieldsV1{}.OpenAPIModelName()), + }, + }, + "subresource": { + SchemaProps: spec.SchemaProps{ + Description: "Subresource is the name of the subresource used to update that object, or empty string if the object was updated through the main resource. The value of this field is used to distinguish between managers, even if they share the same name. For example, a status update will be distinct from a regular update using the same manager name. Note that the APIVersion field is not related to the Subresource field and it always corresponds to the version of the main resource.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.FieldsV1{}.OpenAPIModelName(), v1.Time{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_MicroTime(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "MicroTime is version of Time with microsecond level precision.", + Type: v1.MicroTime{}.OpenAPISchemaType(), + Format: v1.MicroTime{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names", + Type: []string{"string"}, + Format: "", + }, + }, + "generateName": { + SchemaProps: spec.SchemaProps{ + Description: "GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server.\n\nIf this field is specified and the generated name exists, the server will return a 409.\n\nApplied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency", + Type: []string{"string"}, + Format: "", + }, + }, + "namespace": { + SchemaProps: spec.SchemaProps{ + Description: "Namespace defines the space within which each name must be unique. An empty namespace is equivalent to the \"default\" namespace, but \"default\" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty.\n\nMust be a DNS_LABEL. Cannot be updated. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces", + Type: []string{"string"}, + Format: "", + }, + }, + "selfLink": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations.\n\nPopulated by the system. Read-only. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources.\n\nPopulated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency", + Type: []string{"string"}, + Format: "", + }, + }, + "generation": { + SchemaProps: spec.SchemaProps{ + Description: "A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "creationTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.\n\nPopulated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Ref: ref(v1.Time{}.OpenAPIModelName()), + }, + }, + "deletionTimestamp": { + SchemaProps: spec.SchemaProps{ + Description: "DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested.\n\nPopulated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Ref: ref(v1.Time{}.OpenAPIModelName()), + }, + }, + "deletionGracePeriodSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "labels": { + SchemaProps: spec.SchemaProps{ + Description: "Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "annotations": { + SchemaProps: spec.SchemaProps{ + Description: "Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "ownerReferences": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-map-keys": []interface{}{ + "uid", + }, + "x-kubernetes-list-type": "map", + "x-kubernetes-patch-merge-key": "uid", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.OwnerReference{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + "finalizers": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "set", + "x-kubernetes-patch-strategy": "merge", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "managedFields": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like \"ci-cd\". The set of fields is always in the version that the workflow used when modifying the object.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ManagedFieldsEntry{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.ManagedFieldsEntry{}.OpenAPIModelName(), v1.OwnerReference{}.OpenAPIModelName(), v1.Time{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_OwnerReference(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "API version of the referent.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "controller": { + SchemaProps: spec.SchemaProps{ + Description: "If true, this reference points to the managing controller.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "blockOwnerDeletion": { + SchemaProps: spec.SchemaProps{ + Description: "If true, AND if the owner has the \"foregroundDeletion\" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. See https://kubernetes.io/docs/concepts/architecture/garbage-collection/#foreground-deletion for how the garbage collector interacts with this field and enforces the foreground deletion. Defaults to false. To set this field, a user needs \"delete\" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + Required: []string{"apiVersion", "kind", "name", "uid"}, + }, + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_PartialObjectMetadata(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PartialObjectMetadata is a generic representation of any object with ObjectMeta. It allows clients to get access to a particular ObjectMeta schema without knowing the details of the version.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", + Default: map[string]interface{}{}, + Ref: ref(v1.ObjectMeta{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.ObjectMeta{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PartialObjectMetadataList contains a list of objects containing only their metadata", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref(v1.ListMeta{}.OpenAPIModelName()), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "items contains each of the included items.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.PartialObjectMetadata{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + v1.ListMeta{}.OpenAPIModelName(), v1.PartialObjectMetadata{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_Patch(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Patch is provided to give a concrete name and type to the Kubernetes PATCH request body.", + Type: []string{"object"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_PatchOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PatchOptions may be provided when patching an API object. PatchOptions is meant to be a superset of UpdateOptions.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "force": { + SchemaProps: spec.SchemaProps{ + Description: "Force is going to \"force\" Apply requests. It means user will re-acquire conflicting fields owned by other people. Force flag must be unset for non-apply patch requests.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint. This field is required for apply requests (application/apply-patch) but optional for non-apply patch types (JsonPatch, MergePatch, StrategicMergePatch).", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldValidation": { + SchemaProps: spec.SchemaProps{ + Description: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Preconditions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the target UID.", + Type: []string{"string"}, + Format: "", + }, + }, + "resourceVersion": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the target ResourceVersion", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_RootPaths(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RootPaths lists the paths available at root. For example: \"/healthz\", \"/apis\".", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "paths": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "paths are the paths available at root.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + Required: []string{"paths"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "clientCIDR": { + SchemaProps: spec.SchemaProps{ + Description: "The CIDR with which clients can match their IP to figure out the server address that they should use.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "serverAddress": { + SchemaProps: spec.SchemaProps{ + Description: "Address of this server, suitable for a client that matches the above CIDR. This can be a hostname, hostname:port, IP or IP:port.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"clientCIDR", "serverAddress"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_ShardInfo(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ShardInfo describes the shard selector that was applied to produce a list response. Its presence on a list response indicates the list is a filtered subset.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "selector": { + SchemaProps: spec.SchemaProps{ + Description: "selector is the shard selector string from the request, echoed back so clients can verify which shard they received and merge responses from multiple shards.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"selector"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Status(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Status is a return value for calls that don't return other objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref(v1.ListMeta{}.OpenAPIModelName()), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the operation. One of: \"Success\" or \"Failure\". More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human-readable description of the status of this operation.", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "A machine-readable description of why this operation is in the \"Failure\" status. If this value is empty there is no information available. A Reason clarifies an HTTP status code but does not override it.", + Type: []string{"string"}, + Format: "", + }, + }, + "details": { + SchemaProps: spec.SchemaProps{ + Description: "Extended data associated with the reason. Each reason may define its own extended details. This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.", + Ref: ref(v1.StatusDetails{}.OpenAPIModelName()), + }, + }, + "code": { + SchemaProps: spec.SchemaProps{ + Description: "Suggested HTTP return code for this status, 0 if not set.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.ListMeta{}.OpenAPIModelName(), v1.StatusDetails{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_StatusCause(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "StatusCause provides more information about an api.Status failure, including cases when multiple errors are encountered.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "A machine-readable description of the cause of the error. If this value is empty there is no information available.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "A human-readable description of the cause of the error. This field may be presented as-is to a reader.", + Type: []string{"string"}, + Format: "", + }, + }, + "field": { + SchemaProps: spec.SchemaProps{ + Description: "The field of the resource that has caused this error, as named by its JSON serialization. May include dot and postfix notation for nested attributes. Arrays are zero-indexed. Fields may appear more than once in an array of causes due to fields having multiple errors. Optional.\n\nExamples:\n \"name\" - the field \"name\" on the current resource\n \"items[0].name\" - the field \"name\" on the first array entry in \"items\"", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_StatusDetails(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "StatusDetails is a set of additional properties that MAY be set by the server to provide additional information about a response. The Reason field of a Status object defines what attributes will be set. Clients must ignore fields that do not match the defined type of each attribute, and should assume that any attribute may be empty, invalid, or under defined.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described).", + Type: []string{"string"}, + Format: "", + }, + }, + "group": { + SchemaProps: spec.SchemaProps{ + Description: "The group attribute of the resource associated with the status StatusReason.", + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "The kind attribute of the resource associated with the status StatusReason. On some operations may differ from the requested resource Kind. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "uid": { + SchemaProps: spec.SchemaProps{ + Description: "UID of the resource. (when there is a single resource which can be described). More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids", + Type: []string{"string"}, + Format: "", + }, + }, + "causes": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "The Causes array includes more details associated with the StatusReason failure. Not all StatusReasons may provide detailed causes.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.StatusCause{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + "retryAfterSeconds": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the time in seconds before the operation should be retried. Some errors may indicate the client must take an alternate action - for those errors this field may indicate how long to wait before taking the alternate action.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + }, + }, + Dependencies: []string{ + v1.StatusCause{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_Table(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Table is a tabular representation of a set of API resources. The server transforms the object into a set of preferred columns for quickly reviewing the objects.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Description: "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Default: map[string]interface{}{}, + Ref: ref(v1.ListMeta{}.OpenAPIModelName()), + }, + }, + "columnDefinitions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "columnDefinitions describes each column in the returned items array. The number of cells per row will always match the number of column definitions.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.TableColumnDefinition{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + "rows": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "rows is the list of items in the table.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.TableRow{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + }, + Required: []string{"columnDefinitions", "rows"}, + }, + }, + Dependencies: []string{ + v1.ListMeta{}.OpenAPIModelName(), v1.TableColumnDefinition{}.OpenAPIModelName(), v1.TableRow{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_TableColumnDefinition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableColumnDefinition contains information about a column returned in the Table.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "name is a human readable name for the column.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "type is an OpenAPI type definition for this column, such as number, integer, string, or array. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "format": { + SchemaProps: spec.SchemaProps{ + Description: "format is an optional OpenAPI type modifier for this column. A format modifies the type and imposes additional rules, like date or time formatting for a string. The 'name' format is applied to the primary identifier column which has type 'string' to assist in clients identifying column is the resource name. See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#data-types for more.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "description": { + SchemaProps: spec.SchemaProps{ + Description: "description is a human readable description of this column.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "priority": { + SchemaProps: spec.SchemaProps{ + Description: "priority is an integer defining the relative importance of this column compared to others. Lower numbers are considered higher priority. Columns that may be omitted in limited space scenarios should be given a higher priority.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"name", "type", "format", "description", "priority"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_TableOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableOptions are used when a Table is requested by the caller.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "includeObject": { + SchemaProps: spec.SchemaProps{ + Description: "includeObject decides whether to include each object along with its columnar information. Specifying \"None\" will return no object, specifying \"Object\" will return the full object contents, and specifying \"Metadata\" (the default) will return the object's metadata in the PartialObjectMetadata kind in version v1beta1 of the meta.k8s.io API group.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_TableRow(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableRow is an individual row in a table.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "cells": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "cells will be as wide as the column definitions array and may contain strings, numbers (float64 or int64), booleans, simple maps, lists, or null. See the type field of the column definition for a more detailed description.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Format: "", + }, + }, + }, + }, + }, + "conditions": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "conditions describe additional status of a row that are relevant for a human user. These conditions apply to the row, not to the object, and will be specific to table output. The only defined condition type is 'Completed', for a row that indicates a resource that has run to completion and can be given less visual priority.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.TableRowCondition{}.OpenAPIModelName()), + }, + }, + }, + }, + }, + "object": { + SchemaProps: spec.SchemaProps{ + Description: "This field contains the requested additional information about each object based on the includeObject policy when requesting the Table. If \"None\", this field is empty, if \"Object\" this will be the default serialization of the object for the current API version, and if \"Metadata\" (the default) will contain the object metadata. Check the returned kind and apiVersion of the object before parsing. The media type of the object will always match the enclosing list - if this as a JSON table, these will be JSON encoded objects.", + Ref: ref(runtime.RawExtension{}.OpenAPIModelName()), + }, + }, + }, + Required: []string{"cells"}, + }, + }, + Dependencies: []string{ + v1.TableRowCondition{}.OpenAPIModelName(), runtime.RawExtension{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_meta_v1_TableRowCondition(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TableRowCondition allows a row to be marked with additional information.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Type of row condition. The only defined value is 'Completed' indicating that the object this row represents has reached a completed state and may be given less visual priority than other rows. Clients are not required to honor any conditions but should be consistent where possible about handling the conditions.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Description: "Status of the condition, one of True, False, Unknown.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "reason": { + SchemaProps: spec.SchemaProps{ + Description: "(brief) machine readable reason for the condition's last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + "message": { + SchemaProps: spec.SchemaProps{ + Description: "Human readable message indicating details about last transition.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"type", "status"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Time(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.", + Type: v1.Time{}.OpenAPISchemaType(), + Format: v1.Time{}.OpenAPISchemaFormat(), + }, + }, + } +} + +func schema_pkg_apis_meta_v1_Timestamp(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Timestamp is a struct that is equivalent to Time, but intended for protobuf marshalling/unmarshalling. It is generated into a serialization that matches Time. Do not use in Go structs.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "seconds": { + SchemaProps: spec.SchemaProps{ + Description: "Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.", + Default: 0, + Type: []string{"integer"}, + Format: "int64", + }, + }, + "nanos": { + SchemaProps: spec.SchemaProps{ + Description: "Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive. This field may be limited in precision depending on context.", + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"seconds", "nanos"}, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_TypeMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TypeMeta describes an individual object in an API response or request with strings representing the type of the object and its API schema version. Structures that are versioned or persisted should inline TypeMeta.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_UpdateOptions(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "UpdateOptions may be provided when updating an API object. All fields in UpdateOptions should also be present in PatchOptions.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "dryRun": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-list-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "fieldManager": { + SchemaProps: spec.SchemaProps{ + Description: "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + Type: []string{"string"}, + Format: "", + }, + }, + "fieldValidation": { + SchemaProps: spec.SchemaProps{ + Description: "fieldValidation instructs the server on how to handle objects in the request (POST/PUT/PATCH) containing unknown or duplicate fields. Valid values are: - Ignore: This will ignore any unknown fields that are silently dropped from the object, and will ignore all but the last duplicate field that the decoder encounters. This is the default behavior prior to v1.23. - Warn: This will send a warning via the standard warning response header for each unknown field that is dropped from the object, and for each duplicate field that is encountered. The request will still succeed if there are no other errors, and will only persist the last of any duplicate fields. This is the default in v1.23+ - Strict: This will fail the request with a BadRequest error if any unknown fields would be dropped from the object, or if any duplicate fields are present. The error returned from the server will contain all unknown and duplicate fields encountered.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_pkg_apis_meta_v1_WatchEvent(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Event represents a single event to a watched resource.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "type": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "object": { + SchemaProps: spec.SchemaProps{ + Description: "Object is:\n * If Type is Added or Modified: the new state of the object.\n * If Type is Deleted: the state of the object immediately before deletion.\n * If Type is Error: *Status is recommended; other types may make sense\n depending on context.", + Ref: ref(runtime.RawExtension{}.OpenAPIModelName()), + }, + }, + }, + Required: []string{"type", "object"}, + }, + }, + Dependencies: []string{ + runtime.RawExtension{}.OpenAPIModelName()}, + } +} + +func schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.Object `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// External package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// On the wire, the JSON will look something like this:\n\n\t{\n\t\t\"kind\":\"MyAPIObject\",\n\t\t\"apiVersion\":\"v1\",\n\t\t\"myPlugin\": {\n\t\t\t\"kind\":\"PluginA\",\n\t\t\t\"aOption\":\"foo\",\n\t\t},\n\t}\n\nSo what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)", + Type: []string{"object"}, + }, + }, + } +} + +func schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, like this:\n\n\ttype MyAwesomeAPIObject struct {\n\t runtime.TypeMeta `json:\",inline\"`\n\t ... // other fields\n\t}\n\nfunc (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind\n\nTypeMeta is provided here for convenience. You may use it directly from this package or define your own with the same fields.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + } +} + +func schema_k8sio_apimachinery_pkg_runtime_Unknown(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Unknown allows api objects with unknown types to be passed-through. This can be used to deal with the API objects from a plug-in. Unknown objects still have functioning TypeMeta features-- kind, version, etc. metadata and field mutatation.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "kind": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "ContentEncoding": { + SchemaProps: spec.SchemaProps{ + Description: "ContentEncoding is encoding used to encode 'Raw' data. Unspecified means no encoding.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "ContentType": { + SchemaProps: spec.SchemaProps{ + Description: "ContentType is serialization method used to serialize 'Raw'. Unspecified means ContentTypeJSON.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"ContentEncoding", "ContentType"}, + }, + }, + } +} + +func schema_k8sio_apimachinery_pkg_version_Info(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Info contains versioning information. how we'll want to distribute that information.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "major": { + SchemaProps: spec.SchemaProps{ + Description: "Major is the major version of the binary version", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "minor": { + SchemaProps: spec.SchemaProps{ + Description: "Minor is the minor version of the binary version", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "emulationMajor": { + SchemaProps: spec.SchemaProps{ + Description: "EmulationMajor is the major version of the emulation version", + Type: []string{"string"}, + Format: "", + }, + }, + "emulationMinor": { + SchemaProps: spec.SchemaProps{ + Description: "EmulationMinor is the minor version of the emulation version", + Type: []string{"string"}, + Format: "", + }, + }, + "minCompatibilityMajor": { + SchemaProps: spec.SchemaProps{ + Description: "MinCompatibilityMajor is the major version of the minimum compatibility version", + Type: []string{"string"}, + Format: "", + }, + }, + "minCompatibilityMinor": { + SchemaProps: spec.SchemaProps{ + Description: "MinCompatibilityMinor is the minor version of the minimum compatibility version", + Type: []string{"string"}, + Format: "", + }, + }, + "gitVersion": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "gitCommit": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "gitTreeState": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "buildDate": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "goVersion": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "compiler": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "platform": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"major", "minor", "gitVersion", "gitCommit", "gitTreeState", "buildDate", "goVersion", "compiler", "platform"}, + }, + }, + } +} + +func schema_pkg_apis_samplecontroller_v1alpha1_Foo(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "Foo is a specification for a Foo resource", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ObjectMeta{}.OpenAPIModelName()), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooStatus"), + }, + }, + }, + Required: []string{"spec", "status"}, + }, + }, + Dependencies: []string{ + v1.ObjectMeta{}.OpenAPIModelName(), "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooSpec", "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooStatus"}, + } +} + +func schema_pkg_apis_samplecontroller_v1alpha1_FooList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FooList is a list of Foo resources", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ListMeta{}.OpenAPIModelName()), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.Foo"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + v1.ListMeta{}.OpenAPIModelName(), "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.Foo"}, + } +} + +func schema_pkg_apis_samplecontroller_v1alpha1_FooSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FooSpec is the spec for a Foo resource", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "deploymentName": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "replicas": { + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"deploymentName", "replicas"}, + }, + }, + } +} + +func schema_pkg_apis_samplecontroller_v1alpha1_FooStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "FooStatus is the status for a Foo resource", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "availableReplicas": { + SchemaProps: spec.SchemaProps{ + Default: 0, + Type: []string{"integer"}, + Format: "int32", + }, + }, + }, + Required: []string{"availableReplicas"}, + }, + }, + } +} diff --git a/pkg/signals/signal.go b/pkg/signals/signal.go new file mode 100644 index 0000000..2a5b462 --- /dev/null +++ b/pkg/signals/signal.go @@ -0,0 +1,44 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package signals + +import ( + "context" + "os" + "os/signal" +) + +var onlyOneSignalHandler = make(chan struct{}) + +// SetupSignalHandler registered for SIGTERM and SIGINT. A context is returned +// which is cancelled on one of these signals. If a second signal is caught, +// the program is terminated with exit code 1. +func SetupSignalHandler() context.Context { + close(onlyOneSignalHandler) // panics when called twice + + c := make(chan os.Signal, 2) + ctx, cancel := context.WithCancel(context.Background()) + signal.Notify(c, shutdownSignals...) + go func() { + <-c + cancel() + <-c + os.Exit(1) // second signal. Exit directly. + }() + + return ctx +} diff --git a/pkg/signals/signal_posix.go b/pkg/signals/signal_posix.go new file mode 100644 index 0000000..2b24faa --- /dev/null +++ b/pkg/signals/signal_posix.go @@ -0,0 +1,26 @@ +//go:build !windows + +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package signals + +import ( + "os" + "syscall" +) + +var shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} diff --git a/pkg/signals/signal_windows.go b/pkg/signals/signal_windows.go new file mode 100644 index 0000000..4907d57 --- /dev/null +++ b/pkg/signals/signal_windows.go @@ -0,0 +1,23 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package signals + +import ( + "os" +) + +var shutdownSignals = []os.Signal{os.Interrupt} -- 2.52.0 From 93fd4e89d5016df800b1a5986ccfdc3b15683363 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Thu, 14 May 2026 18:55:57 +0200 Subject: [PATCH 02/14] minimum runnable --- .gitignore | 2 +- .gitmodules | 3 + Makefile | 6 +- .../examples/crd-status-subresource.yaml | 41 -- artifacts/examples/crd.yaml | 38 +- controller.go | 298 ++---------- controller_test.go | 316 ------------- go.mod | 10 +- go.sum | 7 + .../codegen_violation_exceptions.list | 18 + hack/boilerplate.go.txt | 16 - hack/tools.go | 22 - hack/update-codegen.sh | 59 --- hack/verify-codegen.sh | 57 --- main.go | 10 +- .../v1alpha1 => proxyprovider/v1}/doc.go | 6 +- .../v1alpha1 => proxyprovider/v1}/types.go | 28 +- .../v1}/zz_generated.deepcopy.go | 47 +- .../v1}/zz_generated.register.go | 16 +- .../applyconfiguration/internal/internal.go | 10 - .../v1/proxyprovider.go} | 122 ++--- .../proxyprovider/v1/proxyproviderspec.go | 66 +++ .../proxyprovider/v1/proxyproviderstatus.go | 39 ++ .../samplecontroller/v1alpha1/foospec.go | 50 -- .../samplecontroller/v1alpha1/foostatus.go | 41 -- pkg/generated/applyconfiguration/utils.go | 18 +- .../clientset/versioned/clientset.go | 16 +- .../versioned/fake/clientset_generated.go | 10 +- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../v1alpha1 => proxyprovider/v1}/doc.go | 2 +- .../v1alpha1 => proxyprovider/v1}/fake/doc.go | 0 .../v1/fake/fake_proxyprovider.go | 51 +++ .../v1/fake/fake_proxyprovider_client.go} | 10 +- .../v1}/generated_expansion.go | 4 +- .../typed/proxyprovider/v1/proxyprovider.go | 74 +++ .../v1/proxyprovider_client.go} | 40 +- .../v1alpha1/fake/fake_foo.go | 49 -- .../typed/samplecontroller/v1alpha1/foo.go | 74 --- .../informers/externalversions/factory.go | 8 +- .../informers/externalversions/generic.go | 8 +- .../interface.go | 14 +- .../v1}/interface.go | 12 +- .../proxyprovider/v1/proxyprovider.go | 116 +++++ .../samplecontroller/v1alpha1/foo.go | 116 ----- .../v1}/expansion_generated.go | 14 +- .../listers/proxyprovider/v1/proxyprovider.go | 70 +++ .../listers/samplecontroller/v1alpha1/foo.go | 70 --- .../openapi/cmd/models-schema/main.go | 76 --- pkg/generated/openapi/zz_generated.openapi.go | 431 +++++++++--------- pkg/signals/signal_windows.go | 23 - scripts/codegen.sh | 50 ++ 52 files changed, 948 insertions(+), 1744 deletions(-) create mode 100644 .gitmodules delete mode 100644 artifacts/examples/crd-status-subresource.yaml delete mode 100644 controller_test.go create mode 100644 hack/api-violations/codegen_violation_exceptions.list delete mode 100644 hack/boilerplate.go.txt delete mode 100644 hack/tools.go delete mode 100755 hack/update-codegen.sh delete mode 100755 hack/verify-codegen.sh rename pkg/apis/{samplecontroller/v1alpha1 => proxyprovider/v1}/doc.go (84%) rename pkg/apis/{samplecontroller/v1alpha1 => proxyprovider/v1}/types.go (65%) rename pkg/apis/{samplecontroller/v1alpha1 => proxyprovider/v1}/zz_generated.deepcopy.go (71%) rename pkg/apis/{samplecontroller/v1alpha1 => proxyprovider/v1}/zz_generated.register.go (88%) rename pkg/generated/applyconfiguration/{samplecontroller/v1alpha1/foo.go => proxyprovider/v1/proxyprovider.go} (61%) create mode 100644 pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go create mode 100644 pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go delete mode 100644 pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go delete mode 100644 pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go rename pkg/generated/clientset/versioned/typed/{samplecontroller/v1alpha1 => proxyprovider/v1}/doc.go (97%) rename pkg/generated/clientset/versioned/typed/{samplecontroller/v1alpha1 => proxyprovider/v1}/fake/doc.go (100%) create mode 100644 pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go rename pkg/generated/clientset/versioned/typed/{samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go => proxyprovider/v1/fake/fake_proxyprovider_client.go} (70%) rename pkg/generated/clientset/versioned/typed/{samplecontroller/v1alpha1 => proxyprovider/v1}/generated_expansion.go (92%) create mode 100644 pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go rename pkg/generated/clientset/versioned/typed/{samplecontroller/v1alpha1/samplecontroller_client.go => proxyprovider/v1/proxyprovider_client.go} (59%) delete mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go delete mode 100644 pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go rename pkg/generated/informers/externalversions/{samplecontroller => proxyprovider}/interface.go (75%) rename pkg/generated/informers/externalversions/{samplecontroller/v1alpha1 => proxyprovider/v1}/interface.go (79%) create mode 100644 pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go delete mode 100644 pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go rename pkg/generated/listers/{samplecontroller/v1alpha1 => proxyprovider/v1}/expansion_generated.go (66%) create mode 100644 pkg/generated/listers/proxyprovider/v1/proxyprovider.go delete mode 100644 pkg/generated/listers/samplecontroller/v1alpha1/foo.go delete mode 100644 pkg/generated/openapi/cmd/models-schema/main.go delete mode 100644 pkg/signals/signal_windows.go create mode 100755 scripts/codegen.sh diff --git a/.gitignore b/.gitignore index 5b90e79..eb38878 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ go.work.sum # env file .env - +vendor/* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a7b679c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "code-generator"] + path = code-generator + url = https://github.com/kubernetes/code-generator.git diff --git a/Makefile b/Makefile index 728f6bc..f9cac0a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +REPO_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + +.PHONY: build run codegen + build: go build @@ -6,4 +10,4 @@ run: ./main codegen: - ./hack/update-codegen.sh + $(REPO_ROOT)/scripts/codegen.sh diff --git a/artifacts/examples/crd-status-subresource.yaml b/artifacts/examples/crd-status-subresource.yaml deleted file mode 100644 index 90b70d1..0000000 --- a/artifacts/examples/crd-status-subresource.yaml +++ /dev/null @@ -1,41 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: foos.samplecontroller.k8s.io - # for more information on the below annotation, please see - # https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2337-k8s.io-group-protection/README.md - annotations: - "api-approved.kubernetes.io": "unapproved, experimental-only; please get an approval from Kubernetes API reviewers if you're trying to develop a CRD in the *.k8s.io or *.kubernetes.io groups" -spec: - group: samplecontroller.k8s.io - versions: - - name: v1alpha1 - served: true - storage: true - schema: - # schema used for validation - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - deploymentName: - type: string - replicas: - type: integer - minimum: 1 - maximum: 10 - status: - type: object - properties: - availableReplicas: - type: integer - # subresources for the custom resource - subresources: - # enables the status subresource - status: {} - names: - kind: Foo - plural: foos - scope: Namespaced diff --git a/artifacts/examples/crd.yaml b/artifacts/examples/crd.yaml index 8ac6e60..e492835 100644 --- a/artifacts/examples/crd.yaml +++ b/artifacts/examples/crd.yaml @@ -1,37 +1,41 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: foos.samplecontroller.k8s.io - # for more information on the below annotation, please see - # https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2337-k8s.io-group-protection/README.md - annotations: - "api-approved.kubernetes.io": "unapproved, experimental-only; please get an approval from Kubernetes API reviewers if you're trying to develop a CRD in the *.k8s.io or *.kubernetes.io groups" + name: proxyproviders.proxyprovider.t000-n.de spec: - group: samplecontroller.k8s.io + group: proxyprovider.t000-n.de versions: - - name: v1alpha1 + - name: v1 served: true storage: true schema: - # schema used for validation openAPIV3Schema: type: object properties: spec: type: object properties: - deploymentName: + name: type: string - replicas: - type: integer - minimum: 1 - maximum: 10 + authorization_flow: + type: string + invalidation_flow: + type: string + external_host: + type: string + required: + - name + - authorization_flow + - invalidation_flow + - external_host status: type: object properties: - availableReplicas: - type: integer + pk: + type: string + required: + - pk names: - kind: Foo - plural: foos + kind: ProxyProvider + plural: proxyproviders scope: Namespaced diff --git a/controller.go b/controller.go index 5553509..908fd98 100644 --- a/controller.go +++ b/controller.go @@ -39,68 +39,45 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" - samplev1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" - samplescheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" - informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/samplecontroller/v1alpha1" - listers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/samplecontroller/v1alpha1" + operatorscheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" + informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1" + listers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1" ) -const controllerAgentName = "sample-controller" +const controllerAgentName = "proxy-provider-controller" const ( - // SuccessSynced is used as part of the Event 'reason' when a Foo is synced - SuccessSynced = "Synced" - // ErrResourceExists is used as part of the Event 'reason' when a Foo fails - // to sync due to a Deployment of the same name already existing. - ErrResourceExists = "ErrResourceExists" - - // MessageResourceExists is the message used for Events when a resource - // fails to sync due to a Deployment already existing - MessageResourceExists = "Resource %q already exists and is not managed by Foo" - // MessageResourceSynced is the message used for an Event fired when a Foo - // is synced successfully - MessageResourceSynced = "Foo synced successfully" - // FieldManager distinguishes this controller from other things writing to API objects - FieldManager = controllerAgentName + SuccessSynced = "Synced" + ErrResourceExists = "ErrResourceExists" + MessageResourceExists = "Resource %q already exists and is not managed by ProxyProvider" + MessageResourceSynced = "ProxyProvider synced successfully" + FieldManager = controllerAgentName ) -// Controller is the controller implementation for Foo resources type Controller struct { - // kubeclientset is a standard kubernetes clientset - kubeclientset kubernetes.Interface - // sampleclientset is a clientset for our own API group - sampleclientset clientset.Interface + kubeclientset kubernetes.Interface + operatorclientset clientset.Interface deploymentsLister appslisters.DeploymentLister deploymentsSynced cache.InformerSynced - foosLister listers.FooLister - foosSynced cache.InformerSynced + proxyLister listers.ProxyProviderLister + proxySynced cache.InformerSynced - // workqueue is a rate limited work queue. This is used to queue work to be - // processed instead of performing it as soon as a change happens. This - // means we can ensure we only process a fixed amount of resources at a - // time, and makes it easy to ensure we are never processing the same item - // simultaneously in two different workers. workqueue workqueue.TypedRateLimitingInterface[cache.ObjectName] - // recorder is an event recorder for recording Event resources to the - // Kubernetes API. - recorder record.EventRecorder + recorder record.EventRecorder } -// NewController returns a new sample controller func NewController( ctx context.Context, kubeclientset kubernetes.Interface, - sampleclientset clientset.Interface, + operatorclientset clientset.Interface, deploymentInformer appsinformers.DeploymentInformer, - fooInformer informers.FooInformer) *Controller { + proxyInformer informers.ProxyProviderInformer, +) *Controller { logger := klog.FromContext(ctx) - // Create event broadcaster - // Add sample-controller types to the default Kubernetes Scheme so Events can be - // logged for sample-controller types. - utilruntime.Must(samplescheme.AddToScheme(scheme.Scheme)) + utilruntime.Must(operatorscheme.AddToScheme(scheme.Scheme)) logger.V(4).Info("Creating event broadcaster") eventBroadcaster := record.NewBroadcaster(record.WithContext(ctx)) @@ -112,70 +89,53 @@ func NewController( &workqueue.TypedBucketRateLimiter[cache.ObjectName]{Limiter: rate.NewLimiter(rate.Limit(50), 300)}, ) - controller := &Controller{ + c := &Controller{ kubeclientset: kubeclientset, - sampleclientset: sampleclientset, + operatorclientset: operatorclientset, deploymentsLister: deploymentInformer.Lister(), deploymentsSynced: deploymentInformer.Informer().HasSynced, - foosLister: fooInformer.Lister(), - foosSynced: fooInformer.Informer().HasSynced, + proxyLister: proxyInformer.Lister(), + proxySynced: proxyInformer.Informer().HasSynced, workqueue: workqueue.NewTypedRateLimitingQueue(ratelimiter), recorder: recorder, } logger.Info("Setting up event handlers") - // Set up an event handler for when Foo resources change - fooInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: controller.enqueueFoo, - UpdateFunc: func(old, new interface{}) { - controller.enqueueFoo(new) + proxyInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ + AddFunc: c.enqueueProxyProvider, + UpdateFunc: func(_, newObj interface{}) { + c.enqueueProxyProvider(newObj) }, }) - // Set up an event handler for when Deployment resources change. This - // handler will lookup the owner of the given Deployment, and if it is - // owned by a Foo resource then the handler will enqueue that Foo resource for - // processing. This way, we don't need to implement custom logic for - // handling Deployment resources. More info on this pattern: - // https://github.com/kubernetes/community/blob/8cafef897a22026d42f5e5bb3f104febe7e29830/contributors/devel/controllers.md deploymentInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: controller.handleObject, + AddFunc: c.handleObject, UpdateFunc: func(old, new interface{}) { newDepl := new.(*appsv1.Deployment) oldDepl := old.(*appsv1.Deployment) if newDepl.ResourceVersion == oldDepl.ResourceVersion { - // Periodic resync will send update events for all known Deployments. - // Two different versions of the same Deployment will always have different RVs. return } - controller.handleObject(new) + c.handleObject(new) }, - DeleteFunc: controller.handleObject, + DeleteFunc: c.handleObject, }) - return controller + return c } -// Run will set up the event handlers for types we are interested in, as well -// as syncing informer caches and starting workers. It will block until stopCh -// is closed, at which point it will shutdown the workqueue and wait for -// workers to finish processing their current work items. func (c *Controller) Run(ctx context.Context, workers int) error { defer utilruntime.HandleCrash() defer c.workqueue.ShutDown() logger := klog.FromContext(ctx) - // Start the informer factories to begin populating the informer caches - logger.Info("Starting Foo controller") + logger.Info("Starting ProxyProvider controller") - // Wait for the caches to be synced before starting workers logger.Info("Waiting for informer caches to sync") - - if ok := cache.WaitForCacheSync(ctx.Done(), c.deploymentsSynced, c.foosSynced); !ok { + if ok := cache.WaitForCacheSync(ctx.Done(), c.deploymentsSynced, c.proxySynced); !ok { return fmt.Errorf("failed to wait for caches to sync") } logger.Info("Starting workers", "count", workers) - // Launch two workers to process Foo resources for i := 0; i < workers; i++ { go wait.UntilWithContext(ctx, c.runWorker, time.Second) } @@ -183,239 +143,71 @@ func (c *Controller) Run(ctx context.Context, workers int) error { logger.Info("Started workers") <-ctx.Done() logger.Info("Shutting down workers") - return nil } -// runWorker is a long-running function that will continually call the -// processNextWorkItem function in order to read and process a message on the -// workqueue. func (c *Controller) runWorker(ctx context.Context) { for c.processNextWorkItem(ctx) { } } -// processNextWorkItem will read a single work item off the workqueue and -// attempt to process it, by calling the syncHandler. func (c *Controller) processNextWorkItem(ctx context.Context) bool { objRef, shutdown := c.workqueue.Get() logger := klog.FromContext(ctx) - if shutdown { return false } - - // We call Done at the end of this func so the workqueue knows we have - // finished processing this item. We also must remember to call Forget - // if we do not want this work item being re-queued. For example, we do - // not call Forget if a transient error occurs, instead the item is - // put back on the workqueue and attempted again after a back-off - // period. defer c.workqueue.Done(objRef) - // Run the syncHandler, passing it the structured reference to the object to be synced. err := c.syncHandler(ctx, objRef) if err == nil { - // If no error occurs then we Forget this item so it does not - // get queued again until another change happens. c.workqueue.Forget(objRef) logger.Info("Successfully synced", "objectName", objRef) return true } - // there was a failure so be sure to report it. This method allows for - // pluggable error handling which can be used for things like - // cluster-monitoring. utilruntime.HandleErrorWithContext(ctx, err, "Error syncing; requeuing for later retry", "objectReference", objRef) - // since we failed, we should requeue the item to work on later. This - // method will add a backoff to avoid hotlooping on particular items - // (they're probably still not going to work right away) and overall - // controller protection (everything I've done is broken, this controller - // needs to calm down or it can starve other useful work) cases. c.workqueue.AddRateLimited(objRef) return true } -// syncHandler compares the actual state with the desired, and attempts to -// converge the two. It then updates the Status block of the Foo resource -// with the current status of the resource. func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName) error { logger := klog.LoggerWithValues(klog.FromContext(ctx), "objectRef", objectRef) - // Get the Foo resource with this namespace/name - foo, err := c.foosLister.Foos(objectRef.Namespace).Get(objectRef.Name) + pp, err := c.proxyLister.ProxyProviders(objectRef.Namespace).Get(objectRef.Name) if err != nil { - // The Foo resource may no longer exist, in which case we stop - // processing. if errors.IsNotFound(err) { - utilruntime.HandleErrorWithContext(ctx, err, "Foo referenced by item in work queue no longer exists", "objectReference", objectRef) + logger.V(4).Info("ProxyProvider no longer exists") return nil } - return err } - deploymentName := foo.Spec.DeploymentName - if deploymentName == "" { - // We choose to absorb the error here as the worker would requeue the - // resource otherwise. Instead, the next time the resource is updated - // the resource will be queued again. - utilruntime.HandleErrorWithContext(ctx, nil, "Deployment name missing from object reference", "objectReference", objectRef) - return nil - } - - // Get the deployment with the name specified in Foo.spec - deployment, err := c.deploymentsLister.Deployments(foo.Namespace).Get(deploymentName) - // If the resource doesn't exist, we'll create it - if errors.IsNotFound(err) { - deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Create(ctx, newDeployment(foo), metav1.CreateOptions{FieldManager: FieldManager}) - } - - // If an error occurs during Get/Create, we'll requeue the item so we can - // attempt processing again later. This could have been caused by a - // temporary network failure, or any other transient reason. - if err != nil { - return err - } - - // If the Deployment is not controlled by this Foo resource, we should log - // a warning to the event recorder and return error msg. - if !metav1.IsControlledBy(deployment, foo) { - msg := fmt.Sprintf(MessageResourceExists, deployment.Name) - c.recorder.Event(foo, corev1.EventTypeWarning, ErrResourceExists, msg) - return fmt.Errorf("%s", msg) - } - - // If this number of the replicas on the Foo resource is specified, and the - // number does not equal the current desired replicas on the Deployment, we - // should update the Deployment resource. - if foo.Spec.Replicas != nil && *foo.Spec.Replicas != *deployment.Spec.Replicas { - logger.V(4).Info("Update deployment resource", "currentReplicas", *deployment.Spec.Replicas, "desiredReplicas", *foo.Spec.Replicas) - deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Update(ctx, newDeployment(foo), metav1.UpdateOptions{FieldManager: FieldManager}) - } - - // If an error occurs during Update, we'll requeue the item so we can - // attempt processing again later. This could have been caused by a - // temporary network failure, or any other transient reason. - if err != nil { - return err - } - - // Finally, we update the status block of the Foo resource to reflect the - // current state of the world - err = c.updateFooStatus(ctx, foo, deployment) - if err != nil { - return err - } - - c.recorder.Event(foo, corev1.EventTypeNormal, SuccessSynced, MessageResourceSynced) + logger.V(4).Info("sync ProxyProvider", "name", pp.Name) return nil } -func (c *Controller) updateFooStatus(ctx context.Context, foo *samplev1alpha1.Foo, deployment *appsv1.Deployment) error { - // NEVER modify objects from the store. It's a read-only, local cache. - // You can use DeepCopy() to make a deep copy of original object and modify this copy - // Or create a copy manually for better performance - fooCopy := foo.DeepCopy() - fooCopy.Status.AvailableReplicas = deployment.Status.AvailableReplicas - // If the CustomResourceSubresources feature gate is not enabled, - // we must use Update instead of UpdateStatus to update the Status block of the Foo resource. - // UpdateStatus will not allow changes to the Spec of the resource, - // which is ideal for ensuring nothing other than resource status has been updated. - _, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).UpdateStatus(ctx, fooCopy, metav1.UpdateOptions{FieldManager: FieldManager}) - return err -} - -// enqueueFoo takes a Foo resource and converts it into a namespace/name -// string which is then put onto the work queue. This method should *not* be -// passed resources of any type other than Foo. -func (c *Controller) enqueueFoo(obj interface{}) { - if objectRef, err := cache.ObjectToName(obj); err != nil { +func (c *Controller) enqueueProxyProvider(obj interface{}) { + objectRef, err := cache.ObjectToName(obj) + if err != nil { utilruntime.HandleError(err) return - } else { - c.workqueue.Add(objectRef) } + c.workqueue.Add(objectRef) } -// handleObject will take any resource implementing metav1.Object and attempt -// to find the Foo resource that 'owns' it. It does this by looking at the -// objects metadata.ownerReferences field for an appropriate OwnerReference. -// It then enqueues that Foo resource to be processed. If the object does not -// have an appropriate OwnerReference, it will simply be skipped. func (c *Controller) handleObject(obj interface{}) { - var object metav1.Object - var ok bool - logger := klog.FromContext(context.Background()) - if object, ok = obj.(metav1.Object); !ok { + // Optional: resolve Deployment owners back to ProxyProvider and enqueue. + _, ok := obj.(metav1.Object) + if !ok { tombstone, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { - // If the object value is not too big and does not contain sensitive information then - // it may be useful to include it. - utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object, invalid type", "type", fmt.Sprintf("%T", obj)) + utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj)) return } - object, ok = tombstone.Obj.(metav1.Object) + _, ok = tombstone.Obj.(metav1.Object) if !ok { - // If the object value is not too big and does not contain sensitive information then - // it may be useful to include it. - utilruntime.HandleErrorWithContext(context.Background(), nil, "Error decoding object tombstone, invalid type", "type", fmt.Sprintf("%T", tombstone.Obj)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a metav1.Object %#v", obj)) return } - logger.V(4).Info("Recovered deleted object", "resourceName", object.GetName()) - } - logger.V(4).Info("Processing object", "object", klog.KObj(object)) - if ownerRef := metav1.GetControllerOf(object); ownerRef != nil { - // If this object is not owned by a Foo, we should not do anything more - // with it. - if ownerRef.Kind != "Foo" { - return - } - - foo, err := c.foosLister.Foos(object.GetNamespace()).Get(ownerRef.Name) - if err != nil { - logger.V(4).Info("Ignore orphaned object", "object", klog.KObj(object), "foo", ownerRef.Name) - return - } - - c.enqueueFoo(foo) - return - } -} - -// newDeployment creates a new Deployment for a Foo resource. It also sets -// the appropriate OwnerReferences on the resource so handleObject can discover -// the Foo resource that 'owns' it. -func newDeployment(foo *samplev1alpha1.Foo) *appsv1.Deployment { - labels := map[string]string{ - "app": "nginx", - "controller": foo.Name, - } - return &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: foo.Spec.DeploymentName, - Namespace: foo.Namespace, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")), - }, - }, - Spec: appsv1.DeploymentSpec{ - Replicas: foo.Spec.Replicas, - Selector: &metav1.LabelSelector{ - MatchLabels: labels, - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: labels, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: "nginx", - Image: "nginx:latest", - }, - }, - }, - }, - }, } } diff --git a/controller_test.go b/controller_test.go deleted file mode 100644 index 5ae6321..0000000 --- a/controller_test.go +++ /dev/null @@ -1,316 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "context" - "fmt" - "reflect" - "testing" - "time" - - apps "k8s.io/api/apps/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/diff" - kubeinformers "k8s.io/client-go/informers" - k8sfake "k8s.io/client-go/kubernetes/fake" - core "k8s.io/client-go/testing" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/tools/record" - "k8s.io/klog/v2/ktesting" - "k8s.io/utils/ptr" - - samplecontroller "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/fake" - informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions" -) - -var ( - alwaysReady = func() bool { return true } - noResyncPeriodFunc = func() time.Duration { return 0 } -) - -type fixture struct { - t *testing.T - - client *fake.Clientset - kubeclient *k8sfake.Clientset - // Objects to put in the store. - fooLister []*samplecontroller.Foo - deploymentLister []*apps.Deployment - // Actions expected to happen on the client. - kubeactions []core.Action - actions []core.Action - // Objects from here preloaded into NewSimpleFake. - kubeobjects []runtime.Object - objects []runtime.Object -} - -func newFixture(t *testing.T) *fixture { - f := &fixture{} - f.t = t - f.objects = []runtime.Object{} - f.kubeobjects = []runtime.Object{} - return f -} - -func newFoo(name string, replicas *int32) *samplecontroller.Foo { - return &samplecontroller.Foo{ - TypeMeta: metav1.TypeMeta{APIVersion: samplecontroller.SchemeGroupVersion.String()}, - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: metav1.NamespaceDefault, - }, - Spec: samplecontroller.FooSpec{ - DeploymentName: fmt.Sprintf("%s-deployment", name), - Replicas: replicas, - }, - } -} - -func (f *fixture) newController(ctx context.Context) (*Controller, informers.SharedInformerFactory, kubeinformers.SharedInformerFactory) { - f.client = fake.NewClientset(f.objects...) - f.kubeclient = k8sfake.NewClientset(f.kubeobjects...) - - i := informers.NewSharedInformerFactory(f.client, noResyncPeriodFunc()) - k8sI := kubeinformers.NewSharedInformerFactory(f.kubeclient, noResyncPeriodFunc()) - - c := NewController(ctx, f.kubeclient, f.client, - k8sI.Apps().V1().Deployments(), i.Samplecontroller().V1alpha1().Foos()) - - c.foosSynced = alwaysReady - c.deploymentsSynced = alwaysReady - c.recorder = &record.FakeRecorder{} - - for _, f := range f.fooLister { - i.Samplecontroller().V1alpha1().Foos().Informer().GetIndexer().Add(f) - } - - for _, d := range f.deploymentLister { - k8sI.Apps().V1().Deployments().Informer().GetIndexer().Add(d) - } - - return c, i, k8sI -} - -func (f *fixture) run(ctx context.Context, fooRef cache.ObjectName) { - f.runController(ctx, fooRef, true, false) -} - -func (f *fixture) runExpectError(ctx context.Context, fooRef cache.ObjectName) { - f.runController(ctx, fooRef, true, true) -} - -func (f *fixture) runController(ctx context.Context, fooRef cache.ObjectName, startInformers bool, expectError bool) { - c, i, k8sI := f.newController(ctx) - if startInformers { - i.Start(ctx.Done()) - k8sI.Start(ctx.Done()) - } - - err := c.syncHandler(ctx, fooRef) - if !expectError && err != nil { - f.t.Errorf("error syncing foo: %v", err) - } else if expectError && err == nil { - f.t.Error("expected error syncing foo, got nil") - } - - actions := filterInformerActions(f.client.Actions()) - for i, action := range actions { - if len(f.actions) < i+1 { - f.t.Errorf("%d unexpected actions: %+v", len(actions)-len(f.actions), actions[i:]) - break - } - - expectedAction := f.actions[i] - checkAction(expectedAction, action, f.t) - } - - if len(f.actions) > len(actions) { - f.t.Errorf("%d additional expected actions:%+v", len(f.actions)-len(actions), f.actions[len(actions):]) - } - - k8sActions := filterInformerActions(f.kubeclient.Actions()) - for i, action := range k8sActions { - if len(f.kubeactions) < i+1 { - f.t.Errorf("%d unexpected actions: %+v", len(k8sActions)-len(f.kubeactions), k8sActions[i:]) - break - } - - expectedAction := f.kubeactions[i] - checkAction(expectedAction, action, f.t) - } - - if len(f.kubeactions) > len(k8sActions) { - f.t.Errorf("%d additional expected actions:%+v", len(f.kubeactions)-len(k8sActions), f.kubeactions[len(k8sActions):]) - } -} - -// checkAction verifies that expected and actual actions are equal and both have -// same attached resources -func checkAction(expected, actual core.Action, t *testing.T) { - if !(expected.Matches(actual.GetVerb(), actual.GetResource().Resource) && actual.GetSubresource() == expected.GetSubresource()) { - t.Errorf("Expected\n\t%#v\ngot\n\t%#v", expected, actual) - return - } - - if reflect.TypeOf(actual) != reflect.TypeOf(expected) { - t.Errorf("Action has wrong type. Expected: %t. Got: %t", expected, actual) - return - } - - switch a := actual.(type) { - case core.CreateActionImpl: - e, _ := expected.(core.CreateActionImpl) - expObject := e.GetObject() - object := a.GetObject() - - if !reflect.DeepEqual(expObject, object) { - t.Errorf("Action %s %s has wrong object\nDiff:\n %s", - a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object)) - } - case core.UpdateActionImpl: - e, _ := expected.(core.UpdateActionImpl) - expObject := e.GetObject() - object := a.GetObject() - - if !reflect.DeepEqual(expObject, object) { - t.Errorf("Action %s %s has wrong object\nDiff:\n %s", - a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expObject, object)) - } - case core.PatchActionImpl: - e, _ := expected.(core.PatchActionImpl) - expPatch := e.GetPatch() - patch := a.GetPatch() - - if !reflect.DeepEqual(expPatch, patch) { - t.Errorf("Action %s %s has wrong patch\nDiff:\n %s", - a.GetVerb(), a.GetResource().Resource, diff.ObjectGoPrintSideBySide(expPatch, patch)) - } - default: - t.Errorf("Uncaptured Action %s %s, you should explicitly add a case to capture it", - actual.GetVerb(), actual.GetResource().Resource) - } -} - -// filterInformerActions filters list and watch actions for testing resources. -// Since list and watch don't change resource state we can filter it to lower -// nose level in our tests. -func filterInformerActions(actions []core.Action) []core.Action { - ret := []core.Action{} - for _, action := range actions { - if len(action.GetNamespace()) == 0 && - (action.Matches("list", "foos") || - action.Matches("watch", "foos") || - action.Matches("list", "deployments") || - action.Matches("watch", "deployments")) { - continue - } - ret = append(ret, action) - } - - return ret -} - -func (f *fixture) expectCreateDeploymentAction(d *apps.Deployment) { - f.kubeactions = append(f.kubeactions, core.NewCreateAction(schema.GroupVersionResource{Resource: "deployments"}, d.Namespace, d)) -} - -func (f *fixture) expectUpdateDeploymentAction(d *apps.Deployment) { - f.kubeactions = append(f.kubeactions, core.NewUpdateAction(schema.GroupVersionResource{Resource: "deployments"}, d.Namespace, d)) -} - -func (f *fixture) expectUpdateFooStatusAction(foo *samplecontroller.Foo) { - action := core.NewUpdateSubresourceAction(schema.GroupVersionResource{Resource: "foos"}, "status", foo.Namespace, foo) - f.actions = append(f.actions, action) -} - -func getRef(foo *samplecontroller.Foo, t *testing.T) cache.ObjectName { - ref := cache.MetaObjectToName(foo) - return ref -} - -func TestCreatesDeployment(t *testing.T) { - f := newFixture(t) - foo := newFoo("test", ptr.To[int32](1)) - _, ctx := ktesting.NewTestContext(t) - - f.fooLister = append(f.fooLister, foo) - f.objects = append(f.objects, foo) - - expDeployment := newDeployment(foo) - f.expectCreateDeploymentAction(expDeployment) - f.expectUpdateFooStatusAction(foo) - - f.run(ctx, getRef(foo, t)) -} - -func TestDoNothing(t *testing.T) { - f := newFixture(t) - foo := newFoo("test", ptr.To[int32](1)) - _, ctx := ktesting.NewTestContext(t) - - d := newDeployment(foo) - - f.fooLister = append(f.fooLister, foo) - f.objects = append(f.objects, foo) - f.deploymentLister = append(f.deploymentLister, d) - f.kubeobjects = append(f.kubeobjects, d) - - f.expectUpdateFooStatusAction(foo) - f.run(ctx, getRef(foo, t)) -} - -func TestUpdateDeployment(t *testing.T) { - f := newFixture(t) - foo := newFoo("test", ptr.To[int32](1)) - _, ctx := ktesting.NewTestContext(t) - - d := newDeployment(foo) - - // Update replicas - foo.Spec.Replicas = ptr.To[int32](2) - expDeployment := newDeployment(foo) - - f.fooLister = append(f.fooLister, foo) - f.objects = append(f.objects, foo) - f.deploymentLister = append(f.deploymentLister, d) - f.kubeobjects = append(f.kubeobjects, d) - - f.expectUpdateFooStatusAction(foo) - f.expectUpdateDeploymentAction(expDeployment) - f.run(ctx, getRef(foo, t)) -} - -func TestNotControlledByUs(t *testing.T) { - f := newFixture(t) - foo := newFoo("test", ptr.To[int32](1)) - _, ctx := ktesting.NewTestContext(t) - - d := newDeployment(foo) - - d.ObjectMeta.OwnerReferences = []metav1.OwnerReference{} - - f.fooLister = append(f.fooLister, foo) - f.objects = append(f.objects, foo) - f.deploymentLister = append(f.deploymentLister, d) - f.kubeobjects = append(f.kubeobjects, d) - - f.runExpectError(ctx, getRef(foo, t)) -} diff --git a/go.mod b/go.mod index 0e5e94b..43b39a9 100644 --- a/go.mod +++ b/go.mod @@ -7,13 +7,13 @@ godebug default=go1.26 require ( golang.org/x/time v0.15.0 k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec - k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5 + k8s.io/apimachinery v0.0.0-20260513183604-f9371b815e42 k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940 k8s.io/code-generator v0.0.0-20260509210052-5595d1310975 k8s.io/klog/v2 v2.140.0 - k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b + k8s.io/kube-openapi v0.0.0-20260511211612-da4e56fe5676 k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 - sigs.k8s.io/structured-merge-diff/v6 v6.3.2 + sigs.k8s.io/structured-merge-diff/v6 v6.4.0 ) require ( @@ -57,8 +57,10 @@ require ( google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - k8s.io/gengo/v2 v2.0.0-20250922181213-ec3ebc5fd46b // indirect + k8s.io/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/yaml v1.6.0 // indirect ) + +replace k8s.io/code-generator => ./code-generator diff --git a/go.sum b/go.sum index fd8673a..24b1ea4 100644 --- a/go.sum +++ b/go.sum @@ -121,16 +121,21 @@ k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec h1:xf12Yh3ltN4fnNyP0CyyM0TwNVnZDfL k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec/go.mod h1:C+fcNlNQ9TcKHspN+DD7UybdfnjDAGyBjfCd6W7ogbY= k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5 h1:k2HBxRBq6w2QCj14oAhBosjMqqgNlj4dmLXFj8f1A+8= k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5/go.mod h1:37ALVDWo0LgW74Y9rAdewmZo20SVCGGH34806wUMrko= +k8s.io/apimachinery v0.0.0-20260513183604-f9371b815e42 h1:rWdGOTor3z0WSyZcRl9ms4dn9Cw9CqmNBqXuf2z0k1k= +k8s.io/apimachinery v0.0.0-20260513183604-f9371b815e42/go.mod h1:hiubQ6UTHIdr0bS8ExXOJEywFVOoudnldm/l/NiNVlA= k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940 h1:n5t5Jx3VpLdiAGxIvIHsZDmsExtZVwghUPLM3wFi6Go= k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940/go.mod h1:0e7OLwg7kdXISVFwn7ishFdvxfVgi7wsqHqsQPHl61w= k8s.io/code-generator v0.0.0-20260509210052-5595d1310975 h1:hDrusFgTzvqcDJ7p13A9Eid4i8Y9uNSs/67lniaYHwM= k8s.io/code-generator v0.0.0-20260509210052-5595d1310975/go.mod h1:mQXg0n0EeF4oU8aTwm9mzwoyAKqVRmUb9wLhjHnRq3I= 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/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3/go.mod h1:yvyl3l9E+UxlqOMUULdKTAYB0rEhsmjr7+2Vb/1pCSo= k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b h1:WrpNVPKkCaOO9h77E1P2HLnhWDQxrxzpf2jfsM8WevY= k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b/go.mod h1:V/QaCUYDa+0QpcHhVVc5l99Uz56wEMEXBSj9oCDkNDY= +k8s.io/kube-openapi v0.0.0-20260511211612-da4e56fe5676 h1:ahjrVu/DBcaAhw/GcblfaOvvQ2wi8kqXWvn62nud3UU= +k8s.io/kube-openapi v0.0.0-20260511211612-da4e56fe5676/go.mod h1:V/QaCUYDa+0QpcHhVVc5l99Uz56wEMEXBSj9oCDkNDY= k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 h1:AZYQSJemyQB5eRxqcPky+/7EdBj0xi3g0ZcxxJ7vbWU= k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= @@ -139,5 +144,7 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= sigs.k8s.io/structured-merge-diff/v6 v6.3.2 h1:kwVWMx5yS1CrnFWA/2QHyRVJ8jM6dBA80uLmm0wJkk8= sigs.k8s.io/structured-merge-diff/v6 v6.3.2/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/structured-merge-diff/v6 v6.4.0 h1:qmp2e3ZfFi1/jJbDGpD4mt3wyp6PE1NfKHCYLqgNQJo= +sigs.k8s.io/structured-merge-diff/v6 v6.4.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/hack/api-violations/codegen_violation_exceptions.list b/hack/api-violations/codegen_violation_exceptions.list new file mode 100644 index 0000000..249ee25 --- /dev/null +++ b/hack/api-violations/codegen_violation_exceptions.list @@ -0,0 +1,18 @@ +API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1,ProxyProviderSpec,AuthorizationFlow +API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1,ProxyProviderSpec,ExternalHost +API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1,ProxyProviderSpec,InvalidationFlow +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,Format +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,d +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,i +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,s +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,int64Amount,scale +API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,int64Amount,value +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,APIResourceList,APIResources +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Duration +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Type +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,MicroTime,Time +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,StatusCause,Type +API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Time,Time +API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentEncoding +API rule violation: names_match,k8s.io/apimachinery/pkg/runtime,Unknown,ContentType diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt deleted file mode 100644 index b7c650d..0000000 --- a/hack/boilerplate.go.txt +++ /dev/null @@ -1,16 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - diff --git a/hack/tools.go b/hack/tools.go deleted file mode 100644 index 3e2ab98..0000000 --- a/hack/tools.go +++ /dev/null @@ -1,22 +0,0 @@ -//go:build tools - -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This package imports things required by build scripts, to force `go mod` to see them as dependencies -package tools - -import _ "k8s.io/code-generator" diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh deleted file mode 100755 index 31d9dae..0000000 --- a/hack/update-codegen.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. -CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} - -source "${CODEGEN_PKG}/kube_codegen.sh" - -THIS_PKG="gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator" - -kube::codegen::gen_helpers \ - --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ - "${SCRIPT_ROOT}/pkg/apis" - -if [[ -n "${API_KNOWN_VIOLATIONS_DIR:-}" ]]; then - report_filename="${API_KNOWN_VIOLATIONS_DIR}/sample_controller_violation_exceptions.list" - if [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then - update_report="--update-report" - fi -fi - -kube::codegen::gen_openapi \ - --output-dir "${SCRIPT_ROOT}/pkg/generated/openapi" \ - --output-pkg "k8s.io/${THIS_PKG}/pkg/generated/openapi" \ - --report-filename "${report_filename:-"/dev/null"}" \ - --output-model-name-file "zz_generated.model_name.go" \ - ${update_report:+"${update_report}"} \ - --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ - "${SCRIPT_ROOT}/pkg/apis" - -kube::codegen::gen_client \ - --with-watch \ - --with-applyconfig \ - --applyconfig-openapi-schema <(go run gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/openapi/cmd/models-schema) \ - --output-dir "${SCRIPT_ROOT}/pkg/generated" \ - --output-pkg "${THIS_PKG}/pkg/generated" \ - --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ - "${SCRIPT_ROOT}/pkg/apis" - -kube::codegen::gen_register \ - --boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \ - "${SCRIPT_ROOT}/pkg/apis" diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh deleted file mode 100755 index 0af433f..0000000 --- a/hack/verify-codegen.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2017 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" -DIFFROOT="${SCRIPT_ROOT}/pkg" -TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")/pkg" - -cleanup() { - rm -rf "${TMP_DIFFROOT}" -} -trap "cleanup" EXIT SIGINT - -cleanup - -# Ensure model-schema generator matches the version from -# k8s.io/kubernetes/pkg/generated/openapi/cmd/models-schema/main.go -echo "Ensuring models-schema is up-to-date" -K8S_MODELS_SCHEMA="${SCRIPT_ROOT}/../../../../pkg/generated/openapi/cmd/models-schema/main.go" -SAMPLE_CONTROLLER_MODELS_SCHEMA="${SCRIPT_ROOT}/pkg/generated/openapi/cmd/models-schema/main.go" -# these two files will only differ in the imported lines for generated openapi -if ! diff -I "k8s.io/kubernetes/pkg/generated/openapi" \ - -I "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/openapi" \ - "${K8S_MODELS_SCHEMA}" "${SAMPLE_CONTROLLER_MODELS_SCHEMA}"; then - echo "${SAMPLE_CONTROLLER_MODELS_SCHEMA} is out of date. Compare changes with ${K8S_MODELS_SCHEMA}" - exit 1 -fi - -mkdir -p "${TMP_DIFFROOT}" -cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" - -"${SCRIPT_ROOT}/hack/update-codegen.sh" -echo "diffing ${DIFFROOT} against freshly generated codegen" -ret=0 -diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? -if [[ $ret -eq 0 ]]; then - echo "${DIFFROOT} up to date." -else - echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh" -fi -exit $ret diff --git a/main.go b/main.go index fac31a3..58e139e 100644 --- a/main.go +++ b/main.go @@ -58,23 +58,23 @@ func main() { klog.FlushAndExit(klog.ExitFlushTimeout, 1) } - exampleClient, err := clientset.NewForConfig(cfg) + operatorClient, err := clientset.NewForConfig(cfg) if err != nil { logger.Error(err, "Error building kubernetes clientset") klog.FlushAndExit(klog.ExitFlushTimeout, 1) } kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30) - exampleInformerFactory := informers.NewSharedInformerFactory(exampleClient, time.Second*30) + operatorInformerFactory := informers.NewSharedInformerFactory(operatorClient, time.Second*30) - controller := NewController(ctx, kubeClient, exampleClient, + controller := NewController(ctx, kubeClient, operatorClient, kubeInformerFactory.Apps().V1().Deployments(), - exampleInformerFactory.Samplecontroller().V1alpha1().Foos()) + operatorInformerFactory.Proxyprovider().V1().ProxyProviders()) // notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(ctx.done()) // Start method is non-blocking and runs all registered informers in a dedicated goroutine. kubeInformerFactory.Start(ctx.Done()) - exampleInformerFactory.Start(ctx.Done()) + operatorInformerFactory.Start(ctx.Done()) if err = controller.Run(ctx, 2); err != nil { logger.Error(err, "Error running controller") diff --git a/pkg/apis/samplecontroller/v1alpha1/doc.go b/pkg/apis/proxyprovider/v1/doc.go similarity index 84% rename from pkg/apis/samplecontroller/v1alpha1/doc.go rename to pkg/apis/proxyprovider/v1/doc.go index 72ef5ae..408cb35 100644 --- a/pkg/apis/samplecontroller/v1alpha1/doc.go +++ b/pkg/apis/proxyprovider/v1/doc.go @@ -16,7 +16,7 @@ limitations under the License. // +k8s:deepcopy-gen=package // +k8s:openapi-gen=true -// +groupName=samplecontroller.k8s.io +// +groupName=proxyprovider.t000-n.de -// Package v1alpha1 is the v1alpha1 version of the API. -package v1alpha1 +// Package v1 is the v1 version of the API. +package v1 diff --git a/pkg/apis/samplecontroller/v1alpha1/types.go b/pkg/apis/proxyprovider/v1/types.go similarity index 65% rename from pkg/apis/samplecontroller/v1alpha1/types.go rename to pkg/apis/proxyprovider/v1/types.go index e387d34..b0a4afa 100644 --- a/pkg/apis/samplecontroller/v1alpha1/types.go +++ b/pkg/apis/proxyprovider/v1/types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -23,32 +23,30 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Foo is a specification for a Foo resource -type Foo struct { +type ProxyProvider struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec FooSpec `json:"spec"` - Status FooStatus `json:"status"` + Spec ProxyProviderSpec `json:"spec"` + Status ProxyProviderStatus `json:"status"` } -// FooSpec is the spec for a Foo resource -type FooSpec struct { - DeploymentName string `json:"deploymentName"` - Replicas *int32 `json:"replicas"` +type ProxyProviderSpec struct { + Name string `json:"name"` + AuthorizationFlow string `json:"authorization_flow"` + InvalidationFlow string `json:"invalidation_flow"` + ExternalHost string `json:"external_host"` } -// FooStatus is the status for a Foo resource -type FooStatus struct { - AvailableReplicas int32 `json:"availableReplicas"` +type ProxyProviderStatus struct { + PK string `json:"pk"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// FooList is a list of Foo resources -type FooList struct { +type ProxyProviderList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []Foo `json:"items"` + Items []ProxyProvider `json:"items"` } diff --git a/pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/proxyprovider/v1/zz_generated.deepcopy.go similarity index 71% rename from pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go rename to pkg/apis/proxyprovider/v1/zz_generated.deepcopy.go index 2619460..27be419 100644 --- a/pkg/apis/samplecontroller/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/proxyprovider/v1/zz_generated.deepcopy.go @@ -19,34 +19,34 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( 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 *Foo) DeepCopyInto(out *Foo) { +func (in *ProxyProvider) DeepCopyInto(out *ProxyProvider) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) + out.Spec = in.Spec out.Status = in.Status return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Foo. -func (in *Foo) DeepCopy() *Foo { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyProvider. +func (in *ProxyProvider) DeepCopy() *ProxyProvider { if in == nil { return nil } - out := new(Foo) + out := new(ProxyProvider) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Foo) DeepCopyObject() runtime.Object { +func (in *ProxyProvider) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -54,13 +54,13 @@ func (in *Foo) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FooList) DeepCopyInto(out *FooList) { +func (in *ProxyProviderList) DeepCopyInto(out *ProxyProviderList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]Foo, len(*in)) + *out = make([]ProxyProvider, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -68,18 +68,18 @@ func (in *FooList) DeepCopyInto(out *FooList) { return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooList. -func (in *FooList) DeepCopy() *FooList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyProviderList. +func (in *ProxyProviderList) DeepCopy() *ProxyProviderList { if in == nil { return nil } - out := new(FooList) + out := new(ProxyProviderList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FooList) DeepCopyObject() runtime.Object { +func (in *ProxyProviderList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -87,38 +87,33 @@ func (in *FooList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FooSpec) DeepCopyInto(out *FooSpec) { +func (in *ProxyProviderSpec) DeepCopyInto(out *ProxyProviderSpec) { *out = *in - if in.Replicas != nil { - in, out := &in.Replicas, &out.Replicas - *out = new(int32) - **out = **in - } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooSpec. -func (in *FooSpec) DeepCopy() *FooSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyProviderSpec. +func (in *ProxyProviderSpec) DeepCopy() *ProxyProviderSpec { if in == nil { return nil } - out := new(FooSpec) + out := new(ProxyProviderSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FooStatus) DeepCopyInto(out *FooStatus) { +func (in *ProxyProviderStatus) DeepCopyInto(out *ProxyProviderStatus) { *out = *in return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FooStatus. -func (in *FooStatus) DeepCopy() *FooStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProxyProviderStatus. +func (in *ProxyProviderStatus) DeepCopy() *ProxyProviderStatus { if in == nil { return nil } - out := new(FooStatus) + out := new(ProxyProviderStatus) in.DeepCopyInto(out) return out } diff --git a/pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go b/pkg/apis/proxyprovider/v1/zz_generated.register.go similarity index 88% rename from pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go rename to pkg/apis/proxyprovider/v1/zz_generated.register.go index 146e82e..236a8cb 100644 --- a/pkg/apis/samplecontroller/v1alpha1/zz_generated.register.go +++ b/pkg/apis/proxyprovider/v1/zz_generated.register.go @@ -19,24 +19,24 @@ limitations under the License. // Code generated by register-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" ) // GroupName specifies the group name used to register the objects. -const GroupName = "samplecontroller.k8s.io" +const GroupName = "proxyprovider.t000-n.de" // GroupVersion specifies the group and the version used to register the objects. -var GroupVersion = v1.GroupVersion{Group: GroupName, Version: "v1alpha1"} +var GroupVersion = metav1.GroupVersion{Group: GroupName, Version: "v1"} // SchemeGroupVersion is group version used to register these objects // // Deprecated: use GroupVersion instead. -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} // Resource takes an unqualified resource and returns a Group qualified GroupResource func Resource(resource string) schema.GroupResource { @@ -62,10 +62,10 @@ func init() { // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &Foo{}, - &FooList{}, + &ProxyProvider{}, + &ProxyProviderList{}, ) // AddToGroupVersion allows the serialization of client types like ListOptions. - v1.AddToGroupVersion(scheme, SchemeGroupVersion) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil } diff --git a/pkg/generated/applyconfiguration/internal/internal.go b/pkg/generated/applyconfiguration/internal/internal.go index 66a908c..c482faa 100644 --- a/pkg/generated/applyconfiguration/internal/internal.go +++ b/pkg/generated/applyconfiguration/internal/internal.go @@ -39,16 +39,6 @@ func Parser() *typed.Parser { var parserOnce sync.Once var parser *typed.Parser var schemaYAML = typed.YAMLObject(`types: -- name: io.k8s.sample-controller.pkg.apis.samplecontroller.v1alpha1.Foo - scalar: untyped - list: - elementType: - namedType: __untyped_atomic_ - elementRelationship: atomic - map: - elementType: - namedType: __untyped_deduced_ - elementRelationship: separable - name: __untyped_atomic_ scalar: untyped list: diff --git a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go b/pkg/generated/applyconfiguration/proxyprovider/v1/proxyprovider.go similarity index 61% rename from pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go rename to pkg/generated/applyconfiguration/proxyprovider/v1/proxyprovider.go index b55eeff..97b5dd5 100644 --- a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go +++ b/pkg/generated/applyconfiguration/proxyprovider/v1/proxyprovider.go @@ -16,86 +16,40 @@ limitations under the License. // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" - internal "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/internal" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" - managedfields "k8s.io/apimachinery/pkg/util/managedfields" - v1 "k8s.io/client-go/applyconfigurations/meta/v1" + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" ) -// FooApplyConfiguration represents a declarative configuration of the Foo type for use +// ProxyProviderApplyConfiguration represents a declarative configuration of the ProxyProvider type for use // with apply. -// -// Foo is a specification for a Foo resource -type FooApplyConfiguration struct { - v1.TypeMetaApplyConfiguration `json:",inline"` - *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *FooSpecApplyConfiguration `json:"spec,omitempty"` - Status *FooStatusApplyConfiguration `json:"status,omitempty"` +type ProxyProviderApplyConfiguration struct { + metav1.TypeMetaApplyConfiguration `json:""` + *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ProxyProviderSpecApplyConfiguration `json:"spec,omitempty"` + Status *ProxyProviderStatusApplyConfiguration `json:"status,omitempty"` } -// Foo constructs a declarative configuration of the Foo type for use with +// ProxyProvider constructs a declarative configuration of the ProxyProvider type for use with // apply. -func Foo(name, namespace string) *FooApplyConfiguration { - b := &FooApplyConfiguration{} +func ProxyProvider(name, namespace string) *ProxyProviderApplyConfiguration { + b := &ProxyProviderApplyConfiguration{} b.WithName(name) b.WithNamespace(namespace) - b.WithKind("Foo") - b.WithAPIVersion("samplecontroller.k8s.io/v1alpha1") + b.WithKind("ProxyProvider") + b.WithAPIVersion("proxyprovider.t000-n.de/v1") return b } -// ExtractFooFrom extracts the applied configuration owned by fieldManager from -// foo for the specified subresource. Pass an empty string for subresource to extract -// the main resource. Common subresources include "status", "scale", etc. -// foo must be a unmodified Foo API object that was retrieved from the Kubernetes API. -// ExtractFooFrom provides a way to perform a extract/modify-in-place/apply workflow. -// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously -// applied if another fieldManager has updated or force applied any of the previously applied fields. -func ExtractFooFrom(foo *samplecontrollerv1alpha1.Foo, fieldManager string, subresource string) (*FooApplyConfiguration, error) { - b := &FooApplyConfiguration{} - err := managedfields.ExtractInto(foo, internal.Parser().Type("io.k8s.sample-controller.pkg.apis.samplecontroller.v1alpha1.Foo"), fieldManager, b, subresource) - if err != nil { - return nil, err - } - b.WithName(foo.Name) - b.WithNamespace(foo.Namespace) - - b.WithKind("Foo") - b.WithAPIVersion("samplecontroller.k8s.io/v1alpha1") - return b, nil -} - -// ExtractFoo extracts the applied configuration owned by fieldManager from -// foo. If no managedFields are found in foo for fieldManager, a -// FooApplyConfiguration is returned with only the Name, Namespace (if applicable), -// APIVersion and Kind populated. It is possible that no managed fields were found for because other -// field managers have taken ownership of all the fields previously owned by fieldManager, or because -// the fieldManager never owned fields any fields. -// foo must be a unmodified Foo API object that was retrieved from the Kubernetes API. -// ExtractFoo provides a way to perform a extract/modify-in-place/apply workflow. -// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously -// applied if another fieldManager has updated or force applied any of the previously applied fields. -func ExtractFoo(foo *samplecontrollerv1alpha1.Foo, fieldManager string) (*FooApplyConfiguration, error) { - return ExtractFooFrom(foo, fieldManager, "") -} - -// ExtractFooStatus extracts the applied configuration owned by fieldManager from -// foo for the status subresource. -func ExtractFooStatus(foo *samplecontrollerv1alpha1.Foo, fieldManager string) (*FooApplyConfiguration, error) { - return ExtractFooFrom(foo, fieldManager, "status") -} - -func (b FooApplyConfiguration) IsApplyConfiguration() {} +func (b ProxyProviderApplyConfiguration) 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 *FooApplyConfiguration) WithKind(value string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithKind(value string) *ProxyProviderApplyConfiguration { b.TypeMetaApplyConfiguration.Kind = &value return b } @@ -103,7 +57,7 @@ func (b *FooApplyConfiguration) WithKind(value string) *FooApplyConfiguration { // 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 *FooApplyConfiguration) WithAPIVersion(value string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithAPIVersion(value string) *ProxyProviderApplyConfiguration { b.TypeMetaApplyConfiguration.APIVersion = &value return b } @@ -111,7 +65,7 @@ func (b *FooApplyConfiguration) WithAPIVersion(value string) *FooApplyConfigurat // 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 *FooApplyConfiguration) WithName(value string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithName(value string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.Name = &value return b @@ -120,7 +74,7 @@ func (b *FooApplyConfiguration) WithName(value string) *FooApplyConfiguration { // 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 *FooApplyConfiguration) WithGenerateName(value string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithGenerateName(value string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.GenerateName = &value return b @@ -129,7 +83,7 @@ func (b *FooApplyConfiguration) WithGenerateName(value string) *FooApplyConfigur // 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 *FooApplyConfiguration) WithNamespace(value string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithNamespace(value string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.Namespace = &value return b @@ -138,7 +92,7 @@ func (b *FooApplyConfiguration) WithNamespace(value string) *FooApplyConfigurati // 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 *FooApplyConfiguration) WithUID(value types.UID) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithUID(value types.UID) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.UID = &value return b @@ -147,7 +101,7 @@ func (b *FooApplyConfiguration) WithUID(value types.UID) *FooApplyConfiguration // 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 *FooApplyConfiguration) WithResourceVersion(value string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithResourceVersion(value string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.ResourceVersion = &value return b @@ -156,7 +110,7 @@ func (b *FooApplyConfiguration) WithResourceVersion(value string) *FooApplyConfi // 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 *FooApplyConfiguration) WithGeneration(value int64) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithGeneration(value int64) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.Generation = &value return b @@ -165,7 +119,7 @@ func (b *FooApplyConfiguration) WithGeneration(value int64) *FooApplyConfigurati // 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 *FooApplyConfiguration) WithCreationTimestamp(value metav1.Time) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.CreationTimestamp = &value return b @@ -174,7 +128,7 @@ func (b *FooApplyConfiguration) WithCreationTimestamp(value metav1.Time) *FooApp // 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 *FooApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value return b @@ -183,7 +137,7 @@ func (b *FooApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *FooApp // 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 *FooApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value return b @@ -193,7 +147,7 @@ func (b *FooApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *Foo // 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 *FooApplyConfiguration) WithLabels(entries map[string]string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithLabels(entries map[string]string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 { b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries)) @@ -208,7 +162,7 @@ func (b *FooApplyConfiguration) WithLabels(entries map[string]string) *FooApplyC // 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 *FooApplyConfiguration) WithAnnotations(entries map[string]string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithAnnotations(entries map[string]string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 { b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries)) @@ -222,7 +176,7 @@ func (b *FooApplyConfiguration) WithAnnotations(entries map[string]string) *FooA // 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 *FooApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { if values[i] == nil { @@ -236,7 +190,7 @@ func (b *FooApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReference // 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 *FooApplyConfiguration) WithFinalizers(values ...string) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithFinalizers(values ...string) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) @@ -244,16 +198,16 @@ func (b *FooApplyConfiguration) WithFinalizers(values ...string) *FooApplyConfig return b } -func (b *FooApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { +func (b *ProxyProviderApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { if b.ObjectMetaApplyConfiguration == nil { - b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + b.ObjectMetaApplyConfiguration = &metav1.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 *FooApplyConfiguration) WithSpec(value *FooSpecApplyConfiguration) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithSpec(value *ProxyProviderSpecApplyConfiguration) *ProxyProviderApplyConfiguration { b.Spec = value return b } @@ -261,29 +215,29 @@ func (b *FooApplyConfiguration) WithSpec(value *FooSpecApplyConfiguration) *FooA // 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 *FooApplyConfiguration) WithStatus(value *FooStatusApplyConfiguration) *FooApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithStatus(value *ProxyProviderStatusApplyConfiguration) *ProxyProviderApplyConfiguration { b.Status = value return b } // GetKind retrieves the value of the Kind field in the declarative configuration. -func (b *FooApplyConfiguration) GetKind() *string { +func (b *ProxyProviderApplyConfiguration) GetKind() *string { return b.TypeMetaApplyConfiguration.Kind } // GetAPIVersion retrieves the value of the APIVersion field in the declarative configuration. -func (b *FooApplyConfiguration) GetAPIVersion() *string { +func (b *ProxyProviderApplyConfiguration) GetAPIVersion() *string { return b.TypeMetaApplyConfiguration.APIVersion } // GetName retrieves the value of the Name field in the declarative configuration. -func (b *FooApplyConfiguration) GetName() *string { +func (b *ProxyProviderApplyConfiguration) GetName() *string { b.ensureObjectMetaApplyConfigurationExists() return b.ObjectMetaApplyConfiguration.Name } // GetNamespace retrieves the value of the Namespace field in the declarative configuration. -func (b *FooApplyConfiguration) GetNamespace() *string { +func (b *ProxyProviderApplyConfiguration) GetNamespace() *string { b.ensureObjectMetaApplyConfigurationExists() return b.ObjectMetaApplyConfiguration.Namespace } diff --git a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go b/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go new file mode 100644 index 0000000..9b9838d --- /dev/null +++ b/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go @@ -0,0 +1,66 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1 + +// ProxyProviderSpecApplyConfiguration represents a declarative configuration of the ProxyProviderSpec type for use +// with apply. +type ProxyProviderSpecApplyConfiguration struct { + Name *string `json:"name,omitempty"` + AuthorizationFlow *string `json:"authorization_flow,omitempty"` + InvalidationFlow *string `json:"invalidation_flow,omitempty"` + ExternalHost *string `json:"external_host,omitempty"` +} + +// ProxyProviderSpecApplyConfiguration constructs a declarative configuration of the ProxyProviderSpec type for use with +// apply. +func ProxyProviderSpec() *ProxyProviderSpecApplyConfiguration { + return &ProxyProviderSpecApplyConfiguration{} +} + +// 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 *ProxyProviderSpecApplyConfiguration) WithName(value string) *ProxyProviderSpecApplyConfiguration { + b.Name = &value + return b +} + +// WithAuthorizationFlow sets the AuthorizationFlow 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 AuthorizationFlow field is set to the value of the last call. +func (b *ProxyProviderSpecApplyConfiguration) WithAuthorizationFlow(value string) *ProxyProviderSpecApplyConfiguration { + b.AuthorizationFlow = &value + return b +} + +// WithInvalidationFlow sets the InvalidationFlow 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 InvalidationFlow field is set to the value of the last call. +func (b *ProxyProviderSpecApplyConfiguration) WithInvalidationFlow(value string) *ProxyProviderSpecApplyConfiguration { + b.InvalidationFlow = &value + return b +} + +// WithExternalHost sets the ExternalHost 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 ExternalHost field is set to the value of the last call. +func (b *ProxyProviderSpecApplyConfiguration) WithExternalHost(value string) *ProxyProviderSpecApplyConfiguration { + b.ExternalHost = &value + return b +} diff --git a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go b/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go new file mode 100644 index 0000000..1527289 --- /dev/null +++ b/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go @@ -0,0 +1,39 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1 + +// ProxyProviderStatusApplyConfiguration represents a declarative configuration of the ProxyProviderStatus type for use +// with apply. +type ProxyProviderStatusApplyConfiguration struct { + PK *string `json:"pk,omitempty"` +} + +// ProxyProviderStatusApplyConfiguration constructs a declarative configuration of the ProxyProviderStatus type for use with +// apply. +func ProxyProviderStatus() *ProxyProviderStatusApplyConfiguration { + return &ProxyProviderStatusApplyConfiguration{} +} + +// WithPK sets the PK 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 PK field is set to the value of the last call. +func (b *ProxyProviderStatusApplyConfiguration) WithPK(value string) *ProxyProviderStatusApplyConfiguration { + b.PK = &value + return b +} diff --git a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go deleted file mode 100644 index 91a1410..0000000 --- a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foospec.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by applyconfiguration-gen. DO NOT EDIT. - -package v1alpha1 - -// FooSpecApplyConfiguration represents a declarative configuration of the FooSpec type for use -// with apply. -// -// FooSpec is the spec for a Foo resource -type FooSpecApplyConfiguration struct { - DeploymentName *string `json:"deploymentName,omitempty"` - Replicas *int32 `json:"replicas,omitempty"` -} - -// FooSpecApplyConfiguration constructs a declarative configuration of the FooSpec type for use with -// apply. -func FooSpec() *FooSpecApplyConfiguration { - return &FooSpecApplyConfiguration{} -} - -// WithDeploymentName sets the DeploymentName 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 DeploymentName field is set to the value of the last call. -func (b *FooSpecApplyConfiguration) WithDeploymentName(value string) *FooSpecApplyConfiguration { - b.DeploymentName = &value - return b -} - -// WithReplicas sets the Replicas 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 Replicas field is set to the value of the last call. -func (b *FooSpecApplyConfiguration) WithReplicas(value int32) *FooSpecApplyConfiguration { - b.Replicas = &value - return b -} diff --git a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go b/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go deleted file mode 100644 index f170c81..0000000 --- a/pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foostatus.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by applyconfiguration-gen. DO NOT EDIT. - -package v1alpha1 - -// FooStatusApplyConfiguration represents a declarative configuration of the FooStatus type for use -// with apply. -// -// FooStatus is the status for a Foo resource -type FooStatusApplyConfiguration struct { - AvailableReplicas *int32 `json:"availableReplicas,omitempty"` -} - -// FooStatusApplyConfiguration constructs a declarative configuration of the FooStatus type for use with -// apply. -func FooStatus() *FooStatusApplyConfiguration { - return &FooStatusApplyConfiguration{} -} - -// WithAvailableReplicas sets the AvailableReplicas 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 AvailableReplicas field is set to the value of the last call. -func (b *FooStatusApplyConfiguration) WithAvailableReplicas(value int32) *FooStatusApplyConfiguration { - b.AvailableReplicas = &value - return b -} diff --git a/pkg/generated/applyconfiguration/utils.go b/pkg/generated/applyconfiguration/utils.go index 2e03b62..da6a1aa 100644 --- a/pkg/generated/applyconfiguration/utils.go +++ b/pkg/generated/applyconfiguration/utils.go @@ -19,9 +19,9 @@ limitations under the License. package applyconfiguration import ( - v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" internal "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/internal" - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/samplecontroller/v1alpha1" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" managedfields "k8s.io/apimachinery/pkg/util/managedfields" @@ -31,13 +31,13 @@ import ( // apply configuration type exists for the given GroupVersionKind. func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { - // Group=samplecontroller.k8s.io, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithKind("Foo"): - return &samplecontrollerv1alpha1.FooApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("FooSpec"): - return &samplecontrollerv1alpha1.FooSpecApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("FooStatus"): - return &samplecontrollerv1alpha1.FooStatusApplyConfiguration{} + // Group=proxyprovider.t000-n.de, Version=v1 + case v1.SchemeGroupVersion.WithKind("ProxyProvider"): + return &proxyproviderv1.ProxyProviderApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ProxyProviderSpec"): + return &proxyproviderv1.ProxyProviderSpecApplyConfiguration{} + case v1.SchemeGroupVersion.WithKind("ProxyProviderStatus"): + return &proxyproviderv1.ProxyProviderStatusApplyConfiguration{} } return nil diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 2339bde..02a0897 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -22,7 +22,7 @@ import ( fmt "fmt" http "net/http" - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,18 +30,18 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface + ProxyproviderV1() proxyproviderv1.ProxyproviderV1Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient - samplecontrollerV1alpha1 *samplecontrollerv1alpha1.SamplecontrollerV1alpha1Client + proxyproviderV1 *proxyproviderv1.ProxyproviderV1Client } -// SamplecontrollerV1alpha1 retrieves the SamplecontrollerV1alpha1Client -func (c *Clientset) SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface { - return c.samplecontrollerV1alpha1 +// ProxyproviderV1 retrieves the ProxyproviderV1Client +func (c *Clientset) ProxyproviderV1() proxyproviderv1.ProxyproviderV1Interface { + return c.proxyproviderV1 } // Discovery retrieves the DiscoveryClient @@ -88,7 +88,7 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error - cs.samplecontrollerV1alpha1, err = samplecontrollerv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + cs.proxyproviderV1, err = proxyproviderv1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -113,7 +113,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.samplecontrollerV1alpha1 = samplecontrollerv1alpha1.New(c) + cs.proxyproviderV1 = proxyproviderv1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 1a59e3d..8651721 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -21,8 +21,8 @@ package fake import ( applyconfiguration "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration" clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" - fakesamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" + fakeproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" @@ -136,7 +136,7 @@ var ( _ testing.FakeClient = &Clientset{} ) -// SamplecontrollerV1alpha1 retrieves the SamplecontrollerV1alpha1Client -func (c *Clientset) SamplecontrollerV1alpha1() samplecontrollerv1alpha1.SamplecontrollerV1alpha1Interface { - return &fakesamplecontrollerv1alpha1.FakeSamplecontrollerV1alpha1{Fake: &c.Fake} +// ProxyproviderV1 retrieves the ProxyproviderV1Client +func (c *Clientset) ProxyproviderV1() proxyproviderv1.ProxyproviderV1Interface { + return &fakeproxyproviderv1.FakeProxyproviderV1{Fake: &c.Fake} } diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 4726554..8a725b8 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - samplecontrollerv1alpha1.AddToScheme, + proxyproviderv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index bcefc82..098bade 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - samplecontrollerv1alpha1.AddToScheme, + proxyproviderv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/doc.go similarity index 97% rename from pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1/doc.go index df51baa..3af5d05 100644 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/doc.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1alpha1 +package v1 diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/doc.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/doc.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/doc.go diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go new file mode 100644 index 0000000..575e1c9 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go @@ -0,0 +1,51 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1" + typedproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" + gentype "k8s.io/client-go/gentype" +) + +// fakeProxyProviders implements ProxyProviderInterface +type fakeProxyProviders struct { + *gentype.FakeClientWithListAndApply[*v1.ProxyProvider, *v1.ProxyProviderList, *proxyproviderv1.ProxyProviderApplyConfiguration] + Fake *FakeProxyproviderV1 +} + +func newFakeProxyProviders(fake *FakeProxyproviderV1, namespace string) typedproxyproviderv1.ProxyProviderInterface { + return &fakeProxyProviders{ + gentype.NewFakeClientWithListAndApply[*v1.ProxyProvider, *v1.ProxyProviderList, *proxyproviderv1.ProxyProviderApplyConfiguration]( + fake.Fake, + namespace, + v1.SchemeGroupVersion.WithResource("proxyproviders"), + v1.SchemeGroupVersion.WithKind("ProxyProvider"), + func() *v1.ProxyProvider { return &v1.ProxyProvider{} }, + func() *v1.ProxyProviderList { return &v1.ProxyProviderList{} }, + func(dst, src *v1.ProxyProviderList) { dst.ListMeta = src.ListMeta }, + func(list *v1.ProxyProviderList) []*v1.ProxyProvider { return gentype.ToPointerSlice(list.Items) }, + func(list *v1.ProxyProviderList, items []*v1.ProxyProvider) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider_client.go similarity index 70% rename from pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider_client.go index a806837..6e7210b 100644 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_samplecontroller_client.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider_client.go @@ -19,22 +19,22 @@ limitations under the License. package fake import ( - v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" + v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeSamplecontrollerV1alpha1 struct { +type FakeProxyproviderV1 struct { *testing.Fake } -func (c *FakeSamplecontrollerV1alpha1) Foos(namespace string) v1alpha1.FooInterface { - return newFakeFoos(c, namespace) +func (c *FakeProxyproviderV1) ProxyProviders(namespace string) v1.ProxyProviderInterface { + return newFakeProxyProviders(c, namespace) } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeSamplecontrollerV1alpha1) RESTClient() rest.Interface { +func (c *FakeProxyproviderV1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/generated_expansion.go similarity index 92% rename from pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1/generated_expansion.go index b64ea02..828bd72 100644 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/generated_expansion.go @@ -16,6 +16,6 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1 -type FooExpansion interface{} +type ProxyProviderExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go new file mode 100644 index 0000000..9a2107b --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go @@ -0,0 +1,74 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + context "context" + + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + applyconfigurationproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1" + scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ProxyProvidersGetter has a method to return a ProxyProviderInterface. +// A group's client should implement this interface. +type ProxyProvidersGetter interface { + ProxyProviders(namespace string) ProxyProviderInterface +} + +// ProxyProviderInterface has methods to work with ProxyProvider resources. +type ProxyProviderInterface interface { + Create(ctx context.Context, proxyProvider *proxyproviderv1.ProxyProvider, opts metav1.CreateOptions) (*proxyproviderv1.ProxyProvider, error) + Update(ctx context.Context, proxyProvider *proxyproviderv1.ProxyProvider, opts metav1.UpdateOptions) (*proxyproviderv1.ProxyProvider, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, proxyProvider *proxyproviderv1.ProxyProvider, opts metav1.UpdateOptions) (*proxyproviderv1.ProxyProvider, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*proxyproviderv1.ProxyProvider, error) + List(ctx context.Context, opts metav1.ListOptions) (*proxyproviderv1.ProxyProviderList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *proxyproviderv1.ProxyProvider, err error) + Apply(ctx context.Context, proxyProvider *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration, opts metav1.ApplyOptions) (result *proxyproviderv1.ProxyProvider, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, proxyProvider *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration, opts metav1.ApplyOptions) (result *proxyproviderv1.ProxyProvider, err error) + ProxyProviderExpansion +} + +// proxyProviders implements ProxyProviderInterface +type proxyProviders struct { + *gentype.ClientWithListAndApply[*proxyproviderv1.ProxyProvider, *proxyproviderv1.ProxyProviderList, *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration] +} + +// newProxyProviders returns a ProxyProviders +func newProxyProviders(c *ProxyproviderV1Client, namespace string) *proxyProviders { + return &proxyProviders{ + gentype.NewClientWithListAndApply[*proxyproviderv1.ProxyProvider, *proxyproviderv1.ProxyProviderList, *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration]( + "proxyproviders", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *proxyproviderv1.ProxyProvider { return &proxyproviderv1.ProxyProvider{} }, + func() *proxyproviderv1.ProxyProviderList { return &proxyproviderv1.ProxyProviderList{} }, + ), + } +} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider_client.go similarity index 59% rename from pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider_client.go index a3e621d..0cf67b5 100644 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/samplecontroller_client.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider_client.go @@ -16,34 +16,34 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( http "net/http" - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) -type SamplecontrollerV1alpha1Interface interface { +type ProxyproviderV1Interface interface { RESTClient() rest.Interface - FoosGetter + ProxyProvidersGetter } -// SamplecontrollerV1alpha1Client is used to interact with features provided by the samplecontroller.k8s.io group. -type SamplecontrollerV1alpha1Client struct { +// ProxyproviderV1Client is used to interact with features provided by the proxyprovider.t000-n.de group. +type ProxyproviderV1Client struct { restClient rest.Interface } -func (c *SamplecontrollerV1alpha1Client) Foos(namespace string) FooInterface { - return newFoos(c, namespace) +func (c *ProxyproviderV1Client) ProxyProviders(namespace string) ProxyProviderInterface { + return newProxyProviders(c, namespace) } -// NewForConfig creates a new SamplecontrollerV1alpha1Client for the given config. +// NewForConfig creates a new ProxyproviderV1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*SamplecontrollerV1alpha1Client, error) { +func NewForConfig(c *rest.Config) (*ProxyproviderV1Client, error) { config := *c setConfigDefaults(&config) httpClient, err := rest.HTTPClientFor(&config) @@ -53,21 +53,21 @@ func NewForConfig(c *rest.Config) (*SamplecontrollerV1alpha1Client, error) { return NewForConfigAndClient(&config, httpClient) } -// NewForConfigAndClient creates a new SamplecontrollerV1alpha1Client for the given config and http client. +// NewForConfigAndClient creates a new ProxyproviderV1Client for the given config and http client. // Note the http client provided takes precedence over the configured transport values. -func NewForConfigAndClient(c *rest.Config, h *http.Client) (*SamplecontrollerV1alpha1Client, error) { +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ProxyproviderV1Client, error) { config := *c setConfigDefaults(&config) client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } - return &SamplecontrollerV1alpha1Client{client}, nil + return &ProxyproviderV1Client{client}, nil } -// NewForConfigOrDie creates a new SamplecontrollerV1alpha1Client for the given config and +// NewForConfigOrDie creates a new ProxyproviderV1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SamplecontrollerV1alpha1Client { +func NewForConfigOrDie(c *rest.Config) *ProxyproviderV1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -75,13 +75,13 @@ func NewForConfigOrDie(c *rest.Config) *SamplecontrollerV1alpha1Client { return client } -// New creates a new SamplecontrollerV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *SamplecontrollerV1alpha1Client { - return &SamplecontrollerV1alpha1Client{c} +// New creates a new ProxyproviderV1Client for the given RESTClient. +func New(c rest.Interface) *ProxyproviderV1Client { + return &ProxyproviderV1Client{c} } func setConfigDefaults(config *rest.Config) { - gv := samplecontrollerv1alpha1.SchemeGroupVersion + gv := proxyproviderv1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() @@ -93,7 +93,7 @@ func setConfigDefaults(config *rest.Config) { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *SamplecontrollerV1alpha1Client) RESTClient() rest.Interface { +func (c *ProxyproviderV1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go deleted file mode 100644 index ef2a943..0000000 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/fake/fake_foo.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/samplecontroller/v1alpha1" - typedsamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1" - gentype "k8s.io/client-go/gentype" -) - -// fakeFoos implements FooInterface -type fakeFoos struct { - *gentype.FakeClientWithListAndApply[*v1alpha1.Foo, *v1alpha1.FooList, *samplecontrollerv1alpha1.FooApplyConfiguration] - Fake *FakeSamplecontrollerV1alpha1 -} - -func newFakeFoos(fake *FakeSamplecontrollerV1alpha1, namespace string) typedsamplecontrollerv1alpha1.FooInterface { - return &fakeFoos{ - gentype.NewFakeClientWithListAndApply[*v1alpha1.Foo, *v1alpha1.FooList, *samplecontrollerv1alpha1.FooApplyConfiguration]( - fake.Fake, - namespace, - v1alpha1.SchemeGroupVersion.WithResource("foos"), - v1alpha1.SchemeGroupVersion.WithKind("Foo"), - func() *v1alpha1.Foo { return &v1alpha1.Foo{} }, - func() *v1alpha1.FooList { return &v1alpha1.FooList{} }, - func(dst, src *v1alpha1.FooList) { dst.ListMeta = src.ListMeta }, - func(list *v1alpha1.FooList) []*v1alpha1.Foo { return gentype.ToPointerSlice(list.Items) }, - func(list *v1alpha1.FooList, items []*v1alpha1.Foo) { list.Items = gentype.FromPointerSlice(items) }, - ), - fake, - } -} diff --git a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go b/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go deleted file mode 100644 index 4abd819..0000000 --- a/pkg/generated/clientset/versioned/typed/samplecontroller/v1alpha1/foo.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - context "context" - - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" - applyconfigurationsamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/samplecontroller/v1alpha1" - scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - gentype "k8s.io/client-go/gentype" -) - -// FoosGetter has a method to return a FooInterface. -// A group's client should implement this interface. -type FoosGetter interface { - Foos(namespace string) FooInterface -} - -// FooInterface has methods to work with Foo resources. -type FooInterface interface { - Create(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.CreateOptions) (*samplecontrollerv1alpha1.Foo, error) - Update(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.UpdateOptions) (*samplecontrollerv1alpha1.Foo, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - UpdateStatus(ctx context.Context, foo *samplecontrollerv1alpha1.Foo, opts v1.UpdateOptions) (*samplecontrollerv1alpha1.Foo, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*samplecontrollerv1alpha1.Foo, error) - List(ctx context.Context, opts v1.ListOptions) (*samplecontrollerv1alpha1.FooList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *samplecontrollerv1alpha1.Foo, err error) - Apply(ctx context.Context, foo *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration, opts v1.ApplyOptions) (result *samplecontrollerv1alpha1.Foo, err error) - // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). - ApplyStatus(ctx context.Context, foo *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration, opts v1.ApplyOptions) (result *samplecontrollerv1alpha1.Foo, err error) - FooExpansion -} - -// foos implements FooInterface -type foos struct { - *gentype.ClientWithListAndApply[*samplecontrollerv1alpha1.Foo, *samplecontrollerv1alpha1.FooList, *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration] -} - -// newFoos returns a Foos -func newFoos(c *SamplecontrollerV1alpha1Client, namespace string) *foos { - return &foos{ - gentype.NewClientWithListAndApply[*samplecontrollerv1alpha1.Foo, *samplecontrollerv1alpha1.FooList, *applyconfigurationsamplecontrollerv1alpha1.FooApplyConfiguration]( - "foos", - c.RESTClient(), - scheme.ParameterCodec, - namespace, - func() *samplecontrollerv1alpha1.Foo { return &samplecontrollerv1alpha1.Foo{} }, - func() *samplecontrollerv1alpha1.FooList { return &samplecontrollerv1alpha1.FooList{} }, - ), - } -} diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go index 6b1a26a..2268ae3 100644 --- a/pkg/generated/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -26,7 +26,7 @@ import ( versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" - samplecontroller "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/samplecontroller" + proxyprovider "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -325,9 +325,9 @@ type SharedInformerFactory interface { // client. InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer - Samplecontroller() samplecontroller.Interface + Proxyprovider() proxyprovider.Interface } -func (f *sharedInformerFactory) Samplecontroller() samplecontroller.Interface { - return samplecontroller.New(f, f.namespace, f.tweakListOptions) +func (f *sharedInformerFactory) Proxyprovider() proxyprovider.Interface { + return proxyprovider.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index a8563be..d855ee4 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -21,7 +21,7 @@ package externalversions import ( fmt "fmt" - v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" + v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,9 +52,9 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=samplecontroller.k8s.io, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("foos"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Samplecontroller().V1alpha1().Foos().Informer()}, nil + // Group=proxyprovider.t000-n.de, Version=v1 + case v1.SchemeGroupVersion.WithResource("proxyproviders"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Proxyprovider().V1().ProxyProviders().Informer()}, nil } diff --git a/pkg/generated/informers/externalversions/samplecontroller/interface.go b/pkg/generated/informers/externalversions/proxyprovider/interface.go similarity index 75% rename from pkg/generated/informers/externalversions/samplecontroller/interface.go rename to pkg/generated/informers/externalversions/proxyprovider/interface.go index acd7c61..e91d464 100644 --- a/pkg/generated/informers/externalversions/samplecontroller/interface.go +++ b/pkg/generated/informers/externalversions/proxyprovider/interface.go @@ -16,17 +16,17 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package samplecontroller +package proxyprovider import ( internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/samplecontroller/v1alpha1" + v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1alpha1 provides access to shared informers for resources in V1alpha1. - V1alpha1() v1alpha1.Interface + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1alpha1 returns a new v1alpha1.Interface. -func (g *group) V1alpha1() v1alpha1.Interface { - return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go b/pkg/generated/informers/externalversions/proxyprovider/v1/interface.go similarity index 79% rename from pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go rename to pkg/generated/informers/externalversions/proxyprovider/v1/interface.go index 7fe2077..556060f 100644 --- a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/proxyprovider/v1/interface.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" @@ -24,8 +24,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // Foos returns a FooInformer. - Foos() FooInformer + // ProxyProviders returns a ProxyProviderInformer. + ProxyProviders() ProxyProviderInformer } type version struct { @@ -39,7 +39,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// Foos returns a FooInformer. -func (v *version) Foos() FooInformer { - return &fooInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +// ProxyProviders returns a ProxyProviderInformer. +func (v *version) ProxyProviders() ProxyProviderInformer { + return &proxyProviderInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } diff --git a/pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go b/pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go new file mode 100644 index 0000000..dd8ab33 --- /dev/null +++ b/pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go @@ -0,0 +1,116 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + context "context" + time "time" + + apisproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" + internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ProxyProviderInformer provides access to a shared informer and lister for +// ProxyProviders. +type ProxyProviderInformer interface { + Informer() cache.SharedIndexInformer + Lister() proxyproviderv1.ProxyProviderLister +} + +type proxyProviderInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewProxyProviderInformer constructs a new informer for ProxyProvider type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewProxyProviderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewProxyProviderInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers}) +} + +// NewFilteredProxyProviderInformer constructs a new informer for ProxyProvider type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredProxyProviderInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return NewProxyProviderInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions}) +} + +// NewProxyProviderInformerWithOptions constructs a new informer for ProxyProvider type with additional options. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewProxyProviderInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { + gvr := schema.GroupVersionResource{Group: "proxyprovider.t000-n.de", Version: "v1", Resource: "proxyproviders"} + identifier := options.InformerName.WithResource(gvr) + tweakListOptions := options.TweakListOptions + return cache.NewSharedIndexInformerWithOptions( + cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ + ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.ProxyproviderV1().ProxyProviders(namespace).List(context.Background(), opts) + }, + WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.ProxyproviderV1().ProxyProviders(namespace).Watch(context.Background(), opts) + }, + ListWithContextFunc: func(ctx context.Context, opts metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.ProxyproviderV1().ProxyProviders(namespace).List(ctx, opts) + }, + WatchFuncWithContext: func(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&opts) + } + return client.ProxyproviderV1().ProxyProviders(namespace).Watch(ctx, opts) + }, + }, client), + &apisproxyproviderv1.ProxyProvider{}, + cache.SharedIndexInformerOptions{ + ResyncPeriod: options.ResyncPeriod, + Indexers: options.Indexers, + Identifier: identifier, + }, + ) +} + +func (f *proxyProviderInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewProxyProviderInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions}) +} + +func (f *proxyProviderInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apisproxyproviderv1.ProxyProvider{}, f.defaultInformer) +} + +func (f *proxyProviderInformer) Lister() proxyproviderv1.ProxyProviderLister { + return proxyproviderv1.NewProxyProviderLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go deleted file mode 100644 index cb7fa39..0000000 --- a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - context "context" - time "time" - - apissamplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" - versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" - internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/samplecontroller/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// FooInformer provides access to a shared informer and lister for -// Foos. -type FooInformer interface { - Informer() cache.SharedIndexInformer - Lister() samplecontrollerv1alpha1.FooLister -} - -type fooInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewFooInformer constructs a new informer for Foo type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers}) -} - -// NewFilteredFooInformer constructs a new informer for Foo type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return NewFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions}) -} - -// NewFooInformerWithOptions constructs a new informer for Foo type with additional options. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFooInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { - gvr := schema.GroupVersionResource{Group: "samplecontroller.k8s.io", Version: "v1alpha1", Resource: "foos"} - identifier := options.InformerName.WithResource(gvr) - tweakListOptions := options.TweakListOptions - return cache.NewSharedIndexInformerWithOptions( - cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ - ListFunc: func(opts v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&opts) - } - return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.Background(), opts) - }, - WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&opts) - } - return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.Background(), opts) - }, - ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&opts) - } - return client.SamplecontrollerV1alpha1().Foos(namespace).List(ctx, opts) - }, - WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&opts) - } - return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(ctx, opts) - }, - }, client), - &apissamplecontrollerv1alpha1.Foo{}, - cache.SharedIndexInformerOptions{ - ResyncPeriod: options.ResyncPeriod, - Indexers: options.Indexers, - Identifier: identifier, - }, - ) -} - -func (f *fooInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFooInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions}) -} - -func (f *fooInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&apissamplecontrollerv1alpha1.Foo{}, f.defaultInformer) -} - -func (f *fooInformer) Lister() samplecontrollerv1alpha1.FooLister { - return samplecontrollerv1alpha1.NewFooLister(f.Informer().GetIndexer()) -} diff --git a/pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go b/pkg/generated/listers/proxyprovider/v1/expansion_generated.go similarity index 66% rename from pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go rename to pkg/generated/listers/proxyprovider/v1/expansion_generated.go index 9a34636..06a3fac 100644 --- a/pkg/generated/listers/samplecontroller/v1alpha1/expansion_generated.go +++ b/pkg/generated/listers/proxyprovider/v1/expansion_generated.go @@ -16,12 +16,12 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 +package v1 -// FooListerExpansion allows custom methods to be added to -// FooLister. -type FooListerExpansion interface{} +// ProxyProviderListerExpansion allows custom methods to be added to +// ProxyProviderLister. +type ProxyProviderListerExpansion interface{} -// FooNamespaceListerExpansion allows custom methods to be added to -// FooNamespaceLister. -type FooNamespaceListerExpansion interface{} +// ProxyProviderNamespaceListerExpansion allows custom methods to be added to +// ProxyProviderNamespaceLister. +type ProxyProviderNamespaceListerExpansion interface{} diff --git a/pkg/generated/listers/proxyprovider/v1/proxyprovider.go b/pkg/generated/listers/proxyprovider/v1/proxyprovider.go new file mode 100644 index 0000000..64d319b --- /dev/null +++ b/pkg/generated/listers/proxyprovider/v1/proxyprovider.go @@ -0,0 +1,70 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// ProxyProviderLister helps list ProxyProviders. +// All objects returned here must be treated as read-only. +type ProxyProviderLister interface { + // List lists all ProxyProviders in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*proxyproviderv1.ProxyProvider, err error) + // ProxyProviders returns an object that can list and get ProxyProviders. + ProxyProviders(namespace string) ProxyProviderNamespaceLister + ProxyProviderListerExpansion +} + +// proxyProviderLister implements the ProxyProviderLister interface. +type proxyProviderLister struct { + listers.ResourceIndexer[*proxyproviderv1.ProxyProvider] +} + +// NewProxyProviderLister returns a new ProxyProviderLister. +func NewProxyProviderLister(indexer cache.Indexer) ProxyProviderLister { + return &proxyProviderLister{listers.New[*proxyproviderv1.ProxyProvider](indexer, proxyproviderv1.Resource("proxyprovider"))} +} + +// ProxyProviders returns an object that can list and get ProxyProviders. +func (s *proxyProviderLister) ProxyProviders(namespace string) ProxyProviderNamespaceLister { + return proxyProviderNamespaceLister{listers.NewNamespaced[*proxyproviderv1.ProxyProvider](s.ResourceIndexer, namespace)} +} + +// ProxyProviderNamespaceLister helps list and get ProxyProviders. +// All objects returned here must be treated as read-only. +type ProxyProviderNamespaceLister interface { + // List lists all ProxyProviders in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*proxyproviderv1.ProxyProvider, err error) + // Get retrieves the ProxyProvider from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*proxyproviderv1.ProxyProvider, error) + ProxyProviderNamespaceListerExpansion +} + +// proxyProviderNamespaceLister implements the ProxyProviderNamespaceLister +// interface. +type proxyProviderNamespaceLister struct { + listers.ResourceIndexer[*proxyproviderv1.ProxyProvider] +} diff --git a/pkg/generated/listers/samplecontroller/v1alpha1/foo.go b/pkg/generated/listers/samplecontroller/v1alpha1/foo.go deleted file mode 100644 index b854564..0000000 --- a/pkg/generated/listers/samplecontroller/v1alpha1/foo.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - samplecontrollerv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1" - labels "k8s.io/apimachinery/pkg/labels" - listers "k8s.io/client-go/listers" - cache "k8s.io/client-go/tools/cache" -) - -// FooLister helps list Foos. -// All objects returned here must be treated as read-only. -type FooLister interface { - // List lists all Foos in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*samplecontrollerv1alpha1.Foo, err error) - // Foos returns an object that can list and get Foos. - Foos(namespace string) FooNamespaceLister - FooListerExpansion -} - -// fooLister implements the FooLister interface. -type fooLister struct { - listers.ResourceIndexer[*samplecontrollerv1alpha1.Foo] -} - -// NewFooLister returns a new FooLister. -func NewFooLister(indexer cache.Indexer) FooLister { - return &fooLister{listers.New[*samplecontrollerv1alpha1.Foo](indexer, samplecontrollerv1alpha1.Resource("foo"))} -} - -// Foos returns an object that can list and get Foos. -func (s *fooLister) Foos(namespace string) FooNamespaceLister { - return fooNamespaceLister{listers.NewNamespaced[*samplecontrollerv1alpha1.Foo](s.ResourceIndexer, namespace)} -} - -// FooNamespaceLister helps list and get Foos. -// All objects returned here must be treated as read-only. -type FooNamespaceLister interface { - // List lists all Foos in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*samplecontrollerv1alpha1.Foo, err error) - // Get retrieves the Foo from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*samplecontrollerv1alpha1.Foo, error) - FooNamespaceListerExpansion -} - -// fooNamespaceLister implements the FooNamespaceLister -// interface. -type fooNamespaceLister struct { - listers.ResourceIndexer[*samplecontrollerv1alpha1.Foo] -} diff --git a/pkg/generated/openapi/cmd/models-schema/main.go b/pkg/generated/openapi/cmd/models-schema/main.go deleted file mode 100644 index f3e6b6e..0000000 --- a/pkg/generated/openapi/cmd/models-schema/main.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2021 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package main - -import ( - "encoding/json" - "fmt" - "os" - - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/openapi" - "k8s.io/kube-openapi/pkg/common" - "k8s.io/kube-openapi/pkg/validation/spec" -) - -// Outputs openAPI schema JSON containing the schema definitions in zz_generated.openapi.go. -func main() { - err := output() - if err != nil { - fmt.Fprintf(os.Stderr, "Failed: %v", err) // nolint:errcheck - os.Exit(1) - } -} - -func output() error { - refFunc := func(name string) spec.Ref { - return spec.MustCreateRef(fmt.Sprintf("#/definitions/%s", name)) - } - defs := openapi.GetOpenAPIDefinitions(refFunc) - schemaDefs := make(map[string]spec.Schema, len(defs)) - for k, v := range defs { - // Replace top-level schema with v2 if a v2 schema is embedded - // so that the output of this program is always in OpenAPI v2. - // This is done by looking up an extension that marks the embedded v2 - // schema, and, if the v2 schema is found, make it the resulting schema for - // the type. - if schema, ok := v.Schema.Extensions[common.ExtensionV2Schema]; ok { - if v2Schema, isOpenAPISchema := schema.(spec.Schema); isOpenAPISchema { - schemaDefs[k] = v2Schema - continue - } - } - - schemaDefs[k] = v.Schema - } - data, err := json.Marshal(&spec.Swagger{ - SwaggerProps: spec.SwaggerProps{ - Definitions: schemaDefs, - Info: &spec.Info{ - InfoProps: spec.InfoProps{ - Title: "Kubernetes", - Version: "unversioned", - }, - }, - Swagger: "2.0", - }, - }) - if err != nil { - return fmt.Errorf("error serializing api definitions: %w", err) - } - os.Stdout.Write(data) // nolint:errcheck - return nil -} diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index d825901..b245522 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -32,6 +32,10 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProvider": schema_pkg_apis_proxyprovider_v1_ProxyProvider(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderList": schema_pkg_apis_proxyprovider_v1_ProxyProviderList(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderSpec": schema_pkg_apis_proxyprovider_v1_ProxyProviderSpec(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderStatus": schema_pkg_apis_proxyprovider_v1_ProxyProviderStatus(ref), resource.Quantity{}.OpenAPIModelName(): schema_apimachinery_pkg_api_resource_Quantity(ref), v1.APIGroup{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroup(ref), v1.APIGroupList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroupList(ref), @@ -87,10 +91,161 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA runtime.TypeMeta{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref), runtime.Unknown{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_runtime_Unknown(ref), version.Info{}.OpenAPIModelName(): schema_k8sio_apimachinery_pkg_version_Info(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.Foo": schema_pkg_apis_samplecontroller_v1alpha1_Foo(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooList": schema_pkg_apis_samplecontroller_v1alpha1_FooList(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooSpec": schema_pkg_apis_samplecontroller_v1alpha1_FooSpec(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooStatus": schema_pkg_apis_samplecontroller_v1alpha1_FooStatus(ref), + } +} + +func schema_pkg_apis_proxyprovider_v1_ProxyProvider(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ObjectMeta{}.OpenAPIModelName()), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderStatus"), + }, + }, + }, + Required: []string{"spec", "status"}, + }, + }, + Dependencies: []string{ + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderSpec", "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderStatus", v1.ObjectMeta{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_proxyprovider_v1_ProxyProviderList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref(v1.ListMeta{}.OpenAPIModelName()), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProvider"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProvider", v1.ListMeta{}.OpenAPIModelName()}, + } +} + +func schema_pkg_apis_proxyprovider_v1_ProxyProviderSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "authorization_flow": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "invalidation_flow": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "external_host": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"name", "authorization_flow", "invalidation_flow", "external_host"}, + }, + }, + } +} + +func schema_pkg_apis_proxyprovider_v1_ProxyProviderStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "pk": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"pk"}, + }, + }, } } @@ -183,8 +338,7 @@ func schema_pkg_apis_meta_v1_APIGroup(ref common.ReferenceCallback) common.OpenA Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.GroupVersionForDiscovery{}.OpenAPIModelName()), + Ref: ref(v1.GroupVersionForDiscovery{}.OpenAPIModelName()), }, }, }, @@ -209,8 +363,7 @@ func schema_pkg_apis_meta_v1_APIGroup(ref common.ReferenceCallback) common.OpenA Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.ServerAddressByClientCIDR{}.OpenAPIModelName()), + Ref: ref(v1.ServerAddressByClientCIDR{}.OpenAPIModelName()), }, }, }, @@ -258,8 +411,7 @@ func schema_pkg_apis_meta_v1_APIGroupList(ref common.ReferenceCallback) common.O Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.APIGroup{}.OpenAPIModelName()), + Ref: ref(v1.APIGroup{}.OpenAPIModelName()), }, }, }, @@ -334,9 +486,8 @@ func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.Op Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -354,9 +505,8 @@ func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.Op Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -374,9 +524,8 @@ func schema_pkg_apis_meta_v1_APIResource(ref common.ReferenceCallback) common.Op Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -437,8 +586,7 @@ func schema_pkg_apis_meta_v1_APIResourceList(ref common.ReferenceCallback) commo Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.APIResource{}.OpenAPIModelName()), + Ref: ref(v1.APIResource{}.OpenAPIModelName()), }, }, }, @@ -486,9 +634,8 @@ func schema_pkg_apis_meta_v1_APIVersions(ref common.ReferenceCallback) common.Op Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -506,8 +653,7 @@ func schema_pkg_apis_meta_v1_APIVersions(ref common.ReferenceCallback) common.Op Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.ServerAddressByClientCIDR{}.OpenAPIModelName()), + Ref: ref(v1.ServerAddressByClientCIDR{}.OpenAPIModelName()), }, }, }, @@ -555,9 +701,8 @@ func schema_pkg_apis_meta_v1_ApplyOptions(ref common.ReferenceCallback) common.O Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -680,9 +825,8 @@ func schema_pkg_apis_meta_v1_CreateOptions(ref common.ReferenceCallback) common. Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -768,9 +912,8 @@ func schema_pkg_apis_meta_v1_DeleteOptions(ref common.ReferenceCallback) common. Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -838,9 +981,8 @@ func schema_pkg_apis_meta_v1_FieldSelectorRequirement(ref common.ReferenceCallba Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1123,9 +1265,8 @@ func schema_pkg_apis_meta_v1_LabelSelector(ref common.ReferenceCallback) common. Allows: true, Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1143,8 +1284,7 @@ func schema_pkg_apis_meta_v1_LabelSelector(ref common.ReferenceCallback) common. Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.LabelSelectorRequirement{}.OpenAPIModelName()), + Ref: ref(v1.LabelSelectorRequirement{}.OpenAPIModelName()), }, }, }, @@ -1198,9 +1338,8 @@ func schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref common.ReferenceCallba Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1573,9 +1712,8 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope Allows: true, Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1589,9 +1727,8 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope Allows: true, Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1614,8 +1751,7 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.OwnerReference{}.OpenAPIModelName()), + Ref: ref(v1.OwnerReference{}.OpenAPIModelName()), }, }, }, @@ -1634,9 +1770,8 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1654,8 +1789,7 @@ func schema_pkg_apis_meta_v1_ObjectMeta(ref common.ReferenceCallback) common.Ope Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.ManagedFieldsEntry{}.OpenAPIModelName()), + Ref: ref(v1.ManagedFieldsEntry{}.OpenAPIModelName()), }, }, }, @@ -1805,8 +1939,7 @@ func schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref common.ReferenceCallb Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.PartialObjectMetadata{}.OpenAPIModelName()), + Ref: ref(v1.PartialObjectMetadata{}.OpenAPIModelName()), }, }, }, @@ -1865,9 +1998,8 @@ func schema_pkg_apis_meta_v1_PatchOptions(ref common.ReferenceCallback) common.O Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -1946,9 +2078,8 @@ func schema_pkg_apis_meta_v1_RootPaths(ref common.ReferenceCallback) common.Open Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -2164,8 +2295,7 @@ func schema_pkg_apis_meta_v1_StatusDetails(ref common.ReferenceCallback) common. Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.StatusCause{}.OpenAPIModelName()), + Ref: ref(v1.StatusCause{}.OpenAPIModelName()), }, }, }, @@ -2226,8 +2356,7 @@ func schema_pkg_apis_meta_v1_Table(ref common.ReferenceCallback) common.OpenAPID Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.TableColumnDefinition{}.OpenAPIModelName()), + Ref: ref(v1.TableColumnDefinition{}.OpenAPIModelName()), }, }, }, @@ -2245,8 +2374,7 @@ func schema_pkg_apis_meta_v1_Table(ref common.ReferenceCallback) common.OpenAPID Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.TableRow{}.OpenAPIModelName()), + Ref: ref(v1.TableRow{}.OpenAPIModelName()), }, }, }, @@ -2387,8 +2515,7 @@ func schema_pkg_apis_meta_v1_TableRow(ref common.ReferenceCallback) common.OpenA Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.TableRowCondition{}.OpenAPIModelName()), + Ref: ref(v1.TableRowCondition{}.OpenAPIModelName()), }, }, }, @@ -2555,9 +2682,8 @@ func schema_pkg_apis_meta_v1_UpdateOptions(ref common.ReferenceCallback) common. Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", + Type: []string{"string"}, + Format: "", }, }, }, @@ -2616,7 +2742,7 @@ func schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref common.ReferenceCall return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.Object `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// External package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// On the wire, the JSON will look something like this:\n\n\t{\n\t\t\"kind\":\"MyAPIObject\",\n\t\t\"apiVersion\":\"v1\",\n\t\t\"myPlugin\": {\n\t\t\t\"kind\":\"PluginA\",\n\t\t\t\"aOption\":\"foo\",\n\t\t},\n\t}\n\nSo what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)", + Description: "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\"\"`\n\t\tMyPlugin runtime.Object `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// External package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\"\"`\n\t\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// On the wire, the JSON will look something like this:\n\n\t{\n\t\t\"kind\":\"MyAPIObject\",\n\t\t\"apiVersion\":\"v1\",\n\t\t\"myPlugin\": {\n\t\t\t\"kind\":\"PluginA\",\n\t\t\t\"aOption\":\"foo\",\n\t\t},\n\t}\n\nSo what happens? Decode first uses json or yaml to unmarshal the serialized data into your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. The next step is to copy (using pkg/conversion) into the internal struct. The runtime package's DefaultScheme has conversion functions installed which will unpack the JSON stored in RawExtension, turning it into the correct object type, and storing it in the Object. (TODO: In the case where the object is of an unknown type, a runtime.Unknown object will be created and stored.)", Type: []string{"object"}, }, }, @@ -2627,7 +2753,7 @@ func schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref common.ReferenceCallback return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, like this:\n\n\ttype MyAwesomeAPIObject struct {\n\t runtime.TypeMeta `json:\",inline\"`\n\t ... // other fields\n\t}\n\nfunc (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind\n\nTypeMeta is provided here for convenience. You may use it directly from this package or define your own with the same fields.", + Description: "TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, like this:\n\n\ttype MyAwesomeAPIObject struct {\n\t runtime.TypeMeta `json:\"\"`\n\t ... // other fields\n\t}\n\nfunc (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind\n\nTypeMeta is provided here for convenience. You may use it directly from this package or define your own with the same fields.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "apiVersion": { @@ -2796,148 +2922,3 @@ func schema_k8sio_apimachinery_pkg_version_Info(ref common.ReferenceCallback) co }, } } - -func schema_pkg_apis_samplecontroller_v1alpha1_Foo(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "Foo is a specification for a Foo resource", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.ObjectMeta{}.OpenAPIModelName()), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooSpec"), - }, - }, - "status": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooStatus"), - }, - }, - }, - Required: []string{"spec", "status"}, - }, - }, - Dependencies: []string{ - v1.ObjectMeta{}.OpenAPIModelName(), "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooSpec", "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.FooStatus"}, - } -} - -func schema_pkg_apis_samplecontroller_v1alpha1_FooList(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FooList is a list of Foo resources", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref(v1.ListMeta{}.OpenAPIModelName()), - }, - }, - "items": { - SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.Foo"), - }, - }, - }, - }, - }, - }, - Required: []string{"items"}, - }, - }, - Dependencies: []string{ - v1.ListMeta{}.OpenAPIModelName(), "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/samplecontroller/v1alpha1.Foo"}, - } -} - -func schema_pkg_apis_samplecontroller_v1alpha1_FooSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FooSpec is the spec for a Foo resource", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "deploymentName": { - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - "replicas": { - SchemaProps: spec.SchemaProps{ - Type: []string{"integer"}, - Format: "int32", - }, - }, - }, - Required: []string{"deploymentName", "replicas"}, - }, - }, - } -} - -func schema_pkg_apis_samplecontroller_v1alpha1_FooStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "FooStatus is the status for a Foo resource", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "availableReplicas": { - SchemaProps: spec.SchemaProps{ - Default: 0, - Type: []string{"integer"}, - Format: "int32", - }, - }, - }, - Required: []string{"availableReplicas"}, - }, - }, - } -} diff --git a/pkg/signals/signal_windows.go b/pkg/signals/signal_windows.go deleted file mode 100644 index 4907d57..0000000 --- a/pkg/signals/signal_windows.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package signals - -import ( - "os" -) - -var shutdownSignals = []os.Signal{os.Interrupt} diff --git a/scripts/codegen.sh b/scripts/codegen.sh new file mode 100755 index 0000000..cca51c7 --- /dev/null +++ b/scripts/codegen.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Run Kubernetes code generators for pkg/apis using vendored kube_codegen.sh. + +set -euo pipefail + +# kube_codegen runs nested `go install` from the code-generator submodule. For this +# repo we force: +# -buildvcs=false — avoid git stamping failures (submodules, safe.directory) +# -mod=mod — do not use the repo root vendor/ (often stale vs go.mod +# or unrelated to generator tools); fetch modules instead. +export GOFLAGS="-buildvcs=false -mod=mod" + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd -P)" + +MODULE="gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator" +KUBE_CODEGEN="${REPO_ROOT}/code-generator/kube_codegen.sh" +BOILERPLATE="${REPO_ROOT}/code-generator/examples/hack/boilerplate.go.txt" +API_ROOT="${REPO_ROOT}/pkg/apis" +GEN_ROOT="${REPO_ROOT}/pkg/generated" + +source "${KUBE_CODEGEN}" + +kube::codegen::gen_helpers --boilerplate "${BOILERPLATE}" "${API_ROOT}" +kube::codegen::gen_register --boilerplate "${BOILERPLATE}" "${API_ROOT}" + +# OpenAPI rule diff: keep a checked-in baseline (see k8s.io/code-generator examples/hack/update-codegen.sh). +API_VIOLATIONS_DIR="${REPO_ROOT}/hack/api-violations" +VIOLATIONS_LIST="${API_VIOLATIONS_DIR}/codegen_violation_exceptions.list" +mkdir -p "${API_VIOLATIONS_DIR}" +openapi_report_args=(--report-filename "${VIOLATIONS_LIST}") +if [[ ! -s "${VIOLATIONS_LIST}" ]] || [[ "${UPDATE_API_KNOWN_VIOLATIONS:-}" == "true" ]]; then + openapi_report_args+=(--update-report) +fi + +kube::codegen::gen_openapi \ + --output-dir "${GEN_ROOT}/openapi" \ + --output-pkg "${MODULE}/pkg/generated/openapi" \ + --output-model-name-file zz_generated.model_name.go \ + --boilerplate "${BOILERPLATE}" \ + "${openapi_report_args[@]}" \ + "${API_ROOT}" + +kube::codegen::gen_client \ + --with-watch \ + --with-applyconfig \ + --output-dir "${GEN_ROOT}" \ + --output-pkg "${MODULE}/pkg/generated" \ + --boilerplate "${BOILERPLATE}" \ + "${API_ROOT}" -- 2.52.0 From 90d21f1dd8a1a3623fa1b9aac348427f2cfb3b08 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Fri, 15 May 2026 11:09:20 +0200 Subject: [PATCH 03/14] mvp working creation of proxy provider --- .gitignore | 7 ++- .vscode/launch.json | 17 ++++++ Makefile | 12 ++-- artifacts/{examples => crd}/crd.yaml | 8 +++ artifacts/examples/example-foo.yaml | 7 --- artifacts/examples/proxyProvider.yaml | 11 ++++ controller.go | 84 +++++++++++++++++++++++---- go.mod | 8 +-- go.sum | 23 +------- main.go | 46 +++++++++++++-- pkg/apis/proxyprovider/v1/types.go | 1 + 11 files changed, 166 insertions(+), 58 deletions(-) create mode 100644 .vscode/launch.json rename artifacts/{examples => crd}/crd.yaml (85%) delete mode 100644 artifacts/examples/example-foo.yaml create mode 100644 artifacts/examples/proxyProvider.yaml diff --git a/.gitignore b/.gitignore index eb38878..dc7f41b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,9 @@ go.work.sum # env file .env -vendor/* + +# vendor directory +vendor/ + +# build artifacts +main diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..edadf84 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${fileDirname}", + "args": ["--kubeconfig=/home/tbehrendt/.kube/config"], + "envFile": ".env" + } + ] +} diff --git a/Makefile b/Makefile index f9cac0a..0c34b95 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ -REPO_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) - +ifneq (,$(wildcard ./.env)) + include .env + export +endif .PHONY: build run codegen build: - go build + go build -o main run: make build - ./main + ./main --kubeconfig=/home/tbehrendt/.kube/config codegen: - $(REPO_ROOT)/scripts/codegen.sh + ./scripts/codegen.sh diff --git a/artifacts/examples/crd.yaml b/artifacts/crd/crd.yaml similarity index 85% rename from artifacts/examples/crd.yaml rename to artifacts/crd/crd.yaml index e492835..59cb9f9 100644 --- a/artifacts/examples/crd.yaml +++ b/artifacts/crd/crd.yaml @@ -8,6 +8,12 @@ spec: - name: v1 served: true storage: true + subresources: + status: {} + additionalPrinterColumns: + - name: PK + type: string + jsonPath: .status.pk schema: openAPIV3Schema: type: object @@ -38,4 +44,6 @@ spec: names: kind: ProxyProvider plural: proxyproviders + shortNames: + - pp scope: Namespaced diff --git a/artifacts/examples/example-foo.yaml b/artifacts/examples/example-foo.yaml deleted file mode 100644 index 897059c..0000000 --- a/artifacts/examples/example-foo.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: samplecontroller.k8s.io/v1alpha1 -kind: Foo -metadata: - name: example-foo -spec: - deploymentName: example-foo - replicas: 1 diff --git a/artifacts/examples/proxyProvider.yaml b/artifacts/examples/proxyProvider.yaml new file mode 100644 index 0000000..94e55d7 --- /dev/null +++ b/artifacts/examples/proxyProvider.yaml @@ -0,0 +1,11 @@ +# Example ProxyProvider CRD +apiVersion: proxyprovider.t000-n.de/v1 +kind: ProxyProvider +metadata: + name: proxy-provider-example + namespace: kube-system +spec: + name: proxy-provider-example + authorization_flow: 16896c6d-b326-42d1-8d3f-93f32921962e + invalidation_flow: 7acac1ef-19e3-4a6f-8d8d-14ca7031d184 + external_host: https://example.t00n.de diff --git a/controller.go b/controller.go index 908fd98..d5f06c6 100644 --- a/controller.go +++ b/controller.go @@ -19,6 +19,7 @@ package main import ( "context" "fmt" + "strconv" "time" "golang.org/x/time/rate" @@ -39,10 +40,12 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" + v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" operatorscheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1" listers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1" + authentikapi "goauthentik.io/api/v3" ) const controllerAgentName = "proxy-provider-controller" @@ -56,8 +59,9 @@ const ( ) type Controller struct { - kubeclientset kubernetes.Interface - operatorclientset clientset.Interface + kubeclientset kubernetes.Interface + proxyProviderClientset clientset.Interface + authentik *authentikapi.APIClient deploymentsLister appslisters.DeploymentLister deploymentsSynced cache.InformerSynced @@ -71,7 +75,8 @@ type Controller struct { func NewController( ctx context.Context, kubeclientset kubernetes.Interface, - operatorclientset clientset.Interface, + proxyProviderClientset clientset.Interface, + authentik *authentikapi.APIClient, deploymentInformer appsinformers.DeploymentInformer, proxyInformer informers.ProxyProviderInformer, ) *Controller { @@ -90,14 +95,15 @@ func NewController( ) c := &Controller{ - kubeclientset: kubeclientset, - operatorclientset: operatorclientset, - deploymentsLister: deploymentInformer.Lister(), - deploymentsSynced: deploymentInformer.Informer().HasSynced, - proxyLister: proxyInformer.Lister(), - proxySynced: proxyInformer.Informer().HasSynced, - workqueue: workqueue.NewTypedRateLimitingQueue(ratelimiter), - recorder: recorder, + kubeclientset: kubeclientset, + proxyProviderClientset: proxyProviderClientset, + authentik: authentik, + deploymentsLister: deploymentInformer.Lister(), + deploymentsSynced: deploymentInformer.Informer().HasSynced, + proxyLister: proxyInformer.Lister(), + proxySynced: proxyInformer.Informer().HasSynced, + workqueue: workqueue.NewTypedRateLimitingQueue(ratelimiter), + recorder: recorder, } logger.Info("Setting up event handlers") @@ -181,8 +187,55 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName } return err } - logger.V(4).Info("sync ProxyProvider", "name", pp.Name) + + if pp.Status.PK != "" { + // We retrieve the existing PP from the API by slug. + pk, err := strconv.ParseInt(pp.Status.PK, 10, 32) + if err != nil { + return fmt.Errorf("error parsing PK: %v", err) + } + _, _, err = c.authentik.ProvidersApi.ProvidersAllRetrieve(ctx, int32(pk)).Execute() + if err != nil { + return fmt.Errorf("error retrieving existing ProxyProvider: %v", err) + } + + // We update the existing PP with the new spec. + proxyProviderRequest := &authentikapi.ProxyProviderRequest{ + Name: pp.Spec.Name, + AuthorizationFlow: pp.Spec.AuthorizationFlow, + InvalidationFlow: pp.Spec.InvalidationFlow, + ExternalHost: pp.Spec.ExternalHost, + Mode: authentikapi.PROXYMODE_FORWARD_SINGLE.Ptr(), + } + resp, r, err := c.authentik.ProvidersApi.ProvidersProxyUpdate(ctx, int32(pk)).ProxyProviderRequest(*proxyProviderRequest).Execute() + if err != nil { + return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyUpdate`: %w with response %v", err, r) + } + pp.Status.PK = strconv.Itoa(int(resp.Pk)) + err = c.updateProxyProviderStatus(ctx, pp) + if err != nil { + return fmt.Errorf("error updating ProxyProvider status: %v", err) + } + } else { + proxyProviderRequest := &authentikapi.ProxyProviderRequest{ + Name: pp.Spec.Name, + AuthorizationFlow: pp.Spec.AuthorizationFlow, + InvalidationFlow: pp.Spec.InvalidationFlow, + ExternalHost: pp.Spec.ExternalHost, + Mode: authentikapi.PROXYMODE_FORWARD_SINGLE.Ptr(), + } + resp, r, err := c.authentik.ProvidersApi.ProvidersProxyCreate(ctx).ProxyProviderRequest(*proxyProviderRequest).Execute() + if err != nil { + return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyCreate`: %w with response %v", err, r) + } + pp.Status.PK = strconv.Itoa(int(resp.Pk)) + err = c.updateProxyProviderStatus(ctx, pp) + if err != nil { + return fmt.Errorf("error updating ProxyProvider status: %v", err) + } + } + return nil } @@ -211,3 +264,10 @@ func (c *Controller) handleObject(obj interface{}) { } } } + +func (c *Controller) updateProxyProviderStatus(ctx context.Context, pp *v1.ProxyProvider) error { + ppCopy := pp.DeepCopy() + ppCopy.Status.PK = pp.Status.PK + _, err := c.proxyProviderClientset.ProxyproviderV1().ProxyProviders(pp.Namespace).UpdateStatus(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) + return err +} diff --git a/go.mod b/go.mod index 43b39a9..b6e9adc 100644 --- a/go.mod +++ b/go.mod @@ -5,14 +5,13 @@ go 1.26.3 godebug default=go1.26 require ( + goauthentik.io/api/v3 v3.2026020.16 golang.org/x/time v0.15.0 k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec k8s.io/apimachinery v0.0.0-20260513183604-f9371b815e42 k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940 - k8s.io/code-generator v0.0.0-20260509210052-5595d1310975 k8s.io/klog/v2 v2.140.0 k8s.io/kube-openapi v0.0.0-20260511211612-da4e56fe5676 - k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 sigs.k8s.io/structured-merge-diff/v6 v6.4.0 ) @@ -46,18 +45,15 @@ require ( github.com/x448/float16 v0.8.4 // indirect go.yaml.in/yaml/v2 v2.4.4 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/mod v0.35.0 // indirect golang.org/x/net v0.53.0 // indirect golang.org/x/oauth2 v0.36.0 // indirect - golang.org/x/sync v0.20.0 // indirect golang.org/x/sys v0.43.0 // indirect golang.org/x/term v0.42.0 // indirect golang.org/x/text v0.36.0 // indirect - golang.org/x/tools v0.44.0 // indirect google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - k8s.io/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3 // indirect + k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/yaml v1.6.0 // indirect diff --git a/go.sum b/go.sum index 24b1ea4..8e707e6 100644 --- a/go.sum +++ b/go.sum @@ -84,14 +84,12 @@ go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= -golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= +goauthentik.io/api/v3 v3.2026020.16 h1:sEqcVRXYSJTYaSdU5PzSEdFUWDqCONm5BeL62F5k+58= +goauthentik.io/api/v3 v3.2026020.16/go.mod h1:82lqAz4jxzl6Cg0YDbhNtvvTG2rm6605ZhdJFnbbsl8= golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA= golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= -golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= -golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI= golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.42.0 h1:UiKe+zDFmJobeJ5ggPwOshJIVt6/Ft0rcfrXZDLWAWY= @@ -100,12 +98,6 @@ golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg= golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164= golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= -golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= -golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= -golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= -golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= -golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= -golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -119,21 +111,12 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec h1:xf12Yh3ltN4fnNyP0CyyM0TwNVnZDfLJjV3+bf9fPFY= k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec/go.mod h1:C+fcNlNQ9TcKHspN+DD7UybdfnjDAGyBjfCd6W7ogbY= -k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5 h1:k2HBxRBq6w2QCj14oAhBosjMqqgNlj4dmLXFj8f1A+8= -k8s.io/apimachinery v0.0.0-20260509204146-64dfe1db2af5/go.mod h1:37ALVDWo0LgW74Y9rAdewmZo20SVCGGH34806wUMrko= k8s.io/apimachinery v0.0.0-20260513183604-f9371b815e42 h1:rWdGOTor3z0WSyZcRl9ms4dn9Cw9CqmNBqXuf2z0k1k= k8s.io/apimachinery v0.0.0-20260513183604-f9371b815e42/go.mod h1:hiubQ6UTHIdr0bS8ExXOJEywFVOoudnldm/l/NiNVlA= k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940 h1:n5t5Jx3VpLdiAGxIvIHsZDmsExtZVwghUPLM3wFi6Go= k8s.io/client-go v0.0.0-20260509205101-ca52b81a2940/go.mod h1:0e7OLwg7kdXISVFwn7ishFdvxfVgi7wsqHqsQPHl61w= -k8s.io/code-generator v0.0.0-20260509210052-5595d1310975 h1:hDrusFgTzvqcDJ7p13A9Eid4i8Y9uNSs/67lniaYHwM= -k8s.io/code-generator v0.0.0-20260509210052-5595d1310975/go.mod h1:mQXg0n0EeF4oU8aTwm9mzwoyAKqVRmUb9wLhjHnRq3I= -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/gengo/v2 v2.0.0-20260408192533-25e2208e0dc3/go.mod h1:yvyl3l9E+UxlqOMUULdKTAYB0rEhsmjr7+2Vb/1pCSo= k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= -k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b h1:WrpNVPKkCaOO9h77E1P2HLnhWDQxrxzpf2jfsM8WevY= -k8s.io/kube-openapi v0.0.0-20260509150519-312035bf509b/go.mod h1:V/QaCUYDa+0QpcHhVVc5l99Uz56wEMEXBSj9oCDkNDY= k8s.io/kube-openapi v0.0.0-20260511211612-da4e56fe5676 h1:ahjrVu/DBcaAhw/GcblfaOvvQ2wi8kqXWvn62nud3UU= k8s.io/kube-openapi v0.0.0-20260511211612-da4e56fe5676/go.mod h1:V/QaCUYDa+0QpcHhVVc5l99Uz56wEMEXBSj9oCDkNDY= k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 h1:AZYQSJemyQB5eRxqcPky+/7EdBj0xi3g0ZcxxJ7vbWU= @@ -142,8 +125,6 @@ sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5E sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= -sigs.k8s.io/structured-merge-diff/v6 v6.3.2 h1:kwVWMx5yS1CrnFWA/2QHyRVJ8jM6dBA80uLmm0wJkk8= -sigs.k8s.io/structured-merge-diff/v6 v6.3.2/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= sigs.k8s.io/structured-merge-diff/v6 v6.4.0 h1:qmp2e3ZfFi1/jJbDGpD4mt3wyp6PE1NfKHCYLqgNQJo= sigs.k8s.io/structured-merge-diff/v6 v6.4.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= diff --git a/main.go b/main.go index 58e139e..7351095 100644 --- a/main.go +++ b/main.go @@ -17,10 +17,14 @@ limitations under the License. package main import ( + "errors" "flag" + "net/url" + "os" "time" "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/signals" + authentikapi "goauthentik.io/api/v3" kubeinformers "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" @@ -58,23 +62,29 @@ func main() { klog.FlushAndExit(klog.ExitFlushTimeout, 1) } - operatorClient, err := clientset.NewForConfig(cfg) + proxyProviderClient, err := clientset.NewForConfig(cfg) if err != nil { - logger.Error(err, "Error building kubernetes clientset") + logger.Error(err, "Error building proxy provider clientset") + klog.FlushAndExit(klog.ExitFlushTimeout, 1) + } + + authentikClient, err := newAuthentikAPIClient(os.Getenv("AUTENTIK_HOST"), os.Getenv("AUTENTIK_TOKEN")) + if err != nil { + logger.Error(err, "Error building Authentik API client") klog.FlushAndExit(klog.ExitFlushTimeout, 1) } kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30) - operatorInformerFactory := informers.NewSharedInformerFactory(operatorClient, time.Second*30) + proxyProviderInformerFactory := informers.NewSharedInformerFactory(proxyProviderClient, time.Second*30) - controller := NewController(ctx, kubeClient, operatorClient, + controller := NewController(ctx, kubeClient, proxyProviderClient, authentikClient, kubeInformerFactory.Apps().V1().Deployments(), - operatorInformerFactory.Proxyprovider().V1().ProxyProviders()) + proxyProviderInformerFactory.Proxyprovider().V1().ProxyProviders()) // notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(ctx.done()) // Start method is non-blocking and runs all registered informers in a dedicated goroutine. kubeInformerFactory.Start(ctx.Done()) - operatorInformerFactory.Start(ctx.Done()) + proxyProviderInformerFactory.Start(ctx.Done()) if err = controller.Run(ctx, 2); err != nil { logger.Error(err, "Error running controller") @@ -86,3 +96,27 @@ func init() { flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.") flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.") } + +// newAuthentikAPIClient builds the OpenAPI-generated goauthentik client when AUTENTIK_HOST is set. +func newAuthentikAPIClient(host, token string) (*authentikapi.APIClient, error) { + if host == "" { + return nil, errors.New("authentik host is not set") + } + cfg := authentikapi.NewConfiguration() + if u, err := url.Parse(host); err == nil && u.Host != "" { + cfg.Scheme = u.Scheme + if cfg.Scheme == "" { + cfg.Scheme = "https" + } + cfg.Host = u.Host + } else { + cfg.Scheme = "https" + cfg.Host = host + } + if token == "" { + return nil, errors.New("authentik token is not set") + } + cfg.AddDefaultHeader("Authorization", "Bearer "+token) + + return authentikapi.NewAPIClient(cfg), nil +} diff --git a/pkg/apis/proxyprovider/v1/types.go b/pkg/apis/proxyprovider/v1/types.go index b0a4afa..c662c69 100644 --- a/pkg/apis/proxyprovider/v1/types.go +++ b/pkg/apis/proxyprovider/v1/types.go @@ -21,6 +21,7 @@ import ( ) // +genclient +// +kubebuilder:subresource:status // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type ProxyProvider struct { -- 2.52.0 From 2753647d01bb29a218ecae0def00ffecab2d4c9f Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Fri, 15 May 2026 11:28:26 +0200 Subject: [PATCH 04/14] remove unused deployment listener --- controller.go | 26 +++----------------------- main.go | 7 ++----- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/controller.go b/controller.go index d5f06c6..f781023 100644 --- a/controller.go +++ b/controller.go @@ -24,17 +24,14 @@ import ( "golang.org/x/time/rate" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" - appsinformers "k8s.io/client-go/informers/apps/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - appslisters "k8s.io/client-go/listers/apps/v1" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" @@ -63,10 +60,8 @@ type Controller struct { proxyProviderClientset clientset.Interface authentik *authentikapi.APIClient - deploymentsLister appslisters.DeploymentLister - deploymentsSynced cache.InformerSynced - proxyLister listers.ProxyProviderLister - proxySynced cache.InformerSynced + proxyLister listers.ProxyProviderLister + proxySynced cache.InformerSynced workqueue workqueue.TypedRateLimitingInterface[cache.ObjectName] recorder record.EventRecorder @@ -77,7 +72,6 @@ func NewController( kubeclientset kubernetes.Interface, proxyProviderClientset clientset.Interface, authentik *authentikapi.APIClient, - deploymentInformer appsinformers.DeploymentInformer, proxyInformer informers.ProxyProviderInformer, ) *Controller { logger := klog.FromContext(ctx) @@ -98,8 +92,6 @@ func NewController( kubeclientset: kubeclientset, proxyProviderClientset: proxyProviderClientset, authentik: authentik, - deploymentsLister: deploymentInformer.Lister(), - deploymentsSynced: deploymentInformer.Informer().HasSynced, proxyLister: proxyInformer.Lister(), proxySynced: proxyInformer.Informer().HasSynced, workqueue: workqueue.NewTypedRateLimitingQueue(ratelimiter), @@ -113,18 +105,6 @@ func NewController( c.enqueueProxyProvider(newObj) }, }) - deploymentInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ - AddFunc: c.handleObject, - UpdateFunc: func(old, new interface{}) { - newDepl := new.(*appsv1.Deployment) - oldDepl := old.(*appsv1.Deployment) - if newDepl.ResourceVersion == oldDepl.ResourceVersion { - return - } - c.handleObject(new) - }, - DeleteFunc: c.handleObject, - }) return c } @@ -137,7 +117,7 @@ func (c *Controller) Run(ctx context.Context, workers int) error { logger.Info("Starting ProxyProvider controller") logger.Info("Waiting for informer caches to sync") - if ok := cache.WaitForCacheSync(ctx.Done(), c.deploymentsSynced, c.proxySynced); !ok { + if ok := cache.WaitForCacheSync(ctx.Done(), c.proxySynced); !ok { return fmt.Errorf("failed to wait for caches to sync") } diff --git a/main.go b/main.go index 7351095..3bb6540 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,6 @@ import ( "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/signals" authentikapi "goauthentik.io/api/v3" - kubeinformers "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" @@ -74,16 +73,14 @@ func main() { klog.FlushAndExit(klog.ExitFlushTimeout, 1) } - kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30) proxyProviderInformerFactory := informers.NewSharedInformerFactory(proxyProviderClient, time.Second*30) controller := NewController(ctx, kubeClient, proxyProviderClient, authentikClient, - kubeInformerFactory.Apps().V1().Deployments(), - proxyProviderInformerFactory.Proxyprovider().V1().ProxyProviders()) + proxyProviderInformerFactory.Proxyprovider().V1().ProxyProviders(), + ) // notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(ctx.done()) // Start method is non-blocking and runs all registered informers in a dedicated goroutine. - kubeInformerFactory.Start(ctx.Done()) proxyProviderInformerFactory.Start(ctx.Done()) if err = controller.Run(ctx, 2); err != nil { -- 2.52.0 From dff5b5c9a1821490a5b26c907ee0113f898ed3b1 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Fri, 15 May 2026 19:00:47 +0200 Subject: [PATCH 05/14] refactor: switch to reconsiliation pattern --- artifacts/crd/crd.yaml | 2 + controller.go | 168 +++++++++++++++++++++++++---------------- 2 files changed, 107 insertions(+), 63 deletions(-) diff --git a/artifacts/crd/crd.yaml b/artifacts/crd/crd.yaml index 59cb9f9..8f46891 100644 --- a/artifacts/crd/crd.yaml +++ b/artifacts/crd/crd.yaml @@ -2,6 +2,8 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: proxyproviders.proxyprovider.t000-n.de + finalizers: + - proxyprovider.t000-n.de/delete-authentik-proxyprovider spec: group: proxyprovider.t000-n.de versions: diff --git a/controller.go b/controller.go index f781023..feda3f4 100644 --- a/controller.go +++ b/controller.go @@ -19,6 +19,8 @@ package main import ( "context" "fmt" + "net/http" + "slices" "strconv" "time" @@ -55,6 +57,11 @@ const ( FieldManager = controllerAgentName ) +// Finalizers +const ( + DeleteAuthentikProxyProviderFinalizer = "proxyprovider.t000-n.de/delete-authentik-proxyprovider" +) + type Controller struct { kubeclientset kubernetes.Interface proxyProviderClientset clientset.Interface @@ -169,54 +176,97 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName } logger.V(4).Info("sync ProxyProvider", "name", pp.Name) - if pp.Status.PK != "" { - // We retrieve the existing PP from the API by slug. - pk, err := strconv.ParseInt(pp.Status.PK, 10, 32) - if err != nil { - return fmt.Errorf("error parsing PK: %v", err) - } - _, _, err = c.authentik.ProvidersApi.ProvidersAllRetrieve(ctx, int32(pk)).Execute() - if err != nil { - return fmt.Errorf("error retrieving existing ProxyProvider: %v", err) - } + if !pp.ObjectMeta.DeletionTimestamp.IsZero() { + logger.Info("Reconciling deletion of ProxyProvider", "name", pp.Name) + return c.reconcileDelete(ctx, pp) + } - // We update the existing PP with the new spec. - proxyProviderRequest := &authentikapi.ProxyProviderRequest{ - Name: pp.Spec.Name, - AuthorizationFlow: pp.Spec.AuthorizationFlow, - InvalidationFlow: pp.Spec.InvalidationFlow, - ExternalHost: pp.Spec.ExternalHost, - Mode: authentikapi.PROXYMODE_FORWARD_SINGLE.Ptr(), - } - resp, r, err := c.authentik.ProvidersApi.ProvidersProxyUpdate(ctx, int32(pk)).ProxyProviderRequest(*proxyProviderRequest).Execute() - if err != nil { - return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyUpdate`: %w with response %v", err, r) - } - pp.Status.PK = strconv.Itoa(int(resp.Pk)) - err = c.updateProxyProviderStatus(ctx, pp) - if err != nil { - return fmt.Errorf("error updating ProxyProvider status: %v", err) - } - } else { - proxyProviderRequest := &authentikapi.ProxyProviderRequest{ - Name: pp.Spec.Name, - AuthorizationFlow: pp.Spec.AuthorizationFlow, - InvalidationFlow: pp.Spec.InvalidationFlow, - ExternalHost: pp.Spec.ExternalHost, - Mode: authentikapi.PROXYMODE_FORWARD_SINGLE.Ptr(), - } - resp, r, err := c.authentik.ProvidersApi.ProvidersProxyCreate(ctx).ProxyProviderRequest(*proxyProviderRequest).Execute() - if err != nil { - return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyCreate`: %w with response %v", err, r) - } - pp.Status.PK = strconv.Itoa(int(resp.Pk)) - err = c.updateProxyProviderStatus(ctx, pp) - if err != nil { - return fmt.Errorf("error updating ProxyProvider status: %v", err) + if pp.Status.PK == "" { + logger.Info("Reconciling creation of ProxyProvider", "name", pp.Name) + return c.reconcileCreate(ctx, pp) + } + + // Check if all finalizers are present. If not, we add them. Same pattern as above, just needs a helper function to check for presence of a finalizer. + if !slices.Contains(pp.ObjectMeta.Finalizers, DeleteAuthentikProxyProviderFinalizer) { + logger.Info("Ensuring finalizers are present", "name", pp.Name) + return c.ensureFinalizers(ctx, pp) + } + + logger.Info("Reconciling update of ProxyProvider", "name", pp.Name) + return c.reconcileUpdate(ctx, pp) +} + +func (c *Controller) ensureFinalizers(ctx context.Context, pp *v1.ProxyProvider) error { + pp.ObjectMeta.Finalizers = append(pp.ObjectMeta.Finalizers, DeleteAuthentikProxyProviderFinalizer) + return c.updateProxyProvider(ctx, pp) +} + +func (c *Controller) reconcileDelete(ctx context.Context, pp *v1.ProxyProvider) error { + pk, err := strconv.ParseInt(pp.Status.PK, 10, 32) + if err != nil { + return fmt.Errorf("error parsing PK: %v", err) + } + + r, err := c.authentik.ProvidersApi.ProvidersProxyDestroy(ctx, int32(pk)).Execute() + if err != nil { + // This handles an edge-case, where when the ProxyProvider on Authentik has already been deleted, but the finalizer is still present. We just remove the finalizer and return. + if r.StatusCode != http.StatusNotFound { + return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyDestroy`: %w with response %v", err, r) } } - return nil + pp.ObjectMeta.Finalizers = slices.Delete(pp.ObjectMeta.Finalizers, slices.Index(pp.ObjectMeta.Finalizers, DeleteAuthentikProxyProviderFinalizer), 1) + return c.updateProxyProvider(ctx, pp) +} + +func (c *Controller) reconcileUpdate(ctx context.Context, pp *v1.ProxyProvider) error { + // We retrieve the existing PP from the API by slug. + pk, err := strconv.ParseInt(pp.Status.PK, 10, 32) + if err != nil { + return fmt.Errorf("error parsing PK: %v", err) + } + _, r, err := c.authentik.ProvidersApi.ProvidersAllRetrieve(ctx, int32(pk)).Execute() + if err != nil && r.StatusCode != http.StatusNotFound { + + return fmt.Errorf("error retrieving existing ProxyProvider: %v with response %v", err, r) + } else if r.StatusCode == http.StatusNotFound { + // This handles an edge-case, where when the PorxyProvider on Authentik has been deleted, e.g. by mistake. We just remove the PK and return. + // During the next reconciliation, the ProxyProvider will be re-created. + pp.Status.PK = "" + } + + proxyProviderRequest := &authentikapi.PatchedProxyProviderRequest{ + Name: &pp.Spec.Name, + AuthorizationFlow: &pp.Spec.AuthorizationFlow, + InvalidationFlow: &pp.Spec.InvalidationFlow, + ExternalHost: &pp.Spec.ExternalHost, + Mode: authentikapi.PROXYMODE_FORWARD_SINGLE.Ptr(), + } + resp, r, err := c.authentik.ProvidersApi.ProvidersProxyPartialUpdate(ctx, int32(pk)).PatchedProxyProviderRequest(*proxyProviderRequest).Execute() + if err != nil { + return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyPartialUpdate`: %w with response %v", err, r) + } + + pp.Status.PK = strconv.Itoa(int(resp.Pk)) + + return c.updateProxyProviderStatus(ctx, pp) +} + +func (c *Controller) reconcileCreate(ctx context.Context, pp *v1.ProxyProvider) error { + proxyProviderRequest := &authentikapi.ProxyProviderRequest{ + Name: pp.Spec.Name, + AuthorizationFlow: pp.Spec.AuthorizationFlow, + InvalidationFlow: pp.Spec.InvalidationFlow, + ExternalHost: pp.Spec.ExternalHost, + Mode: authentikapi.PROXYMODE_FORWARD_SINGLE.Ptr(), + } + resp, r, err := c.authentik.ProvidersApi.ProvidersProxyCreate(ctx).ProxyProviderRequest(*proxyProviderRequest).Execute() + if err != nil { + return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyCreate`: %w with response %v", err, r) + } + + pp.Status.PK = strconv.Itoa(int(resp.Pk)) + return c.updateProxyProviderStatus(ctx, pp) } func (c *Controller) enqueueProxyProvider(obj interface{}) { @@ -228,26 +278,18 @@ func (c *Controller) enqueueProxyProvider(obj interface{}) { c.workqueue.Add(objectRef) } -func (c *Controller) handleObject(obj interface{}) { - // Optional: resolve Deployment owners back to ProxyProvider and enqueue. - _, ok := obj.(metav1.Object) - if !ok { - tombstone, ok := obj.(cache.DeletedFinalStateUnknown) - if !ok { - utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj)) - return - } - _, ok = tombstone.Obj.(metav1.Object) - if !ok { - utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a metav1.Object %#v", obj)) - return - } - } -} - func (c *Controller) updateProxyProviderStatus(ctx context.Context, pp *v1.ProxyProvider) error { ppCopy := pp.DeepCopy() - ppCopy.Status.PK = pp.Status.PK - _, err := c.proxyProviderClientset.ProxyproviderV1().ProxyProviders(pp.Namespace).UpdateStatus(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) + _, err := c.proxyProviderClientset.ProxyproviderV1().ProxyProviders(ppCopy.Namespace).UpdateStatus(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) return err } + +// Update metadata, spec, etc. of the ProxyProvider object. +func (c *Controller) updateProxyProvider(ctx context.Context, pp *v1.ProxyProvider) error { + ppCopy := pp.DeepCopy() + _, err := c.proxyProviderClientset.ProxyproviderV1().ProxyProviders(ppCopy.Namespace).Update(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) + if err != nil { + return fmt.Errorf("error updating ProxyProvider metadata: %v", err) + } + return nil +} -- 2.52.0 From d926b3b4b1ad12e8571534d067f8b10b89bf1a35 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Fri, 15 May 2026 19:01:18 +0200 Subject: [PATCH 06/14] chore: add delve debugging artifacts to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dc7f41b..5f56073 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ vendor/ # build artifacts main +__debug_bin* -- 2.52.0 From 4f6910c809111623eb75992f4a9038a34472022d Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sat, 16 May 2026 19:28:24 +0200 Subject: [PATCH 07/14] docs --- README.md | 34 ++++++++++++++++++- .../crd/{crd.yaml => proxyProvider.yaml} | 0 2 files changed, 33 insertions(+), 1 deletion(-) rename artifacts/crd/{crd.yaml => proxyProvider.yaml} (100%) diff --git a/README.md b/README.md index 0ea4c10..6bd3580 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,36 @@ Authentik Kubernetes Operator allows to manage Authentik resources directly in Kubernetes using Custom Kubernetes Resources. -## Features +The custom resources of this operator ultimately will mirror the Authentik resources. New resources will be added as there is a need for them. + +Manual changes to the resources in Authentik will be overwritten by the operator. So always manage the resources in Kubernetes. + +## Custom Resources + +| Custom Resource | CRD File | Short Name | +| --------------- | ---------------------------------------------------------- | ---------- | +| ProxyProvider | [`proxyProvider.yaml`](`artifacts/crd/proxyProvider.yaml`) | pp | + +### ProxyProvider + +Currently only the "Forward Single" ProxyProvider is supported and only a reduced set of fields are exposed by the custom resources. + +Example [`proxyProvider.yaml`](`artifacts/examples/proxyProvider.yaml`): + +```yaml +apiVersion: proxyprovider.t000-n.de/v1 +kind: ProxyProvider +metadata: + name: proxy-provider-example + namespace: kube-system +spec: + name: proxy-provider-example + # The ID of the authorization flow. In this example: "default-provider-authorization-implicit-consent (Authorize Application)" + authorization_flow: 16896c6d-b326-42d1-8d3f-93f32921962e + # The ID of the invalidation flow. In this example: "default-provider-invalidation-flow (Logged out of application)" + invalidation_flow: 7acac1ef-19e3-4a6f-8d8d-14ca7031d184 + # The external host of your application. + external_host: https://example.t00n.de +``` + +The ProxyProvider will be created in Authentik, but will not be assigned to an outpost or an application (Resources are TBD). diff --git a/artifacts/crd/crd.yaml b/artifacts/crd/proxyProvider.yaml similarity index 100% rename from artifacts/crd/crd.yaml rename to artifacts/crd/proxyProvider.yaml -- 2.52.0 From 9b0d6a32799ceada43ddd4f697ab08aadfc39738 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sat, 16 May 2026 19:35:46 +0200 Subject: [PATCH 08/14] change v1 to v1alpha1 --- README.md | 6 +- artifacts/crd/proxyProvider.yaml | 2 +- artifacts/examples/proxyProvider.yaml | 2 +- controller.go | 22 +++--- .../codegen_violation_exceptions.list | 6 +- main.go | 2 +- .../proxyprovider/{v1 => v1alpha1}/doc.go | 2 +- .../proxyprovider/{v1 => v1alpha1}/types.go | 2 +- .../{v1 => v1alpha1}/zz_generated.deepcopy.go | 2 +- .../{v1 => v1alpha1}/zz_generated.register.go | 10 +-- .../{v1 => v1alpha1}/proxyprovider.go | 24 +++--- .../{v1 => v1alpha1}/proxyproviderspec.go | 2 +- .../{v1 => v1alpha1}/proxyproviderstatus.go | 2 +- pkg/generated/applyconfiguration/utils.go | 18 ++--- .../clientset/versioned/clientset.go | 16 ++-- .../versioned/fake/clientset_generated.go | 10 +-- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../v1/fake/fake_proxyprovider.go | 51 ------------- .../typed/proxyprovider/v1/proxyprovider.go | 74 ------------------- .../proxyprovider/{v1 => v1alpha1}/doc.go | 2 +- .../{v1 => v1alpha1}/fake/doc.go | 0 .../v1alpha1/fake/fake_proxyprovider.go | 53 +++++++++++++ .../fake/fake_proxyprovider_client.go | 8 +- .../{v1 => v1alpha1}/generated_expansion.go | 2 +- .../proxyprovider/v1alpha1/proxyprovider.go | 74 +++++++++++++++++++ .../{v1 => v1alpha1}/proxyprovider_client.go | 36 ++++----- .../informers/externalversions/generic.go | 8 +- .../proxyprovider/interface.go | 12 +-- .../{v1 => v1alpha1}/interface.go | 2 +- .../{v1 => v1alpha1}/proxyprovider.go | 36 ++++----- .../{v1 => v1alpha1}/expansion_generated.go | 2 +- .../{v1 => v1alpha1}/proxyprovider.go | 18 ++--- pkg/generated/openapi/zz_generated.openapi.go | 26 +++---- 34 files changed, 273 insertions(+), 267 deletions(-) rename pkg/apis/proxyprovider/{v1 => v1alpha1}/doc.go (97%) rename pkg/apis/proxyprovider/{v1 => v1alpha1}/types.go (98%) rename pkg/apis/proxyprovider/{v1 => v1alpha1}/zz_generated.deepcopy.go (99%) rename pkg/apis/proxyprovider/{v1 => v1alpha1}/zz_generated.register.go (91%) rename pkg/generated/applyconfiguration/proxyprovider/{v1 => v1alpha1}/proxyprovider.go (93%) rename pkg/generated/applyconfiguration/proxyprovider/{v1 => v1alpha1}/proxyproviderspec.go (99%) rename pkg/generated/applyconfiguration/proxyprovider/{v1 => v1alpha1}/proxyproviderstatus.go (98%) delete mode 100644 pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go delete mode 100644 pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go rename pkg/generated/clientset/versioned/typed/proxyprovider/{v1 => v1alpha1}/doc.go (97%) rename pkg/generated/clientset/versioned/typed/proxyprovider/{v1 => v1alpha1}/fake/doc.go (100%) create mode 100644 pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider.go rename pkg/generated/clientset/versioned/typed/proxyprovider/{v1 => v1alpha1}/fake/fake_proxyprovider_client.go (73%) rename pkg/generated/clientset/versioned/typed/proxyprovider/{v1 => v1alpha1}/generated_expansion.go (97%) create mode 100644 pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider.go rename pkg/generated/clientset/versioned/typed/proxyprovider/{v1 => v1alpha1}/proxyprovider_client.go (63%) rename pkg/generated/informers/externalversions/proxyprovider/{v1 => v1alpha1}/interface.go (98%) rename pkg/generated/informers/externalversions/proxyprovider/{v1 => v1alpha1}/proxyprovider.go (75%) rename pkg/generated/listers/proxyprovider/{v1 => v1alpha1}/expansion_generated.go (98%) rename pkg/generated/listers/proxyprovider/{v1 => v1alpha1}/proxyprovider.go (76%) diff --git a/README.md b/README.md index 6bd3580..352e121 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Currently only the "Forward Single" ProxyProvider is supported and only a reduce Example [`proxyProvider.yaml`](`artifacts/examples/proxyProvider.yaml`): ```yaml -apiVersion: proxyprovider.t000-n.de/v1 +apiVersion: proxyprovider.t000-n.de/v1alpha1 kind: ProxyProvider metadata: name: proxy-provider-example @@ -35,3 +35,7 @@ spec: ``` The ProxyProvider will be created in Authentik, but will not be assigned to an outpost or an application (Resources are TBD). + +## Versioning + +As soon as the operator covers an entire use case, the version will be raised to v1 and follow default versioning rules. Before that, the version will be v1alpha1. diff --git a/artifacts/crd/proxyProvider.yaml b/artifacts/crd/proxyProvider.yaml index 8f46891..9333950 100644 --- a/artifacts/crd/proxyProvider.yaml +++ b/artifacts/crd/proxyProvider.yaml @@ -7,7 +7,7 @@ metadata: spec: group: proxyprovider.t000-n.de versions: - - name: v1 + - name: v1alpha1 served: true storage: true subresources: diff --git a/artifacts/examples/proxyProvider.yaml b/artifacts/examples/proxyProvider.yaml index 94e55d7..5de4a22 100644 --- a/artifacts/examples/proxyProvider.yaml +++ b/artifacts/examples/proxyProvider.yaml @@ -1,5 +1,5 @@ # Example ProxyProvider CRD -apiVersion: proxyprovider.t000-n.de/v1 +apiVersion: proxyprovider.t000-n.de/v1alpha1 kind: ProxyProvider metadata: name: proxy-provider-example diff --git a/controller.go b/controller.go index feda3f4..a1dbd81 100644 --- a/controller.go +++ b/controller.go @@ -39,11 +39,11 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" - v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" operatorscheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" - informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1" - listers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1" + informers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1alpha1" + listers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1alpha1" authentikapi "goauthentik.io/api/v3" ) @@ -196,12 +196,12 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName return c.reconcileUpdate(ctx, pp) } -func (c *Controller) ensureFinalizers(ctx context.Context, pp *v1.ProxyProvider) error { +func (c *Controller) ensureFinalizers(ctx context.Context, pp *v1alpha1.ProxyProvider) error { pp.ObjectMeta.Finalizers = append(pp.ObjectMeta.Finalizers, DeleteAuthentikProxyProviderFinalizer) return c.updateProxyProvider(ctx, pp) } -func (c *Controller) reconcileDelete(ctx context.Context, pp *v1.ProxyProvider) error { +func (c *Controller) reconcileDelete(ctx context.Context, pp *v1alpha1.ProxyProvider) error { pk, err := strconv.ParseInt(pp.Status.PK, 10, 32) if err != nil { return fmt.Errorf("error parsing PK: %v", err) @@ -219,7 +219,7 @@ func (c *Controller) reconcileDelete(ctx context.Context, pp *v1.ProxyProvider) return c.updateProxyProvider(ctx, pp) } -func (c *Controller) reconcileUpdate(ctx context.Context, pp *v1.ProxyProvider) error { +func (c *Controller) reconcileUpdate(ctx context.Context, pp *v1alpha1.ProxyProvider) error { // We retrieve the existing PP from the API by slug. pk, err := strconv.ParseInt(pp.Status.PK, 10, 32) if err != nil { @@ -252,7 +252,7 @@ func (c *Controller) reconcileUpdate(ctx context.Context, pp *v1.ProxyProvider) return c.updateProxyProviderStatus(ctx, pp) } -func (c *Controller) reconcileCreate(ctx context.Context, pp *v1.ProxyProvider) error { +func (c *Controller) reconcileCreate(ctx context.Context, pp *v1alpha1.ProxyProvider) error { proxyProviderRequest := &authentikapi.ProxyProviderRequest{ Name: pp.Spec.Name, AuthorizationFlow: pp.Spec.AuthorizationFlow, @@ -278,16 +278,16 @@ func (c *Controller) enqueueProxyProvider(obj interface{}) { c.workqueue.Add(objectRef) } -func (c *Controller) updateProxyProviderStatus(ctx context.Context, pp *v1.ProxyProvider) error { +func (c *Controller) updateProxyProviderStatus(ctx context.Context, pp *v1alpha1.ProxyProvider) error { ppCopy := pp.DeepCopy() - _, err := c.proxyProviderClientset.ProxyproviderV1().ProxyProviders(ppCopy.Namespace).UpdateStatus(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) + _, err := c.proxyProviderClientset.ProxyproviderV1alpha1().ProxyProviders(ppCopy.Namespace).UpdateStatus(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) return err } // Update metadata, spec, etc. of the ProxyProvider object. -func (c *Controller) updateProxyProvider(ctx context.Context, pp *v1.ProxyProvider) error { +func (c *Controller) updateProxyProvider(ctx context.Context, pp *v1alpha1.ProxyProvider) error { ppCopy := pp.DeepCopy() - _, err := c.proxyProviderClientset.ProxyproviderV1().ProxyProviders(ppCopy.Namespace).Update(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) + _, err := c.proxyProviderClientset.ProxyproviderV1alpha1().ProxyProviders(ppCopy.Namespace).Update(ctx, ppCopy, metav1.UpdateOptions{FieldManager: FieldManager}) if err != nil { return fmt.Errorf("error updating ProxyProvider metadata: %v", err) } diff --git a/hack/api-violations/codegen_violation_exceptions.list b/hack/api-violations/codegen_violation_exceptions.list index 249ee25..51eec1c 100644 --- a/hack/api-violations/codegen_violation_exceptions.list +++ b/hack/api-violations/codegen_violation_exceptions.list @@ -1,6 +1,6 @@ -API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1,ProxyProviderSpec,AuthorizationFlow -API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1,ProxyProviderSpec,ExternalHost -API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1,ProxyProviderSpec,InvalidationFlow +API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1,ProxyProviderSpec,AuthorizationFlow +API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1,ProxyProviderSpec,ExternalHost +API rule violation: names_match,gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1,ProxyProviderSpec,InvalidationFlow API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,Format API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,d API rule violation: names_match,k8s.io/apimachinery/pkg/api/resource,Quantity,i diff --git a/main.go b/main.go index 3bb6540..da14215 100644 --- a/main.go +++ b/main.go @@ -76,7 +76,7 @@ func main() { proxyProviderInformerFactory := informers.NewSharedInformerFactory(proxyProviderClient, time.Second*30) controller := NewController(ctx, kubeClient, proxyProviderClient, authentikClient, - proxyProviderInformerFactory.Proxyprovider().V1().ProxyProviders(), + proxyProviderInformerFactory.Proxyprovider().V1alpha1().ProxyProviders(), ) // notice that there is no need to run Start methods in a separate goroutine. (i.e. go kubeInformerFactory.Start(ctx.done()) diff --git a/pkg/apis/proxyprovider/v1/doc.go b/pkg/apis/proxyprovider/v1alpha1/doc.go similarity index 97% rename from pkg/apis/proxyprovider/v1/doc.go rename to pkg/apis/proxyprovider/v1alpha1/doc.go index 408cb35..29a860f 100644 --- a/pkg/apis/proxyprovider/v1/doc.go +++ b/pkg/apis/proxyprovider/v1alpha1/doc.go @@ -19,4 +19,4 @@ limitations under the License. // +groupName=proxyprovider.t000-n.de // Package v1 is the v1 version of the API. -package v1 +package v1alpha1 diff --git a/pkg/apis/proxyprovider/v1/types.go b/pkg/apis/proxyprovider/v1alpha1/types.go similarity index 98% rename from pkg/apis/proxyprovider/v1/types.go rename to pkg/apis/proxyprovider/v1alpha1/types.go index c662c69..f328cd4 100644 --- a/pkg/apis/proxyprovider/v1/types.go +++ b/pkg/apis/proxyprovider/v1alpha1/types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1 +package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apis/proxyprovider/v1/zz_generated.deepcopy.go b/pkg/apis/proxyprovider/v1alpha1/zz_generated.deepcopy.go similarity index 99% rename from pkg/apis/proxyprovider/v1/zz_generated.deepcopy.go rename to pkg/apis/proxyprovider/v1alpha1/zz_generated.deepcopy.go index 27be419..58b7917 100644 --- a/pkg/apis/proxyprovider/v1/zz_generated.deepcopy.go +++ b/pkg/apis/proxyprovider/v1alpha1/zz_generated.deepcopy.go @@ -19,7 +19,7 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( runtime "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/apis/proxyprovider/v1/zz_generated.register.go b/pkg/apis/proxyprovider/v1alpha1/zz_generated.register.go similarity index 91% rename from pkg/apis/proxyprovider/v1/zz_generated.register.go rename to pkg/apis/proxyprovider/v1alpha1/zz_generated.register.go index 236a8cb..4efaced 100644 --- a/pkg/apis/proxyprovider/v1/zz_generated.register.go +++ b/pkg/apis/proxyprovider/v1alpha1/zz_generated.register.go @@ -19,10 +19,10 @@ limitations under the License. // Code generated by register-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -31,12 +31,12 @@ import ( const GroupName = "proxyprovider.t000-n.de" // GroupVersion specifies the group and the version used to register the objects. -var GroupVersion = metav1.GroupVersion{Group: GroupName, Version: "v1"} +var GroupVersion = v1.GroupVersion{Group: GroupName, Version: "v1alpha1"} // SchemeGroupVersion is group version used to register these objects // // Deprecated: use GroupVersion instead. -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1"} +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} // Resource takes an unqualified resource and returns a Group qualified GroupResource func Resource(resource string) schema.GroupResource { @@ -66,6 +66,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ProxyProviderList{}, ) // AddToGroupVersion allows the serialization of client types like ListOptions. - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + v1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil } diff --git a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyprovider.go b/pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyprovider.go similarity index 93% rename from pkg/generated/applyconfiguration/proxyprovider/v1/proxyprovider.go rename to pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyprovider.go index 97b5dd5..83dd035 100644 --- a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyprovider.go +++ b/pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyprovider.go @@ -16,21 +16,21 @@ limitations under the License. // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( - apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" - metav1 "k8s.io/client-go/applyconfigurations/meta/v1" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) // ProxyProviderApplyConfiguration represents a declarative configuration of the ProxyProvider type for use // with apply. type ProxyProviderApplyConfiguration struct { - metav1.TypeMetaApplyConfiguration `json:""` - *metav1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *ProxyProviderSpecApplyConfiguration `json:"spec,omitempty"` - Status *ProxyProviderStatusApplyConfiguration `json:"status,omitempty"` + v1.TypeMetaApplyConfiguration `json:""` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *ProxyProviderSpecApplyConfiguration `json:"spec,omitempty"` + Status *ProxyProviderStatusApplyConfiguration `json:"status,omitempty"` } // ProxyProvider constructs a declarative configuration of the ProxyProvider type for use with @@ -40,7 +40,7 @@ func ProxyProvider(name, namespace string) *ProxyProviderApplyConfiguration { b.WithName(name) b.WithNamespace(namespace) b.WithKind("ProxyProvider") - b.WithAPIVersion("proxyprovider.t000-n.de/v1") + b.WithAPIVersion("proxyprovider.t000-n.de/v1alpha1") return b } @@ -119,7 +119,7 @@ func (b *ProxyProviderApplyConfiguration) WithGeneration(value int64) *ProxyProv // 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 *ProxyProviderApplyConfiguration) WithCreationTimestamp(value apismetav1.Time) *ProxyProviderApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.CreationTimestamp = &value return b @@ -128,7 +128,7 @@ func (b *ProxyProviderApplyConfiguration) WithCreationTimestamp(value apismetav1 // 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 *ProxyProviderApplyConfiguration) WithDeletionTimestamp(value apismetav1.Time) *ProxyProviderApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value return b @@ -176,7 +176,7 @@ func (b *ProxyProviderApplyConfiguration) WithAnnotations(entries map[string]str // 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 *ProxyProviderApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *ProxyProviderApplyConfiguration { +func (b *ProxyProviderApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ProxyProviderApplyConfiguration { b.ensureObjectMetaApplyConfigurationExists() for i := range values { if values[i] == nil { @@ -200,7 +200,7 @@ func (b *ProxyProviderApplyConfiguration) WithFinalizers(values ...string) *Prox func (b *ProxyProviderApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { if b.ObjectMetaApplyConfiguration == nil { - b.ObjectMetaApplyConfiguration = &metav1.ObjectMetaApplyConfiguration{} + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} } } diff --git a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go b/pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyproviderspec.go similarity index 99% rename from pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go rename to pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyproviderspec.go index 9b9838d..c3f060b 100644 --- a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderspec.go +++ b/pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyproviderspec.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1 +package v1alpha1 // ProxyProviderSpecApplyConfiguration represents a declarative configuration of the ProxyProviderSpec type for use // with apply. diff --git a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go b/pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyproviderstatus.go similarity index 98% rename from pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go rename to pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyproviderstatus.go index 1527289..5172c6d 100644 --- a/pkg/generated/applyconfiguration/proxyprovider/v1/proxyproviderstatus.go +++ b/pkg/generated/applyconfiguration/proxyprovider/v1alpha1/proxyproviderstatus.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1 +package v1alpha1 // ProxyProviderStatusApplyConfiguration represents a declarative configuration of the ProxyProviderStatus type for use // with apply. diff --git a/pkg/generated/applyconfiguration/utils.go b/pkg/generated/applyconfiguration/utils.go index da6a1aa..8162829 100644 --- a/pkg/generated/applyconfiguration/utils.go +++ b/pkg/generated/applyconfiguration/utils.go @@ -19,9 +19,9 @@ limitations under the License. package applyconfiguration import ( - v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" internal "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/internal" - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1alpha1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" managedfields "k8s.io/apimachinery/pkg/util/managedfields" @@ -31,13 +31,13 @@ import ( // apply configuration type exists for the given GroupVersionKind. func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { - // Group=proxyprovider.t000-n.de, Version=v1 - case v1.SchemeGroupVersion.WithKind("ProxyProvider"): - return &proxyproviderv1.ProxyProviderApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("ProxyProviderSpec"): - return &proxyproviderv1.ProxyProviderSpecApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("ProxyProviderStatus"): - return &proxyproviderv1.ProxyProviderStatusApplyConfiguration{} + // Group=proxyprovider.t000-n.de, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("ProxyProvider"): + return &proxyproviderv1alpha1.ProxyProviderApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ProxyProviderSpec"): + return &proxyproviderv1alpha1.ProxyProviderSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ProxyProviderStatus"): + return &proxyproviderv1alpha1.ProxyProviderStatusApplyConfiguration{} } return nil diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 02a0897..adbd398 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -22,7 +22,7 @@ import ( fmt "fmt" http "net/http" - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,18 +30,18 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - ProxyproviderV1() proxyproviderv1.ProxyproviderV1Interface + ProxyproviderV1alpha1() proxyproviderv1alpha1.ProxyproviderV1alpha1Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient - proxyproviderV1 *proxyproviderv1.ProxyproviderV1Client + proxyproviderV1alpha1 *proxyproviderv1alpha1.ProxyproviderV1alpha1Client } -// ProxyproviderV1 retrieves the ProxyproviderV1Client -func (c *Clientset) ProxyproviderV1() proxyproviderv1.ProxyproviderV1Interface { - return c.proxyproviderV1 +// ProxyproviderV1alpha1 retrieves the ProxyproviderV1alpha1Client +func (c *Clientset) ProxyproviderV1alpha1() proxyproviderv1alpha1.ProxyproviderV1alpha1Interface { + return c.proxyproviderV1alpha1 } // Discovery retrieves the DiscoveryClient @@ -88,7 +88,7 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error - cs.proxyproviderV1, err = proxyproviderv1.NewForConfigAndClient(&configShallowCopy, httpClient) + cs.proxyproviderV1alpha1, err = proxyproviderv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -113,7 +113,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.proxyproviderV1 = proxyproviderv1.New(c) + cs.proxyproviderV1alpha1 = proxyproviderv1alpha1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 8651721..a99c5f4 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -21,8 +21,8 @@ package fake import ( applyconfiguration "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration" clientset "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" - fakeproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1" + fakeproxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" @@ -136,7 +136,7 @@ var ( _ testing.FakeClient = &Clientset{} ) -// ProxyproviderV1 retrieves the ProxyproviderV1Client -func (c *Clientset) ProxyproviderV1() proxyproviderv1.ProxyproviderV1Interface { - return &fakeproxyproviderv1.FakeProxyproviderV1{Fake: &c.Fake} +// ProxyproviderV1alpha1 retrieves the ProxyproviderV1alpha1Client +func (c *Clientset) ProxyproviderV1alpha1() proxyproviderv1alpha1.ProxyproviderV1alpha1Interface { + return &fakeproxyproviderv1alpha1.FakeProxyproviderV1alpha1{Fake: &c.Fake} } diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 8a725b8..8430976 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -19,7 +19,7 @@ limitations under the License. package fake import ( - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - proxyproviderv1.AddToScheme, + proxyproviderv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index 098bade..08428df 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -19,7 +19,7 @@ limitations under the License. package scheme import ( - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -31,7 +31,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - proxyproviderv1.AddToScheme, + proxyproviderv1alpha1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go deleted file mode 100644 index 575e1c9..0000000 --- a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1" - typedproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" - gentype "k8s.io/client-go/gentype" -) - -// fakeProxyProviders implements ProxyProviderInterface -type fakeProxyProviders struct { - *gentype.FakeClientWithListAndApply[*v1.ProxyProvider, *v1.ProxyProviderList, *proxyproviderv1.ProxyProviderApplyConfiguration] - Fake *FakeProxyproviderV1 -} - -func newFakeProxyProviders(fake *FakeProxyproviderV1, namespace string) typedproxyproviderv1.ProxyProviderInterface { - return &fakeProxyProviders{ - gentype.NewFakeClientWithListAndApply[*v1.ProxyProvider, *v1.ProxyProviderList, *proxyproviderv1.ProxyProviderApplyConfiguration]( - fake.Fake, - namespace, - v1.SchemeGroupVersion.WithResource("proxyproviders"), - v1.SchemeGroupVersion.WithKind("ProxyProvider"), - func() *v1.ProxyProvider { return &v1.ProxyProvider{} }, - func() *v1.ProxyProviderList { return &v1.ProxyProviderList{} }, - func(dst, src *v1.ProxyProviderList) { dst.ListMeta = src.ListMeta }, - func(list *v1.ProxyProviderList) []*v1.ProxyProvider { return gentype.ToPointerSlice(list.Items) }, - func(list *v1.ProxyProviderList, items []*v1.ProxyProvider) { - list.Items = gentype.FromPointerSlice(items) - }, - ), - fake, - } -} diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go deleted file mode 100644 index 9a2107b..0000000 --- a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - context "context" - - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" - applyconfigurationproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1" - scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - gentype "k8s.io/client-go/gentype" -) - -// ProxyProvidersGetter has a method to return a ProxyProviderInterface. -// A group's client should implement this interface. -type ProxyProvidersGetter interface { - ProxyProviders(namespace string) ProxyProviderInterface -} - -// ProxyProviderInterface has methods to work with ProxyProvider resources. -type ProxyProviderInterface interface { - Create(ctx context.Context, proxyProvider *proxyproviderv1.ProxyProvider, opts metav1.CreateOptions) (*proxyproviderv1.ProxyProvider, error) - Update(ctx context.Context, proxyProvider *proxyproviderv1.ProxyProvider, opts metav1.UpdateOptions) (*proxyproviderv1.ProxyProvider, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - UpdateStatus(ctx context.Context, proxyProvider *proxyproviderv1.ProxyProvider, opts metav1.UpdateOptions) (*proxyproviderv1.ProxyProvider, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*proxyproviderv1.ProxyProvider, error) - List(ctx context.Context, opts metav1.ListOptions) (*proxyproviderv1.ProxyProviderList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *proxyproviderv1.ProxyProvider, err error) - Apply(ctx context.Context, proxyProvider *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration, opts metav1.ApplyOptions) (result *proxyproviderv1.ProxyProvider, err error) - // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). - ApplyStatus(ctx context.Context, proxyProvider *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration, opts metav1.ApplyOptions) (result *proxyproviderv1.ProxyProvider, err error) - ProxyProviderExpansion -} - -// proxyProviders implements ProxyProviderInterface -type proxyProviders struct { - *gentype.ClientWithListAndApply[*proxyproviderv1.ProxyProvider, *proxyproviderv1.ProxyProviderList, *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration] -} - -// newProxyProviders returns a ProxyProviders -func newProxyProviders(c *ProxyproviderV1Client, namespace string) *proxyProviders { - return &proxyProviders{ - gentype.NewClientWithListAndApply[*proxyproviderv1.ProxyProvider, *proxyproviderv1.ProxyProviderList, *applyconfigurationproxyproviderv1.ProxyProviderApplyConfiguration]( - "proxyproviders", - c.RESTClient(), - scheme.ParameterCodec, - namespace, - func() *proxyproviderv1.ProxyProvider { return &proxyproviderv1.ProxyProvider{} }, - func() *proxyproviderv1.ProxyProviderList { return &proxyproviderv1.ProxyProviderList{} }, - ), - } -} diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/doc.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/doc.go similarity index 97% rename from pkg/generated/clientset/versioned/typed/proxyprovider/v1/doc.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/doc.go index 3af5d05..df51baa 100644 --- a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/doc.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1 +package v1alpha1 diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/doc.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/doc.go similarity index 100% rename from pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/doc.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/doc.go diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider.go new file mode 100644 index 0000000..995caa7 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider.go @@ -0,0 +1,53 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1alpha1" + typedproxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1" + gentype "k8s.io/client-go/gentype" +) + +// fakeProxyProviders implements ProxyProviderInterface +type fakeProxyProviders struct { + *gentype.FakeClientWithListAndApply[*v1alpha1.ProxyProvider, *v1alpha1.ProxyProviderList, *proxyproviderv1alpha1.ProxyProviderApplyConfiguration] + Fake *FakeProxyproviderV1alpha1 +} + +func newFakeProxyProviders(fake *FakeProxyproviderV1alpha1, namespace string) typedproxyproviderv1alpha1.ProxyProviderInterface { + return &fakeProxyProviders{ + gentype.NewFakeClientWithListAndApply[*v1alpha1.ProxyProvider, *v1alpha1.ProxyProviderList, *proxyproviderv1alpha1.ProxyProviderApplyConfiguration]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("proxyproviders"), + v1alpha1.SchemeGroupVersion.WithKind("ProxyProvider"), + func() *v1alpha1.ProxyProvider { return &v1alpha1.ProxyProvider{} }, + func() *v1alpha1.ProxyProviderList { return &v1alpha1.ProxyProviderList{} }, + func(dst, src *v1alpha1.ProxyProviderList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.ProxyProviderList) []*v1alpha1.ProxyProvider { + return gentype.ToPointerSlice(list.Items) + }, + func(list *v1alpha1.ProxyProviderList, items []*v1alpha1.ProxyProvider) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider_client.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider_client.go similarity index 73% rename from pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider_client.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider_client.go index 6e7210b..e0b2385 100644 --- a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/fake/fake_proxyprovider_client.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/fake/fake_proxyprovider_client.go @@ -19,22 +19,22 @@ limitations under the License. package fake import ( - v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1" + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeProxyproviderV1 struct { +type FakeProxyproviderV1alpha1 struct { *testing.Fake } -func (c *FakeProxyproviderV1) ProxyProviders(namespace string) v1.ProxyProviderInterface { +func (c *FakeProxyproviderV1alpha1) ProxyProviders(namespace string) v1alpha1.ProxyProviderInterface { return newFakeProxyProviders(c, namespace) } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeProxyproviderV1) RESTClient() rest.Interface { +func (c *FakeProxyproviderV1alpha1) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/generated_expansion.go similarity index 97% rename from pkg/generated/clientset/versioned/typed/proxyprovider/v1/generated_expansion.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/generated_expansion.go index 828bd72..8e0f857 100644 --- a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/generated_expansion.go @@ -16,6 +16,6 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1 +package v1alpha1 type ProxyProviderExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider.go new file mode 100644 index 0000000..cc9a19a --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider.go @@ -0,0 +1,74 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" + applyconfigurationproxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/applyconfiguration/proxyprovider/v1alpha1" + scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ProxyProvidersGetter has a method to return a ProxyProviderInterface. +// A group's client should implement this interface. +type ProxyProvidersGetter interface { + ProxyProviders(namespace string) ProxyProviderInterface +} + +// ProxyProviderInterface has methods to work with ProxyProvider resources. +type ProxyProviderInterface interface { + Create(ctx context.Context, proxyProvider *proxyproviderv1alpha1.ProxyProvider, opts v1.CreateOptions) (*proxyproviderv1alpha1.ProxyProvider, error) + Update(ctx context.Context, proxyProvider *proxyproviderv1alpha1.ProxyProvider, opts v1.UpdateOptions) (*proxyproviderv1alpha1.ProxyProvider, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, proxyProvider *proxyproviderv1alpha1.ProxyProvider, opts v1.UpdateOptions) (*proxyproviderv1alpha1.ProxyProvider, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*proxyproviderv1alpha1.ProxyProvider, error) + List(ctx context.Context, opts v1.ListOptions) (*proxyproviderv1alpha1.ProxyProviderList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *proxyproviderv1alpha1.ProxyProvider, err error) + Apply(ctx context.Context, proxyProvider *applyconfigurationproxyproviderv1alpha1.ProxyProviderApplyConfiguration, opts v1.ApplyOptions) (result *proxyproviderv1alpha1.ProxyProvider, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, proxyProvider *applyconfigurationproxyproviderv1alpha1.ProxyProviderApplyConfiguration, opts v1.ApplyOptions) (result *proxyproviderv1alpha1.ProxyProvider, err error) + ProxyProviderExpansion +} + +// proxyProviders implements ProxyProviderInterface +type proxyProviders struct { + *gentype.ClientWithListAndApply[*proxyproviderv1alpha1.ProxyProvider, *proxyproviderv1alpha1.ProxyProviderList, *applyconfigurationproxyproviderv1alpha1.ProxyProviderApplyConfiguration] +} + +// newProxyProviders returns a ProxyProviders +func newProxyProviders(c *ProxyproviderV1alpha1Client, namespace string) *proxyProviders { + return &proxyProviders{ + gentype.NewClientWithListAndApply[*proxyproviderv1alpha1.ProxyProvider, *proxyproviderv1alpha1.ProxyProviderList, *applyconfigurationproxyproviderv1alpha1.ProxyProviderApplyConfiguration]( + "proxyproviders", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *proxyproviderv1alpha1.ProxyProvider { return &proxyproviderv1alpha1.ProxyProvider{} }, + func() *proxyproviderv1alpha1.ProxyProviderList { return &proxyproviderv1alpha1.ProxyProviderList{} }, + ), + } +} diff --git a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider_client.go b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider_client.go similarity index 63% rename from pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider_client.go rename to pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider_client.go index 0cf67b5..e1b783d 100644 --- a/pkg/generated/clientset/versioned/typed/proxyprovider/v1/proxyprovider_client.go +++ b/pkg/generated/clientset/versioned/typed/proxyprovider/v1alpha1/proxyprovider_client.go @@ -16,34 +16,34 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( http "net/http" - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" scheme "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) -type ProxyproviderV1Interface interface { +type ProxyproviderV1alpha1Interface interface { RESTClient() rest.Interface ProxyProvidersGetter } -// ProxyproviderV1Client is used to interact with features provided by the proxyprovider.t000-n.de group. -type ProxyproviderV1Client struct { +// ProxyproviderV1alpha1Client is used to interact with features provided by the proxyprovider.t000-n.de group. +type ProxyproviderV1alpha1Client struct { restClient rest.Interface } -func (c *ProxyproviderV1Client) ProxyProviders(namespace string) ProxyProviderInterface { +func (c *ProxyproviderV1alpha1Client) ProxyProviders(namespace string) ProxyProviderInterface { return newProxyProviders(c, namespace) } -// NewForConfig creates a new ProxyproviderV1Client for the given config. +// NewForConfig creates a new ProxyproviderV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*ProxyproviderV1Client, error) { +func NewForConfig(c *rest.Config) (*ProxyproviderV1alpha1Client, error) { config := *c setConfigDefaults(&config) httpClient, err := rest.HTTPClientFor(&config) @@ -53,21 +53,21 @@ func NewForConfig(c *rest.Config) (*ProxyproviderV1Client, error) { return NewForConfigAndClient(&config, httpClient) } -// NewForConfigAndClient creates a new ProxyproviderV1Client for the given config and http client. +// NewForConfigAndClient creates a new ProxyproviderV1alpha1Client for the given config and http client. // Note the http client provided takes precedence over the configured transport values. -func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ProxyproviderV1Client, error) { +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*ProxyproviderV1alpha1Client, error) { config := *c setConfigDefaults(&config) client, err := rest.RESTClientForConfigAndClient(&config, h) if err != nil { return nil, err } - return &ProxyproviderV1Client{client}, nil + return &ProxyproviderV1alpha1Client{client}, nil } -// NewForConfigOrDie creates a new ProxyproviderV1Client for the given config and +// NewForConfigOrDie creates a new ProxyproviderV1alpha1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *ProxyproviderV1Client { +func NewForConfigOrDie(c *rest.Config) *ProxyproviderV1alpha1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -75,13 +75,13 @@ func NewForConfigOrDie(c *rest.Config) *ProxyproviderV1Client { return client } -// New creates a new ProxyproviderV1Client for the given RESTClient. -func New(c rest.Interface) *ProxyproviderV1Client { - return &ProxyproviderV1Client{c} +// New creates a new ProxyproviderV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ProxyproviderV1alpha1Client { + return &ProxyproviderV1alpha1Client{c} } func setConfigDefaults(config *rest.Config) { - gv := proxyproviderv1.SchemeGroupVersion + gv := proxyproviderv1alpha1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() @@ -93,7 +93,7 @@ func setConfigDefaults(config *rest.Config) { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *ProxyproviderV1Client) RESTClient() rest.Interface { +func (c *ProxyproviderV1alpha1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index d855ee4..1080424 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -21,7 +21,7 @@ package externalversions import ( fmt "fmt" - v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,9 +52,9 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=proxyprovider.t000-n.de, Version=v1 - case v1.SchemeGroupVersion.WithResource("proxyproviders"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Proxyprovider().V1().ProxyProviders().Informer()}, nil + // Group=proxyprovider.t000-n.de, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("proxyproviders"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Proxyprovider().V1alpha1().ProxyProviders().Informer()}, nil } diff --git a/pkg/generated/informers/externalversions/proxyprovider/interface.go b/pkg/generated/informers/externalversions/proxyprovider/interface.go index e91d464..7f3fae2 100644 --- a/pkg/generated/informers/externalversions/proxyprovider/interface.go +++ b/pkg/generated/informers/externalversions/proxyprovider/interface.go @@ -20,13 +20,13 @@ package proxyprovider import ( internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" - v1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1" + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/proxyprovider/v1alpha1" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1 provides access to shared informers for resources in V1. - V1() v1.Interface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1 returns a new v1.Interface. -func (g *group) V1() v1.Interface { - return v1.New(g.factory, g.namespace, g.tweakListOptions) +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/generated/informers/externalversions/proxyprovider/v1/interface.go b/pkg/generated/informers/externalversions/proxyprovider/v1alpha1/interface.go similarity index 98% rename from pkg/generated/informers/externalversions/proxyprovider/v1/interface.go rename to pkg/generated/informers/externalversions/proxyprovider/v1alpha1/interface.go index 556060f..630d293 100644 --- a/pkg/generated/informers/externalversions/proxyprovider/v1/interface.go +++ b/pkg/generated/informers/externalversions/proxyprovider/v1alpha1/interface.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" diff --git a/pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go b/pkg/generated/informers/externalversions/proxyprovider/v1alpha1/proxyprovider.go similarity index 75% rename from pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go rename to pkg/generated/informers/externalversions/proxyprovider/v1alpha1/proxyprovider.go index dd8ab33..a83eb89 100644 --- a/pkg/generated/informers/externalversions/proxyprovider/v1/proxyprovider.go +++ b/pkg/generated/informers/externalversions/proxyprovider/v1alpha1/proxyprovider.go @@ -16,17 +16,17 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( context "context" time "time" - apisproxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + apisproxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" versioned "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned" internalinterfaces "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions/internalinterfaces" - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/listers/proxyprovider/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" watch "k8s.io/apimachinery/pkg/watch" @@ -37,7 +37,7 @@ import ( // ProxyProviders. type ProxyProviderInformer interface { Informer() cache.SharedIndexInformer - Lister() proxyproviderv1.ProxyProviderLister + Lister() proxyproviderv1alpha1.ProxyProviderLister } type proxyProviderInformer struct { @@ -64,37 +64,37 @@ func NewFilteredProxyProviderInformer(client versioned.Interface, namespace stri // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. func NewProxyProviderInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { - gvr := schema.GroupVersionResource{Group: "proxyprovider.t000-n.de", Version: "v1", Resource: "proxyproviders"} + gvr := schema.GroupVersionResource{Group: "proxyprovider.t000-n.de", Version: "v1alpha1", Resource: "proxyproviders"} identifier := options.InformerName.WithResource(gvr) tweakListOptions := options.TweakListOptions return cache.NewSharedIndexInformerWithOptions( cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ - ListFunc: func(opts metav1.ListOptions) (runtime.Object, error) { + ListFunc: func(opts v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&opts) } - return client.ProxyproviderV1().ProxyProviders(namespace).List(context.Background(), opts) + return client.ProxyproviderV1alpha1().ProxyProviders(namespace).List(context.Background(), opts) }, - WatchFunc: func(opts metav1.ListOptions) (watch.Interface, error) { + WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&opts) } - return client.ProxyproviderV1().ProxyProviders(namespace).Watch(context.Background(), opts) + return client.ProxyproviderV1alpha1().ProxyProviders(namespace).Watch(context.Background(), opts) }, - ListWithContextFunc: func(ctx context.Context, opts metav1.ListOptions) (runtime.Object, error) { + ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&opts) } - return client.ProxyproviderV1().ProxyProviders(namespace).List(ctx, opts) + return client.ProxyproviderV1alpha1().ProxyProviders(namespace).List(ctx, opts) }, - WatchFuncWithContext: func(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&opts) } - return client.ProxyproviderV1().ProxyProviders(namespace).Watch(ctx, opts) + return client.ProxyproviderV1alpha1().ProxyProviders(namespace).Watch(ctx, opts) }, }, client), - &apisproxyproviderv1.ProxyProvider{}, + &apisproxyproviderv1alpha1.ProxyProvider{}, cache.SharedIndexInformerOptions{ ResyncPeriod: options.ResyncPeriod, Indexers: options.Indexers, @@ -108,9 +108,9 @@ func (f *proxyProviderInformer) defaultInformer(client versioned.Interface, resy } func (f *proxyProviderInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&apisproxyproviderv1.ProxyProvider{}, f.defaultInformer) + return f.factory.InformerFor(&apisproxyproviderv1alpha1.ProxyProvider{}, f.defaultInformer) } -func (f *proxyProviderInformer) Lister() proxyproviderv1.ProxyProviderLister { - return proxyproviderv1.NewProxyProviderLister(f.Informer().GetIndexer()) +func (f *proxyProviderInformer) Lister() proxyproviderv1alpha1.ProxyProviderLister { + return proxyproviderv1alpha1.NewProxyProviderLister(f.Informer().GetIndexer()) } diff --git a/pkg/generated/listers/proxyprovider/v1/expansion_generated.go b/pkg/generated/listers/proxyprovider/v1alpha1/expansion_generated.go similarity index 98% rename from pkg/generated/listers/proxyprovider/v1/expansion_generated.go rename to pkg/generated/listers/proxyprovider/v1alpha1/expansion_generated.go index 06a3fac..0236f2c 100644 --- a/pkg/generated/listers/proxyprovider/v1/expansion_generated.go +++ b/pkg/generated/listers/proxyprovider/v1alpha1/expansion_generated.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1 +package v1alpha1 // ProxyProviderListerExpansion allows custom methods to be added to // ProxyProviderLister. diff --git a/pkg/generated/listers/proxyprovider/v1/proxyprovider.go b/pkg/generated/listers/proxyprovider/v1alpha1/proxyprovider.go similarity index 76% rename from pkg/generated/listers/proxyprovider/v1/proxyprovider.go rename to pkg/generated/listers/proxyprovider/v1alpha1/proxyprovider.go index 64d319b..315ce98 100644 --- a/pkg/generated/listers/proxyprovider/v1/proxyprovider.go +++ b/pkg/generated/listers/proxyprovider/v1alpha1/proxyprovider.go @@ -16,10 +16,10 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1 +package v1alpha1 import ( - proxyproviderv1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1" + proxyproviderv1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" labels "k8s.io/apimachinery/pkg/labels" listers "k8s.io/client-go/listers" cache "k8s.io/client-go/tools/cache" @@ -30,7 +30,7 @@ import ( type ProxyProviderLister interface { // List lists all ProxyProviders in the indexer. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*proxyproviderv1.ProxyProvider, err error) + List(selector labels.Selector) (ret []*proxyproviderv1alpha1.ProxyProvider, err error) // ProxyProviders returns an object that can list and get ProxyProviders. ProxyProviders(namespace string) ProxyProviderNamespaceLister ProxyProviderListerExpansion @@ -38,17 +38,17 @@ type ProxyProviderLister interface { // proxyProviderLister implements the ProxyProviderLister interface. type proxyProviderLister struct { - listers.ResourceIndexer[*proxyproviderv1.ProxyProvider] + listers.ResourceIndexer[*proxyproviderv1alpha1.ProxyProvider] } // NewProxyProviderLister returns a new ProxyProviderLister. func NewProxyProviderLister(indexer cache.Indexer) ProxyProviderLister { - return &proxyProviderLister{listers.New[*proxyproviderv1.ProxyProvider](indexer, proxyproviderv1.Resource("proxyprovider"))} + return &proxyProviderLister{listers.New[*proxyproviderv1alpha1.ProxyProvider](indexer, proxyproviderv1alpha1.Resource("proxyprovider"))} } // ProxyProviders returns an object that can list and get ProxyProviders. func (s *proxyProviderLister) ProxyProviders(namespace string) ProxyProviderNamespaceLister { - return proxyProviderNamespaceLister{listers.NewNamespaced[*proxyproviderv1.ProxyProvider](s.ResourceIndexer, namespace)} + return proxyProviderNamespaceLister{listers.NewNamespaced[*proxyproviderv1alpha1.ProxyProvider](s.ResourceIndexer, namespace)} } // ProxyProviderNamespaceLister helps list and get ProxyProviders. @@ -56,15 +56,15 @@ func (s *proxyProviderLister) ProxyProviders(namespace string) ProxyProviderName type ProxyProviderNamespaceLister interface { // List lists all ProxyProviders in the indexer for a given namespace. // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*proxyproviderv1.ProxyProvider, err error) + List(selector labels.Selector) (ret []*proxyproviderv1alpha1.ProxyProvider, err error) // Get retrieves the ProxyProvider from the indexer for a given namespace and name. // Objects returned here must be treated as read-only. - Get(name string) (*proxyproviderv1.ProxyProvider, error) + Get(name string) (*proxyproviderv1alpha1.ProxyProvider, error) ProxyProviderNamespaceListerExpansion } // proxyProviderNamespaceLister implements the ProxyProviderNamespaceLister // interface. type proxyProviderNamespaceLister struct { - listers.ResourceIndexer[*proxyproviderv1.ProxyProvider] + listers.ResourceIndexer[*proxyproviderv1alpha1.ProxyProvider] } diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index b245522..6145d09 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -32,10 +32,10 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProvider": schema_pkg_apis_proxyprovider_v1_ProxyProvider(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderList": schema_pkg_apis_proxyprovider_v1_ProxyProviderList(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderSpec": schema_pkg_apis_proxyprovider_v1_ProxyProviderSpec(ref), - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderStatus": schema_pkg_apis_proxyprovider_v1_ProxyProviderStatus(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProvider": schema_pkg_apis_proxyprovider_v1alpha1_ProxyProvider(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderList": schema_pkg_apis_proxyprovider_v1alpha1_ProxyProviderList(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderSpec": schema_pkg_apis_proxyprovider_v1alpha1_ProxyProviderSpec(ref), + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderStatus": schema_pkg_apis_proxyprovider_v1alpha1_ProxyProviderStatus(ref), resource.Quantity{}.OpenAPIModelName(): schema_apimachinery_pkg_api_resource_Quantity(ref), v1.APIGroup{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroup(ref), v1.APIGroupList{}.OpenAPIModelName(): schema_pkg_apis_meta_v1_APIGroupList(ref), @@ -94,7 +94,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA } } -func schema_pkg_apis_proxyprovider_v1_ProxyProvider(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_proxyprovider_v1alpha1_ProxyProvider(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -123,13 +123,13 @@ func schema_pkg_apis_proxyprovider_v1_ProxyProvider(ref common.ReferenceCallback "spec": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderSpec"), + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderStatus"), + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderStatus"), }, }, }, @@ -137,11 +137,11 @@ func schema_pkg_apis_proxyprovider_v1_ProxyProvider(ref common.ReferenceCallback }, }, Dependencies: []string{ - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderSpec", "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProviderStatus", v1.ObjectMeta{}.OpenAPIModelName()}, + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderSpec", "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProviderStatus", v1.ObjectMeta{}.OpenAPIModelName()}, } } -func schema_pkg_apis_proxyprovider_v1_ProxyProviderList(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_proxyprovider_v1alpha1_ProxyProviderList(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -173,7 +173,7 @@ func schema_pkg_apis_proxyprovider_v1_ProxyProviderList(ref common.ReferenceCall Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProvider"), + Ref: ref("gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProvider"), }, }, }, @@ -184,11 +184,11 @@ func schema_pkg_apis_proxyprovider_v1_ProxyProviderList(ref common.ReferenceCall }, }, Dependencies: []string{ - "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1.ProxyProvider", v1.ListMeta{}.OpenAPIModelName()}, + "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1.ProxyProvider", v1.ListMeta{}.OpenAPIModelName()}, } } -func schema_pkg_apis_proxyprovider_v1_ProxyProviderSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_proxyprovider_v1alpha1_ProxyProviderSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ @@ -229,7 +229,7 @@ func schema_pkg_apis_proxyprovider_v1_ProxyProviderSpec(ref common.ReferenceCall } } -func schema_pkg_apis_proxyprovider_v1_ProxyProviderStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { +func schema_pkg_apis_proxyprovider_v1alpha1_ProxyProviderStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ -- 2.52.0 From cc32a0124658173a68b69c41f0165d4c08a66c20 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sat, 16 May 2026 20:07:04 +0200 Subject: [PATCH 09/14] ci: add base --- .gitea/actions/go-cache-key/action.yaml | 17 + .gitea/workflows/ci.yaml | 86 +++- .gitea/workflows/install-go-dependencies.yaml | 28 ++ .gitea/workflows/run-go-script.yaml | 35 ++ .gitignore | 1 + Makefile | 27 +- controller.go | 15 +- controller_test.go | 385 ++++++++++++++++++ go.mod | 3 + go.sum | 10 + 10 files changed, 579 insertions(+), 28 deletions(-) create mode 100644 .gitea/actions/go-cache-key/action.yaml create mode 100644 .gitea/workflows/install-go-dependencies.yaml create mode 100644 .gitea/workflows/run-go-script.yaml create mode 100644 controller_test.go diff --git a/.gitea/actions/go-cache-key/action.yaml b/.gitea/actions/go-cache-key/action.yaml new file mode 100644 index 0000000..929e530 --- /dev/null +++ b/.gitea/actions/go-cache-key/action.yaml @@ -0,0 +1,17 @@ +name: Go Cache Key +description: Create a cache key for Go dependencies + +outputs: + hash: + description: The cache key for Go dependencies + value: ${{ steps.hash-go.outputs.hash }} + +runs: + using: composite + steps: + - name: Create cache key + shell: bash + id: hash-go + run: | + echo "hash=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" + echo "hash=$hash" >> "$GITHUB_OUTPUT" diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index a910bf1..f74412e 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -8,30 +8,76 @@ env: RUNNER_TOOL_CACHE: /toolcache jobs: - test: - name: test + install-dependencies: + name: install dependencies runs-on: - ubuntu-latest steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Setup go - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6 + - name: Install dependencies + uses: .gitea/workflows/install-go-dependencies + + build-check: + name: build check + runs-on: + - ubuntu-latest + needs: install-dependencies + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Run build script + uses: .gitea/workflows/run-go-script with: - go-version-file: go.mod - check-latest: true - - name: Create cache key - id: hash-go - run: echo "hash=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" - - name: cache go - id: cache-go - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 + script: build + + check-format: + name: check format + runs-on: + - ubuntu-latest + needs: build-check + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Run check format script + uses: .gitea/workflows/run-go-script with: - path: | - /go_path - /go_cache - key: go_path-${{ steps.hash-go.outputs.hash }} - restore-keys: |- - go_cache-${{ steps.hash-go.outputs.hash }} - - name: build - run: make build + script: check-format + + check-lint: + name: check lint + runs-on: + - ubuntu-latest + needs: build-check + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Run check lint script + uses: .gitea/workflows/run-go-script + with: + script: check-lint + + test: + name: test + runs-on: + - ubuntu-latest + needs: build-check + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Run test script + uses: .gitea/workflows/run-go-script + with: + script: test + + image-check: + name: image check + runs-on: + - ubuntu-latest + - linux_amd64 + needs: build-check + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Build image + run: make build-image diff --git a/.gitea/workflows/install-go-dependencies.yaml b/.gitea/workflows/install-go-dependencies.yaml new file mode 100644 index 0000000..90ddd67 --- /dev/null +++ b/.gitea/workflows/install-go-dependencies.yaml @@ -0,0 +1,28 @@ +name: Install Go Dependencies + +on: + workflow_call: + +jobs: + install-dependencies: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Setup go + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0.4.0 + with: + go-version-file: go.mod + check-latest: true + - name: Create cache key + uses: .gitea/actions/go-cache-key@main + - name: cache go + id: cache-go + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: | + /go_path + /go_cache + key: go_path-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} diff --git a/.gitea/workflows/run-go-script.yaml b/.gitea/workflows/run-go-script.yaml new file mode 100644 index 0000000..53b7172 --- /dev/null +++ b/.gitea/workflows/run-go-script.yaml @@ -0,0 +1,35 @@ +name: Run Go Script + +on: + workflow_call: + inputs: + script: + description: The script to run + required: true + type: string + +jobs: + run-script: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Setup go + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 + with: + go-version-file: go.mod + check-latest: true + - name: Create cache key + uses: .gitea/actions/go-cache-key@main + - name: Install dependencies from Cache + id: cache-go + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: | + /go_path + /go_cache + key: go_path-${{ steps.hash-go.outputs.hash }} + restore-keys: |- + go_cache-${{ steps.hash-go.outputs.hash }} + - name: Run script + run: make ${{ inputs.script }} diff --git a/.gitignore b/.gitignore index 5f56073..f72610b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +lcov.info # Dependency directories (remove the comment below to include it) # vendor/ diff --git a/Makefile b/Makefile index 0c34b95..788ed27 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,39 @@ ifneq (,$(wildcard ./.env)) include .env export endif -.PHONY: build run codegen +.PHONY: build run codegen build-image test test-unit test-coverage lint format check-format build: go build -o main +build-image: + docker build -t authentik-kubernetes-operator:latest . + run: make build ./main --kubeconfig=/home/tbehrendt/.kube/config codegen: ./scripts/codegen.sh + +test: test-unit test-coverage + +test-unit: + go test . -coverprofile=coverage.out + +test-coverage: + go tool gcov2lcov -infile coverage.out > lcov.info + +lint: + go vet ./... + +format: + gofmt -w . + +check-format: + @OUTPUT=$$(gofmt -l .); \ + if [ -n "$$OUTPUT" ]; then \ + echo "Formatter failed for:"; \ + echo "$$OUTPUT"; \ + exit 1; \ + fi diff --git a/controller.go b/controller.go index a1dbd81..2330bf3 100644 --- a/controller.go +++ b/controller.go @@ -210,7 +210,7 @@ func (c *Controller) reconcileDelete(ctx context.Context, pp *v1alpha1.ProxyProv r, err := c.authentik.ProvidersApi.ProvidersProxyDestroy(ctx, int32(pk)).Execute() if err != nil { // This handles an edge-case, where when the ProxyProvider on Authentik has already been deleted, but the finalizer is still present. We just remove the finalizer and return. - if r.StatusCode != http.StatusNotFound { + if r != nil && r.StatusCode != http.StatusNotFound { return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyDestroy`: %w with response %v", err, r) } } @@ -226,13 +226,14 @@ func (c *Controller) reconcileUpdate(ctx context.Context, pp *v1alpha1.ProxyProv return fmt.Errorf("error parsing PK: %v", err) } _, r, err := c.authentik.ProvidersApi.ProvidersAllRetrieve(ctx, int32(pk)).Execute() - if err != nil && r.StatusCode != http.StatusNotFound { - + if err != nil { + if r != nil && r.StatusCode == http.StatusNotFound { + // This handles an edge-case, where when the PorxyProvider on Authentik has been deleted, e.g. by mistake. We just remove the PK and return. + // During the next reconciliation, the ProxyProvider will be re-created. + pp.Status.PK = "" + return c.updateProxyProviderStatus(ctx, pp) + } return fmt.Errorf("error retrieving existing ProxyProvider: %v with response %v", err, r) - } else if r.StatusCode == http.StatusNotFound { - // This handles an edge-case, where when the PorxyProvider on Authentik has been deleted, e.g. by mistake. We just remove the PK and return. - // During the next reconciliation, the ProxyProvider will be re-created. - pp.Status.PK = "" } proxyProviderRequest := &authentikapi.PatchedProxyProviderRequest{ diff --git a/controller_test.go b/controller_test.go new file mode 100644 index 0000000..8d3c13b --- /dev/null +++ b/controller_test.go @@ -0,0 +1,385 @@ +// AI generated tests and not yet reviewed. +package main + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "net/url" + "slices" + "strings" + "testing" + + v1alpha1 "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/apis/proxyprovider/v1alpha1" + operatorfake "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/clientset/versioned/fake" + operatorinformers "gitea.t000-n.de/t.behrendt/authentik-kubernetes-operator/pkg/generated/informers/externalversions" + authentikapi "goauthentik.io/api/v3" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/kubernetes/fake" + "k8s.io/client-go/tools/cache" +) + +func TestController_syncHandler_create(t *testing.T) { + const wantPK = 42 + + server := newAuthentikTestServer(t, authentikTestHandlers{ + proxyCreate: func(w http.ResponseWriter, _ *http.Request) { + writeJSON(t, w, http.StatusCreated, map[string]any{"pk": wantPK}) + }, + }) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, testProxyProvider(), server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: "default", Name: "test-pp"}) + if err != nil { + t.Fatalf("syncHandler() error = %v", err) + } + + got := getProxyProvider(t, ctrl, "default", "test-pp") + if got.Status.PK != "42" { + t.Fatalf("status.pk = %q, want 42", got.Status.PK) + } +} + +func TestController_syncHandler_ensureFinalizers(t *testing.T) { + pp := testProxyProvider() + pp.Status.PK = "42" + + server := newAuthentikTestServer(t, authentikTestHandlers{}) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, pp, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: pp.Namespace, Name: pp.Name}) + if err != nil { + t.Fatalf("syncHandler() error = %v", err) + } + + got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name) + if !slices.Contains(got.Finalizers, DeleteAuthentikProxyProviderFinalizer) { + t.Fatalf("finalizers = %v, want %q", got.Finalizers, DeleteAuthentikProxyProviderFinalizer) + } +} + +func TestController_syncHandler_update(t *testing.T) { + pp := testProxyProvider() + pp.Status.PK = "42" + pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer} + + server := newAuthentikTestServer(t, authentikTestHandlers{ + allRetrieve: func(w http.ResponseWriter, _ *http.Request) { + writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42}) + }, + proxyPartialUpdate: func(w http.ResponseWriter, _ *http.Request) { + writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42}) + }, + }) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, pp, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: pp.Namespace, Name: pp.Name}) + if err != nil { + t.Fatalf("syncHandler() error = %v", err) + } + + got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name) + if got.Status.PK != "42" { + t.Fatalf("status.pk = %q, want 42", got.Status.PK) + } +} + +func TestController_syncHandler_update_providerNotFound(t *testing.T) { + pp := testProxyProvider() + pp.Status.PK = "42" + pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer} + + server := newAuthentikTestServer(t, authentikTestHandlers{ + allRetrieve: func(w http.ResponseWriter, _ *http.Request) { + http.NotFound(w, nil) + }, + }) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, pp, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: pp.Namespace, Name: pp.Name}) + if err != nil { + t.Fatalf("syncHandler() error = %v", err) + } + + got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name) + if got.Status.PK != "" { + t.Fatalf("status.pk = %q, want empty after provider not found", got.Status.PK) + } +} + +func TestController_syncHandler_delete(t *testing.T) { + now := metav1.Now() + pp := testProxyProvider() + pp.Status.PK = "42" + pp.DeletionTimestamp = &now + pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer} + + var destroyCalled bool + server := newAuthentikTestServer(t, authentikTestHandlers{ + proxyDestroy: func(w http.ResponseWriter, r *http.Request) { + destroyCalled = true + if r.Method != http.MethodDelete { + t.Errorf("destroy method = %s, want DELETE", r.Method) + } + w.WriteHeader(http.StatusNoContent) + }, + }) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, pp, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: pp.Namespace, Name: pp.Name}) + if err != nil { + t.Fatalf("syncHandler() error = %v", err) + } + if !destroyCalled { + t.Fatal("expected Authentik destroy call") + } + + got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name) + if slices.Contains(got.Finalizers, DeleteAuthentikProxyProviderFinalizer) { + t.Fatalf("finalizers = %v, want finalizer removed", got.Finalizers) + } +} + +func TestController_syncHandler_delete_providerAlreadyGone(t *testing.T) { + now := metav1.Now() + pp := testProxyProvider() + pp.Status.PK = "42" + pp.DeletionTimestamp = &now + pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer} + + server := newAuthentikTestServer(t, authentikTestHandlers{ + proxyDestroy: func(w http.ResponseWriter, _ *http.Request) { + http.NotFound(w, nil) + }, + }) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, pp, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: pp.Namespace, Name: pp.Name}) + if err != nil { + t.Fatalf("syncHandler() error = %v", err) + } + + got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name) + if slices.Contains(got.Finalizers, DeleteAuthentikProxyProviderFinalizer) { + t.Fatalf("finalizers = %v, want finalizer removed after 404", got.Finalizers) + } +} + +func TestController_syncHandler_notFound(t *testing.T) { + server := newAuthentikTestServer(t, authentikTestHandlers{}) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, nil, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: "default", Name: "missing"}) + if err != nil { + t.Fatalf("syncHandler() error = %v, want nil for missing object", err) + } +} + +func TestController_syncHandler_invalidPK(t *testing.T) { + pp := testProxyProvider() + pp.Status.PK = "not-a-number" + pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer} + + server := newAuthentikTestServer(t, authentikTestHandlers{}) + t.Cleanup(server.Close) + + ctrl, ctx, cancel := newTestController(t, pp, server.URL) + t.Cleanup(cancel) + + err := ctrl.syncHandler(ctx, cache.ObjectName{Namespace: pp.Namespace, Name: pp.Name}) + if err == nil { + t.Fatal("syncHandler() error = nil, want parse error") + } + if !strings.Contains(err.Error(), "error parsing PK") { + t.Fatalf("syncHandler() error = %v, want PK parse error", err) + } +} + +func TestController_enqueueProxyProvider(t *testing.T) { + server := newAuthentikTestServer(t, authentikTestHandlers{}) + t.Cleanup(server.Close) + + ctrl, _, cancel := newTestController(t, testProxyProvider(), server.URL) + t.Cleanup(cancel) + + ctrl.enqueueProxyProvider(testProxyProvider()) + + if ctrl.workqueue.Len() != 1 { + t.Fatalf("workqueue length = %d, want 1", ctrl.workqueue.Len()) + } +} + +// --- test helpers --- + +func testProxyProvider() *v1alpha1.ProxyProvider { + return &v1alpha1.ProxyProvider{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1alpha1.SchemeGroupVersion.String(), + Kind: "ProxyProvider", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test-pp", + Namespace: "default", + }, + Spec: v1alpha1.ProxyProviderSpec{ + Name: "my-app", + AuthorizationFlow: "flow-auth", + InvalidationFlow: "flow-invalidate", + ExternalHost: "https://app.example.com", + }, + } +} + +func newTestController(t *testing.T, pp *v1alpha1.ProxyProvider, authentikURL string) (*Controller, context.Context, context.CancelFunc) { + t.Helper() + ctx, cancel := context.WithCancel(context.Background()) + ctrl, _, stop := newTestControllerWithContext(t, ctx, pp, authentikURL) + return ctrl, ctx, func() { + cancel() + stop() + } +} + +func newTestControllerWithContext(t *testing.T, ctx context.Context, pp *v1alpha1.ProxyProvider, authentikURL string) (*Controller, context.Context, func()) { + t.Helper() + + authentikClient := newAuthentikAPIClientForTest(t, authentikURL) + + var objects []runtime.Object + if pp != nil { + objects = append(objects, pp) + } + proxyClient := operatorfake.NewSimpleClientset(objects...) + + informerFactory := operatorinformers.NewSharedInformerFactory(proxyClient, 0) + proxyInformer := informerFactory.Proxyprovider().V1alpha1().ProxyProviders() + + ctrl := NewController(ctx, fake.NewClientset(), proxyClient, authentikClient, proxyInformer) + + informerFactory.Start(ctx.Done()) + for informerType, synced := range informerFactory.WaitForCacheSync(ctx.Done()) { + if !synced { + t.Fatalf("informer %v failed to sync", informerType) + } + } + + return ctrl, ctx, func() {} +} + +func newAuthentikAPIClientForTest(t *testing.T, serverURL string) *authentikapi.APIClient { + t.Helper() + + u, err := url.Parse(serverURL) + if err != nil { + t.Fatalf("parse server URL: %v", err) + } + + cfg := authentikapi.NewConfiguration() + cfg.Scheme = u.Scheme + cfg.Host = u.Host + + return authentikapi.NewAPIClient(cfg) +} + +type authentikTestHandlers struct { + proxyCreate http.HandlerFunc + proxyDestroy http.HandlerFunc + proxyPartialUpdate http.HandlerFunc + allRetrieve http.HandlerFunc +} + +func newAuthentikTestServer(t *testing.T, handlers authentikTestHandlers) *httptest.Server { + t.Helper() + + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + path := r.URL.Path + + switch { + case path == "/api/v3/providers/proxy/" && r.Method == http.MethodPost: + if handlers.proxyCreate != nil { + handlers.proxyCreate(w, r) + return + } + http.NotFound(w, r) + + case strings.HasPrefix(path, "/api/v3/providers/proxy/") && strings.HasSuffix(path, "/"): + idPath := strings.TrimPrefix(path, "/api/v3/providers/proxy/") + if idPath == "" { + http.NotFound(w, r) + return + } + switch r.Method { + case http.MethodDelete: + if handlers.proxyDestroy != nil { + handlers.proxyDestroy(w, r) + return + } + http.NotFound(w, r) + case http.MethodPatch: + if handlers.proxyPartialUpdate != nil { + handlers.proxyPartialUpdate(w, r) + return + } + http.NotFound(w, r) + default: + http.Error(w, "unexpected method on proxy instance", http.StatusMethodNotAllowed) + } + + case strings.HasPrefix(path, "/api/v3/providers/all/") && strings.HasSuffix(path, "/"): + if r.Method == http.MethodGet && handlers.allRetrieve != nil { + handlers.allRetrieve(w, r) + return + } + http.NotFound(w, r) + + default: + http.NotFound(w, r) + } + }) + + return httptest.NewServer(handler) +} + +func writeJSON(t *testing.T, w http.ResponseWriter, status int, body any) { + t.Helper() + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + if err := json.NewEncoder(w).Encode(body); err != nil { + t.Fatalf("write JSON response: %v", err) + } +} + +func getProxyProvider(t *testing.T, ctrl *Controller, namespace, name string) *v1alpha1.ProxyProvider { + t.Helper() + + got, err := ctrl.proxyProviderClientset.ProxyproviderV1alpha1().ProxyProviders(namespace).Get( + context.Background(), name, metav1.GetOptions{}, + ) + if err != nil { + t.Fatalf("get ProxyProvider: %v", err) + } + return got +} diff --git a/go.mod b/go.mod index b6e9adc..0f731a7 100644 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ require ( github.com/go-openapi/swag/yamlutils v0.25.4 // indirect github.com/google/gnostic-models v0.7.0 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/jandelgado/gcov2lcov v1.1.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect @@ -60,3 +61,5 @@ require ( ) replace k8s.io/code-generator => ./code-generator + +tool github.com/jandelgado/gcov2lcov diff --git a/go.sum b/go.sum index 8e707e6..c63418c 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/jandelgado/gcov2lcov v1.1.1 h1:CHUNoAglvb34DqmMoZchnzDbA3yjpzT8EoUvVqcAY+s= +github.com/jandelgado/gcov2lcov v1.1.1/go.mod h1:tMVUlMVtS1po2SB8UkADWhOT5Y5Q13XOce2AYU69JuI= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -71,9 +73,16 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7 github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= @@ -107,6 +116,7 @@ gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnf gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.0.0-20260509204538-0dfb117cc6ec h1:xf12Yh3ltN4fnNyP0CyyM0TwNVnZDfLJjV3+bf9fPFY= -- 2.52.0 From 6a9cefbaf39511d7200f8d5e1ac5c4cda3a1f760 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sat, 16 May 2026 20:12:43 +0200 Subject: [PATCH 10/14] update docs --- .vscode/launch.json | 3 --- README.md | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index edadf84..07a489e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,7 +1,4 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { diff --git a/README.md b/README.md index 352e121..df09558 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,19 @@ The ProxyProvider will be created in Authentik, but will not be assigned to an o ## Versioning As soon as the operator covers an entire use case, the version will be raised to v1 and follow default versioning rules. Before that, the version will be v1alpha1. + +## Development + +### Guidelines & Tips + +- Only do a single reconciliation at a time and then return. + - This is because your references from the k8s API get stale after each update. + - Whenever you update a resource, k8s API will send a new event to your controller, which will trigger a new reconciliation. +- The API will periodically send a resource to the controller for re-syncing, giving the controller a chance to reconcile the state with the outside world. +- Use finalizers to ensure that the controller gets a chance to reconcile the state with the outside world before the object is deleted. If no finalizer is present, the object is deleted immediately without the controller seeing it. +- Use the resource's state to keep track of the current state of the outside world, e.g. identifiers of external resources, etc. + +### References + +- [Extend Kubernetes](https://kubernetes.io/docs/concepts/extend-kubernetes/#api-extensions) +- [Example Controller Implementation](https://github.com/kubernetes/sample-controller) -- 2.52.0 From 20f81f90eb7ec48ea559fa5dec74e82c2e18100e Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sat, 16 May 2026 20:15:46 +0200 Subject: [PATCH 11/14] ci: fix ref to local workflows --- .gitea/actions/go-cache-key/action.yaml | 1 - .gitea/workflows/ci.yaml | 64 +++++-------------- .gitea/workflows/install-go-dependencies.yaml | 15 +++-- .gitea/workflows/run-go-script.yaml | 11 ++-- 4 files changed, 33 insertions(+), 58 deletions(-) diff --git a/.gitea/actions/go-cache-key/action.yaml b/.gitea/actions/go-cache-key/action.yaml index 929e530..7d393e8 100644 --- a/.gitea/actions/go-cache-key/action.yaml +++ b/.gitea/actions/go-cache-key/action.yaml @@ -14,4 +14,3 @@ runs: id: hash-go run: | echo "hash=$(sha256sum go.mod go.sum | sha256sum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" - echo "hash=$hash" >> "$GITHUB_OUTPUT" diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index f74412e..70d8636 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -9,73 +9,41 @@ env: jobs: install-dependencies: - name: install dependencies - runs-on: - - ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Install dependencies - uses: .gitea/workflows/install-go-dependencies + uses: ./.gitea/workflows/install-go-dependencies.yaml build-check: name: build check - runs-on: - - ubuntu-latest needs: install-dependencies - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Run build script - uses: .gitea/workflows/run-go-script - with: - script: build + uses: ./.gitea/workflows/run-go-script.yaml + with: + script: build check-format: name: check format - runs-on: - - ubuntu-latest - needs: build-check - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Run check format script - uses: .gitea/workflows/run-go-script - with: - script: check-format + needs: install-dependencies + uses: ./.gitea/workflows/run-go-script.yaml + with: + script: check-format check-lint: name: check lint - runs-on: - - ubuntu-latest - needs: build-check - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Run check lint script - uses: .gitea/workflows/run-go-script - with: - script: check-lint + needs: install-dependencies + uses: ./.gitea/workflows/run-go-script.yaml + with: + script: lint test: name: test - runs-on: - - ubuntu-latest - needs: build-check - steps: - - name: Checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Run test script - uses: .gitea/workflows/run-go-script - with: - script: test + needs: install-dependencies + uses: ./.gitea/workflows/run-go-script.yaml + with: + script: test image-check: name: image check runs-on: - ubuntu-latest - linux_amd64 - needs: build-check steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 diff --git a/.gitea/workflows/install-go-dependencies.yaml b/.gitea/workflows/install-go-dependencies.yaml index 90ddd67..4d200cb 100644 --- a/.gitea/workflows/install-go-dependencies.yaml +++ b/.gitea/workflows/install-go-dependencies.yaml @@ -5,17 +5,20 @@ on: jobs: install-dependencies: - runs-on: ubuntu-latest + runs-on: + - ubuntu-latest + - linux_amd64 steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Setup go - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0.4.0 + uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: go-version-file: go.mod check-latest: true - name: Create cache key - uses: .gitea/actions/go-cache-key@main + id: go-cache-key + uses: ./.gitea/actions/go-cache-key - name: cache go id: cache-go uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 @@ -23,6 +26,8 @@ jobs: path: | /go_path /go_cache - key: go_path-${{ steps.hash-go.outputs.hash }} + key: go_path-${{ steps.go-cache-key.outputs.hash }} restore-keys: |- - go_cache-${{ steps.hash-go.outputs.hash }} + go_cache-${{ steps.go-cache-key.outputs.hash }} + - name: Download dependencies + run: go mod download diff --git a/.gitea/workflows/run-go-script.yaml b/.gitea/workflows/run-go-script.yaml index 53b7172..f481755 100644 --- a/.gitea/workflows/run-go-script.yaml +++ b/.gitea/workflows/run-go-script.yaml @@ -10,7 +10,9 @@ on: jobs: run-script: - runs-on: ubuntu-latest + runs-on: + - ubuntu-latest + - linux_amd64 steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -20,7 +22,8 @@ jobs: go-version-file: go.mod check-latest: true - name: Create cache key - uses: .gitea/actions/go-cache-key@main + id: go-cache-key + uses: ./.gitea/actions/go-cache-key - name: Install dependencies from Cache id: cache-go uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 @@ -28,8 +31,8 @@ jobs: path: | /go_path /go_cache - key: go_path-${{ steps.hash-go.outputs.hash }} + key: go_path-${{ steps.go-cache-key.outputs.hash }} restore-keys: |- - go_cache-${{ steps.hash-go.outputs.hash }} + go_cache-${{ steps.go-cache-key.outputs.hash }} - name: Run script run: make ${{ inputs.script }} -- 2.52.0 From f00dfd89cc92c0c05628d99258f1d55309fc3ebc Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sun, 17 May 2026 10:46:44 +0200 Subject: [PATCH 12/14] bump docker file base image version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index be65e9c..4a14c81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/golang:1.25-alpine@sha256:04d017a27c481185c169884328a5761d052910fdced8c3b8edd686474efdf59b AS build +FROM docker.io/library/golang:1.26.3@sha256:313faae491b410a35402c05d35e7518ae99103d957308e940e1ae2cfa0aac29b AS build ARG GOARCH=amd64 -- 2.52.0 From 8a8ea0e3f3cfde5409c955b4ffc90e034df2181a Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sun, 17 May 2026 12:10:10 +0200 Subject: [PATCH 13/14] ci: add base cd --- .gitea/workflows/cd.yaml | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .gitea/workflows/cd.yaml diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml new file mode 100644 index 0000000..1b104bb --- /dev/null +++ b/.gitea/workflows/cd.yaml @@ -0,0 +1,104 @@ +name: CD + +on: + push: + branches: + - main + paths: + - "go.mod" + - "go.sum" + - "**/*.go" + - "Dockerfile" + - "Makefile" + workflow_dispatch: + +env: + DOCKER_REGISTRY: gitea.t000-n.de + +jobs: + build_and_push: + name: Build and push + strategy: + matrix: + arch: [amd64] + runs-on: + - ubuntu-latest + - linux_${{ matrix.arch }} + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 + - name: Login to Registry + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - name: Get Metadata + id: meta + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT + - name: Build and push + uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 + with: + context: . + file: ./Dockerfile + platforms: linux/${{ matrix.arch }} + push: true + provenance: false + build-args: GOARCH=${{ matrix.arch }} + tags: | + ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-${{ matrix.arch }} + + create_tag: + name: Create tag + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.tag.outputs.new-tag }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + - uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@ef0c23189db33220a73022d8c29a27709d0df440 # 0.1.32 + id: tag + with: + token: ${{ secrets.GITEA_TOKEN }} + prerelease: ${{ github.event_name == 'workflow_dispatch' }} + - run: | + git tag ${{ steps.tag.outputs.new-tag }} + git push origin ${{ steps.tag.outputs.new-tag }} + - name: Set output + run: | + echo "tag=${{ steps.tag.outputs.new-tag }}" >> $GITHUB_OUTPUT + + create_manifest: + name: Create manifest + needs: + - build_and_push + - create_tag + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Get Metadata + id: meta + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}' | tr '[:upper:]' '[:lower:]') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT + + - name: Login to Registry + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Create manifest + run: | + docker manifest create ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} \ + ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}-amd64 + + docker manifest push ${{ env.DOCKER_REGISTRY }}/t.behrendt/${{ steps.meta.outputs.REPO_NAME }}:${{ needs.create_tag.outputs.tag }} -- 2.52.0 From 145e3e4627a04cbd1bfc5e234fdd10f94ed76ede Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sun, 17 May 2026 12:11:35 +0200 Subject: [PATCH 14/14] add dockerignore --- .dockerignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d13d34b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +* + +!pkg +!controller.go +!main.go +!go.mod +!go.sum -- 2.52.0