From e652ed315f1a943859caa1042d22ec7590ae07ac Mon Sep 17 00:00:00 2001 From: Pedro Juarez Date: Mon, 13 May 2024 08:58:35 -0700 Subject: [PATCH] Rename PolicyBinding API form `v1alpha1` to `v1beta1` (#2119) * Rename PolicyBinding API form `v1alpha1` to `v1beta1` Signed-off-by: pjuarezd * Update pkg/apis/sts.min.io/v1beta1/doc.go * Update pkg/apis/sts.min.io/v1beta1/register.go * Update pkg/apis/sts.min.io/v1beta1/types.go Co-authored-by: Shubhendu --------- Signed-off-by: pjuarezd Co-authored-by: Shubhendu --- Makefile | 6 +- docs/STS.md | 2 +- docs/policybinding_crd.adoc | 4 +- examples/kustomization/sts-example/README.md | 4 +- .../sample-data/mc-job-policy-binding.yaml | 2 +- .../sts-example/sts-app/policy-binding.yaml | 2 +- .../templates/sts.min.io_policybindings.yaml | 59 +++- k8s/update-codegen.sh | 2 +- pkg/apis/sts.min.io/v1alpha1/types.go | 3 +- pkg/apis/sts.min.io/v1beta1/doc.go | 25 ++ pkg/apis/sts.min.io/v1beta1/register.go | 57 ++++ pkg/apis/sts.min.io/v1beta1/types.go | 91 +++++++ .../v1beta1/zz_generated.deepcopy.go | 162 +++++++++++ .../sts.min.io/v1beta1/application.go | 48 ++++ .../sts.min.io/v1beta1/policybinding.go | 219 +++++++++++++++ .../sts.min.io/v1beta1/policybindingspec.go | 50 ++++ .../sts.min.io/v1beta1/policybindingstatus.go | 48 ++++ .../sts.min.io/v1beta1/policybindingusage.go | 39 +++ pkg/client/applyconfiguration/utils.go | 14 + pkg/client/clientset/versioned/clientset.go | 13 + .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/sts.min.io/v1beta1/doc.go | 20 ++ .../typed/sts.min.io/v1beta1/fake/doc.go | 20 ++ .../v1beta1/fake/fake_policybinding.go | 189 +++++++++++++ .../v1beta1/fake/fake_sts.min.io_client.go | 40 +++ .../sts.min.io/v1beta1/generated_expansion.go | 21 ++ .../typed/sts.min.io/v1beta1/policybinding.go | 256 ++++++++++++++++++ .../sts.min.io/v1beta1/sts.min.io_client.go | 107 ++++++++ .../informers/externalversions/generic.go | 5 + .../externalversions/sts.min.io/interface.go | 8 + .../sts.min.io/v1beta1/interface.go | 45 +++ .../sts.min.io/v1beta1/policybinding.go | 90 ++++++ .../sts.min.io/v1beta1/expansion_generated.go | 27 ++ .../sts.min.io/v1beta1/policybinding.go | 99 +++++++ pkg/controller/controller.go | 7 +- pkg/controller/job-controller.go | 4 +- pkg/controller/main-controller.go | 2 +- pkg/controller/sts_handlers.go | 6 +- release.sh | 2 +- .../base/crds/sts.min.io_policybindings.yaml | 59 +++- 42 files changed, 1845 insertions(+), 23 deletions(-) create mode 100644 pkg/apis/sts.min.io/v1beta1/doc.go create mode 100644 pkg/apis/sts.min.io/v1beta1/register.go create mode 100644 pkg/apis/sts.min.io/v1beta1/types.go create mode 100644 pkg/apis/sts.min.io/v1beta1/zz_generated.deepcopy.go create mode 100644 pkg/client/applyconfiguration/sts.min.io/v1beta1/application.go create mode 100644 pkg/client/applyconfiguration/sts.min.io/v1beta1/policybinding.go create mode 100644 pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingspec.go create mode 100644 pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingstatus.go create mode 100644 pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingusage.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_policybinding.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_sts.min.io_client.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/policybinding.go create mode 100644 pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/sts.min.io_client.go create mode 100644 pkg/client/informers/externalversions/sts.min.io/v1beta1/interface.go create mode 100644 pkg/client/informers/externalversions/sts.min.io/v1beta1/policybinding.go create mode 100644 pkg/client/listers/sts.min.io/v1beta1/expansion_generated.go create mode 100644 pkg/client/listers/sts.min.io/v1beta1/policybinding.go diff --git a/Makefile b/Makefile index abc981e1800..1c457d8e720 100644 --- a/Makefile +++ b/Makefile @@ -66,8 +66,8 @@ clean: @rm -rf dist/ regen-crd: - @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 - @${GOPATH}/bin/controller-gen crd:maxDescLen=0,generateEmbeddedObjectMeta=true paths="./..." output:crd:artifacts:config=$(KUSTOMIZE_CRDS) + @go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.15.0 + @${GOPATH}/bin/controller-gen crd:maxDescLen=0,generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=$(KUSTOMIZE_CRDS) @sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/minio.min.io_tenants.yaml > $(HELM_TEMPLATES)/minio.min.io_tenants.yaml @sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/sts.min.io_policybindings.yaml > $(HELM_TEMPLATES)/sts.min.io_policybindings.yaml @sed 's#namespace: minio-operator#namespace: {{ .Release.Namespace }}#g' resources/base/crds/job.min.io_miniojobs.yaml > $(HELM_TEMPLATES)/job.min.io_jobs.yaml @@ -75,7 +75,7 @@ regen-crd: regen-crd-docs: @echo "Installing crd-ref-docs" && GO111MODULE=on go install -v github.com/elastic/crd-ref-docs@latest @${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/minio.min.io/v2 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/tenant_crd.adoc --templates-dir=docs/templates/asciidoctor/ - @${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/sts.min.io/v1alpha1 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/policybinding_crd.adoc --templates-dir=docs/templates/asciidoctor/ + @${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/sts.min.io/v1beta1 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/policybinding_crd.adoc --templates-dir=docs/templates/asciidoctor/ @${GOPATH}/bin/crd-ref-docs --source-path=./pkg/apis/job.min.io/v1alpha1 --config=docs/templates/config.yaml --renderer=asciidoctor --output-path=docs/job_crd.adoc --templates-dir=docs/templates/asciidoctor/ generate-code: diff --git a/docs/STS.md b/docs/STS.md index 857ceb0b500..eb017a286d9 100644 --- a/docs/STS.md +++ b/docs/STS.md @@ -2,7 +2,7 @@ **Native IAM Authentication for Kubernetes.** -> ⚠️ This feature is an alpha release and is subject to breaking changes in future releases. +> ⚠️ This feature is an Beta release starting Operator v6.x, was released in Beta on Operator v5.x MinIO Operator offers support for [Secure Tokens](https://min.io/docs/minio/linux/developers/security-token-service.html?ref=op-gh) (a.k.a. STS) which diff --git a/docs/policybinding_crd.adoc b/docs/policybinding_crd.adoc index cef8cb1b8ba..8f29bd960f7 100644 --- a/docs/policybinding_crd.adoc +++ b/docs/policybinding_crd.adoc @@ -9,9 +9,9 @@ [id="{anchor_prefix}-sts-min-io-v1alpha1"] -=== sts.min.io/v1alpha1 +=== sts.min.io/v1beta1 -Package v1alpha1 - The following parameters are specific to the `sts.min.io/v1alpha1` MinIO Policy Binding CRD API +Package v1beta1 - The following parameters are specific to the `sts.min.io/v1beta1` MinIO Policy Binding CRD API PolicyBinding is an Authorization mechanism managed by the Minio Operator. Using Kubernetes ServiceAccount JSON Web Tokens the binding allow a ServiceAccount to assume temporary IAM credentials. For more complete documentation on this object, see the https://docs.min.io/minio/k8s/reference/minio-operator-reference.html#minio-operator-yaml-reference[MinIO Kubernetes Documentation]. diff --git a/examples/kustomization/sts-example/README.md b/examples/kustomization/sts-example/README.md index d45852a75e6..2c642c90d95 100644 --- a/examples/kustomization/sts-example/README.md +++ b/examples/kustomization/sts-example/README.md @@ -2,7 +2,7 @@ Each example in this folder contains an example using a different SDK on how to adopt Operator's STS. -> ⚠️ This feature is an alpha release and is subject to breaking changes in future releases. +> ⚠️ This feature is an Beta release now starting Operator v6.x, Operator v5.x released STS as v1alpha1. # Requirements @@ -58,7 +58,7 @@ namespace `minio-tenant-1` by installing a `PolicyBinding` on the `minio-tenant- Example policy binding (see CRD documentation in [policybinding_crd.adoc](../../../docs/policybinding_crd.adoc) ) ```yaml -apiVersion: sts.min.io/v1alpha1 +apiVersion: sts.min.io/v1beta1 kind: PolicyBinding metadata: name: binding-1 diff --git a/examples/kustomization/sts-example/sample-data/mc-job-policy-binding.yaml b/examples/kustomization/sts-example/sample-data/mc-job-policy-binding.yaml index e676e9996e4..92be418150b 100644 --- a/examples/kustomization/sts-example/sample-data/mc-job-policy-binding.yaml +++ b/examples/kustomization/sts-example/sample-data/mc-job-policy-binding.yaml @@ -1,4 +1,4 @@ -apiVersion: sts.min.io/v1alpha1 +apiVersion: sts.min.io/v1beta1 kind: PolicyBinding metadata: name: mc-job-binding diff --git a/examples/kustomization/sts-example/sts-app/policy-binding.yaml b/examples/kustomization/sts-example/sts-app/policy-binding.yaml index 13136d858e1..ac1ad721354 100644 --- a/examples/kustomization/sts-example/sts-app/policy-binding.yaml +++ b/examples/kustomization/sts-example/sts-app/policy-binding.yaml @@ -1,4 +1,4 @@ -apiVersion: sts.min.io/v1alpha1 +apiVersion: sts.min.io/v1beta1 kind: PolicyBinding metadata: name: binding-1 diff --git a/helm/operator/templates/sts.min.io_policybindings.yaml b/helm/operator/templates/sts.min.io_policybindings.yaml index a2bc9a8aca4..2ef71786929 100644 --- a/helm/operator/templates/sts.min.io_policybindings.yaml +++ b/helm/operator/templates/sts.min.io_policybindings.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.14.0 + controller-gen.kubebuilder.io/version: v0.15.0 operator.min.io/version: v5.0.15 name: policybindings.sts.min.io spec: @@ -71,6 +71,63 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.currentState + name: State + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + application: + properties: + namespace: + type: string + serviceaccount: + type: string + required: + - namespace + - serviceaccount + type: object + policies: + items: + type: string + type: array + required: + - application + - policies + type: object + status: + properties: + currentState: + type: string + usage: + nullable: true + properties: + authotizations: + format: int64 + type: integer + type: object + required: + - currentState + - usage + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/k8s/update-codegen.sh b/k8s/update-codegen.sh index 3f7d66b7ad3..7293aae8ce0 100755 --- a/k8s/update-codegen.sh +++ b/k8s/update-codegen.sh @@ -43,7 +43,7 @@ chmod +x ${CODEGEN_PKG}/generate-internal-groups.sh cd ${SCRIPT_ROOT} ${CODEGEN_PKG}/generate-groups.sh "all" \ $ROOT_PKG/pkg/client $ROOT_PKG/pkg/apis \ - "minio.min.io:v2 sts.min.io:v1alpha1 job.min.io:v1alpha1" \ + "minio.min.io:v2 sts.min.io:v1alpha1,v1beta1 job.min.io:v1alpha1" \ --output-base "${TEMP_DIR}" \ --go-header-file "k8s/boilerplate.go.txt" diff --git a/pkg/apis/sts.min.io/v1alpha1/types.go b/pkg/apis/sts.min.io/v1alpha1/types.go index ba7113667a3..838bc4c3c4e 100644 --- a/pkg/apis/sts.min.io/v1alpha1/types.go +++ b/pkg/apis/sts.min.io/v1alpha1/types.go @@ -26,7 +26,8 @@ import ( // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.currentState" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" // +kubebuilder:metadata:annotations=operator.min.io/version=v5.0.15 -// +kubebuilder:storageversion +// +groupName=policybinding.sts.min.io +// +versionName=v1alpha1 // PolicyBinding is a https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/[Kubernetes object] describing a MinIO PolicyBinding. type PolicyBinding struct { diff --git a/pkg/apis/sts.min.io/v1beta1/doc.go b/pkg/apis/sts.min.io/v1beta1/doc.go new file mode 100644 index 00000000000..8ab64c159d5 --- /dev/null +++ b/pkg/apis/sts.min.io/v1beta1/doc.go @@ -0,0 +1,25 @@ +// Copyright (C) 2024, MinIO, Inc. +// +// This code is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License, version 3, +// as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License, version 3, +// along with this program. If not, see + +// +k8s:deepcopy-gen=package,register +// go:generate controller-gen crd:trivialVersions=true paths=. output:dir=. + +// Package v1beta1 - The following parameters are specific to the `sts.min.io/vv1beta1` MinIO Policy Binding CRD API +// PolicyBinding is an Authorization mechanism managed by the Minio Operator. +// Using Kubernetes ServiceAccount JSON Web Tokens the binding allow a ServiceAccount to assume temporary IAM credentials. +// For more complete documentation on this object, see the https://docs.min.io/minio/k8s/reference/minio-operator-reference.html#minio-operator-yaml-reference[MinIO Kubernetes Documentation]. +// PolicyBinding is added as part of the MinIO Operator v5.0.0. + +// +groupName=sts.min.io +// +versionName=v1beta1 +package v1beta1 diff --git a/pkg/apis/sts.min.io/v1beta1/register.go b/pkg/apis/sts.min.io/v1beta1/register.go new file mode 100644 index 00000000000..1c3a6eef0f4 --- /dev/null +++ b/pkg/apis/sts.min.io/v1beta1/register.go @@ -0,0 +1,57 @@ +// Copyright (C) 2024, MinIO, Inc. +// +// This code is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License, version 3, +// as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License, version 3, +// along with this program. If not, see + +package v1beta1 + +import ( + operator "github.com/minio/operator/pkg/apis/sts.min.io" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// Version specifies the API Version +const Version = "v1beta1" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: operator.GroupName, Version: Version} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder collects the scheme builder functions for the MinIO + // Operator API. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme applies the SchemeBuilder functions to a specified scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &PolicyBinding{}, + &PolicyBindingList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/sts.min.io/v1beta1/types.go b/pkg/apis/sts.min.io/v1beta1/types.go new file mode 100644 index 00000000000..d239e56d089 --- /dev/null +++ b/pkg/apis/sts.min.io/v1beta1/types.go @@ -0,0 +1,91 @@ +// Copyright (C) 2024, MinIO, Inc. +// +// This code is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License, version 3, +// as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License, version 3, +// along with this program. If not, see + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:defaulter-gen=true +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Namespaced,shortName=policybinding,singular=policybinding +// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.currentState" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:metadata:annotations=operator.min.io/version=v5.0.15 +// +kubebuilder:storageversion +// +groupName=policybinding.sts.min.io +// +versionName=v1beta1 + +// PolicyBinding is a https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/[Kubernetes object] describing a MinIO PolicyBinding. +type PolicyBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // *Required* + + // + // The root field for the MinIO PolicyBinding object. + Spec PolicyBindingSpec `json:"spec,omitempty"` + + // Status provides details of the state of the PolicyBinding + // +optional + Status PolicyBindingStatus `json:"status,omitempty"` +} + +// PolicyBindingStatus is the status for a PolicyBinding resource +type PolicyBindingStatus struct { + // *Required* + + CurrentState string `json:"currentState"` + + // Keeps track of the invocations related to the PolicyBinding + // +nullable + Usage PolicyBindingUsage `json:"usage"` +} + +// PolicyBindingUsage are metrics regarding the usage of the policyBinding +type PolicyBindingUsage struct { + Authorizations int64 `json:"authotizations,omitempty"` +} + +// PolicyBindingSpec (`spec`) defines the configuration of a MinIO PolicyBinding object. + +type PolicyBindingSpec struct { + // *Required* + + // + // The Application Property identifies the namespace and service account that will be authorized + Application *Application `json:"application"` + // *Required* + + Policies []string `json:"policies"` +} + +// Application defines the `Namespace` and `ServiceAccount` to authorize the usage of the policies listed +type Application struct { + // *Required* + + Namespace string `json:"namespace"` + // *Required* + + ServiceAccount string `json:"serviceaccount"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true + +// PolicyBindingList is a list of PolicyBinding resources +type PolicyBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + + Items []PolicyBinding `json:"items"` +} diff --git a/pkg/apis/sts.min.io/v1beta1/zz_generated.deepcopy.go b/pkg/apis/sts.min.io/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..7c1d2e46736 --- /dev/null +++ b/pkg/apis/sts.min.io/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,162 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +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 *Application) DeepCopyInto(out *Application) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Application. +func (in *Application) DeepCopy() *Application { + if in == nil { + return nil + } + out := new(Application) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PolicyBinding) DeepCopyInto(out *PolicyBinding) { + *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 PolicyBinding. +func (in *PolicyBinding) DeepCopy() *PolicyBinding { + if in == nil { + return nil + } + out := new(PolicyBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PolicyBinding) 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 *PolicyBindingList) DeepCopyInto(out *PolicyBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PolicyBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyBindingList. +func (in *PolicyBindingList) DeepCopy() *PolicyBindingList { + if in == nil { + return nil + } + out := new(PolicyBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PolicyBindingList) 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 *PolicyBindingSpec) DeepCopyInto(out *PolicyBindingSpec) { + *out = *in + if in.Application != nil { + in, out := &in.Application, &out.Application + *out = new(Application) + **out = **in + } + if in.Policies != nil { + in, out := &in.Policies, &out.Policies + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyBindingSpec. +func (in *PolicyBindingSpec) DeepCopy() *PolicyBindingSpec { + if in == nil { + return nil + } + out := new(PolicyBindingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PolicyBindingStatus) DeepCopyInto(out *PolicyBindingStatus) { + *out = *in + out.Usage = in.Usage + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyBindingStatus. +func (in *PolicyBindingStatus) DeepCopy() *PolicyBindingStatus { + if in == nil { + return nil + } + out := new(PolicyBindingStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PolicyBindingUsage) DeepCopyInto(out *PolicyBindingUsage) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PolicyBindingUsage. +func (in *PolicyBindingUsage) DeepCopy() *PolicyBindingUsage { + if in == nil { + return nil + } + out := new(PolicyBindingUsage) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/applyconfiguration/sts.min.io/v1beta1/application.go b/pkg/client/applyconfiguration/sts.min.io/v1beta1/application.go new file mode 100644 index 00000000000..d81b8a37ff0 --- /dev/null +++ b/pkg/client/applyconfiguration/sts.min.io/v1beta1/application.go @@ -0,0 +1,48 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// ApplicationApplyConfiguration represents an declarative configuration of the Application type for use +// with apply. +type ApplicationApplyConfiguration struct { + Namespace *string `json:"namespace,omitempty"` + ServiceAccount *string `json:"serviceaccount,omitempty"` +} + +// ApplicationApplyConfiguration constructs an declarative configuration of the Application type for use with +// apply. +func Application() *ApplicationApplyConfiguration { + return &ApplicationApplyConfiguration{} +} + +// 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 *ApplicationApplyConfiguration) WithNamespace(value string) *ApplicationApplyConfiguration { + b.Namespace = &value + return b +} + +// WithServiceAccount sets the ServiceAccount 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 ServiceAccount field is set to the value of the last call. +func (b *ApplicationApplyConfiguration) WithServiceAccount(value string) *ApplicationApplyConfiguration { + b.ServiceAccount = &value + return b +} diff --git a/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybinding.go b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybinding.go new file mode 100644 index 00000000000..f5c5587641e --- /dev/null +++ b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybinding.go @@ -0,0 +1,219 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// PolicyBindingApplyConfiguration represents an declarative configuration of the PolicyBinding type for use +// with apply. +type PolicyBindingApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *PolicyBindingSpecApplyConfiguration `json:"spec,omitempty"` + Status *PolicyBindingStatusApplyConfiguration `json:"status,omitempty"` +} + +// PolicyBinding constructs an declarative configuration of the PolicyBinding type for use with +// apply. +func PolicyBinding(name, namespace string) *PolicyBindingApplyConfiguration { + b := &PolicyBindingApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("PolicyBinding") + b.WithAPIVersion("sts.min.io/v1beta1") + return b +} + +// 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 *PolicyBindingApplyConfiguration) WithKind(value string) *PolicyBindingApplyConfiguration { + b.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 *PolicyBindingApplyConfiguration) WithAPIVersion(value string) *PolicyBindingApplyConfiguration { + b.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 *PolicyBindingApplyConfiguration) WithName(value string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithGenerateName(value string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithNamespace(value string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithUID(value types.UID) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithResourceVersion(value string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithGeneration(value int64) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithCreationTimestamp(value metav1.Time) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.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 *PolicyBindingApplyConfiguration) WithLabels(entries map[string]string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *PolicyBindingApplyConfiguration) WithAnnotations(entries map[string]string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.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 *PolicyBindingApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.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 *PolicyBindingApplyConfiguration) WithFinalizers(values ...string) *PolicyBindingApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *PolicyBindingApplyConfiguration) 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 *PolicyBindingApplyConfiguration) WithSpec(value *PolicyBindingSpecApplyConfiguration) *PolicyBindingApplyConfiguration { + 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 *PolicyBindingApplyConfiguration) WithStatus(value *PolicyBindingStatusApplyConfiguration) *PolicyBindingApplyConfiguration { + b.Status = value + return b +} diff --git a/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingspec.go b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingspec.go new file mode 100644 index 00000000000..be02e40f1b5 --- /dev/null +++ b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingspec.go @@ -0,0 +1,50 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// PolicyBindingSpecApplyConfiguration represents an declarative configuration of the PolicyBindingSpec type for use +// with apply. +type PolicyBindingSpecApplyConfiguration struct { + Application *ApplicationApplyConfiguration `json:"application,omitempty"` + Policies []string `json:"policies,omitempty"` +} + +// PolicyBindingSpecApplyConfiguration constructs an declarative configuration of the PolicyBindingSpec type for use with +// apply. +func PolicyBindingSpec() *PolicyBindingSpecApplyConfiguration { + return &PolicyBindingSpecApplyConfiguration{} +} + +// WithApplication sets the Application 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 Application field is set to the value of the last call. +func (b *PolicyBindingSpecApplyConfiguration) WithApplication(value *ApplicationApplyConfiguration) *PolicyBindingSpecApplyConfiguration { + b.Application = value + return b +} + +// WithPolicies adds the given value to the Policies 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 Policies field. +func (b *PolicyBindingSpecApplyConfiguration) WithPolicies(values ...string) *PolicyBindingSpecApplyConfiguration { + for i := range values { + b.Policies = append(b.Policies, values[i]) + } + return b +} diff --git a/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingstatus.go b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingstatus.go new file mode 100644 index 00000000000..b703ae2a1c6 --- /dev/null +++ b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingstatus.go @@ -0,0 +1,48 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// PolicyBindingStatusApplyConfiguration represents an declarative configuration of the PolicyBindingStatus type for use +// with apply. +type PolicyBindingStatusApplyConfiguration struct { + CurrentState *string `json:"currentState,omitempty"` + Usage *PolicyBindingUsageApplyConfiguration `json:"usage,omitempty"` +} + +// PolicyBindingStatusApplyConfiguration constructs an declarative configuration of the PolicyBindingStatus type for use with +// apply. +func PolicyBindingStatus() *PolicyBindingStatusApplyConfiguration { + return &PolicyBindingStatusApplyConfiguration{} +} + +// WithCurrentState sets the CurrentState 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 CurrentState field is set to the value of the last call. +func (b *PolicyBindingStatusApplyConfiguration) WithCurrentState(value string) *PolicyBindingStatusApplyConfiguration { + b.CurrentState = &value + return b +} + +// WithUsage sets the Usage 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 Usage field is set to the value of the last call. +func (b *PolicyBindingStatusApplyConfiguration) WithUsage(value *PolicyBindingUsageApplyConfiguration) *PolicyBindingStatusApplyConfiguration { + b.Usage = value + return b +} diff --git a/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingusage.go b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingusage.go new file mode 100644 index 00000000000..e25e4c44360 --- /dev/null +++ b/pkg/client/applyconfiguration/sts.min.io/v1beta1/policybindingusage.go @@ -0,0 +1,39 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// PolicyBindingUsageApplyConfiguration represents an declarative configuration of the PolicyBindingUsage type for use +// with apply. +type PolicyBindingUsageApplyConfiguration struct { + Authorizations *int64 `json:"authotizations,omitempty"` +} + +// PolicyBindingUsageApplyConfiguration constructs an declarative configuration of the PolicyBindingUsage type for use with +// apply. +func PolicyBindingUsage() *PolicyBindingUsageApplyConfiguration { + return &PolicyBindingUsageApplyConfiguration{} +} + +// WithAuthorizations sets the Authorizations 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 Authorizations field is set to the value of the last call. +func (b *PolicyBindingUsageApplyConfiguration) WithAuthorizations(value int64) *PolicyBindingUsageApplyConfiguration { + b.Authorizations = &value + return b +} diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index 466234e27e3..df8d4a6d5d8 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -22,9 +22,11 @@ import ( v1alpha1 "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1" v2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" stsminiov1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + v1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" jobminiov1alpha1 "github.com/minio/operator/pkg/client/applyconfiguration/job.min.io/v1alpha1" miniominiov2 "github.com/minio/operator/pkg/client/applyconfiguration/minio.min.io/v2" applyconfigurationstsminiov1alpha1 "github.com/minio/operator/pkg/client/applyconfiguration/sts.min.io/v1alpha1" + stsminiov1beta1 "github.com/minio/operator/pkg/client/applyconfiguration/sts.min.io/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -102,6 +104,18 @@ func ForKind(kind schema.GroupVersionKind) interface{} { case stsminiov1alpha1.SchemeGroupVersion.WithKind("PolicyBindingUsage"): return &applyconfigurationstsminiov1alpha1.PolicyBindingUsageApplyConfiguration{} + // Group=sts.min.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithKind("Application"): + return &stsminiov1beta1.ApplicationApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("PolicyBinding"): + return &stsminiov1beta1.PolicyBindingApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("PolicyBindingSpec"): + return &stsminiov1beta1.PolicyBindingSpecApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("PolicyBindingStatus"): + return &stsminiov1beta1.PolicyBindingStatusApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("PolicyBindingUsage"): + return &stsminiov1beta1.PolicyBindingUsageApplyConfiguration{} + } return nil } diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 7bd9bdcc99f..7add49efb58 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -25,6 +25,7 @@ import ( jobv1alpha1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/job.min.io/v1alpha1" miniov2 "github.com/minio/operator/pkg/client/clientset/versioned/typed/minio.min.io/v2" stsv1alpha1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1alpha1" + stsv1beta1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -35,6 +36,7 @@ type Interface interface { JobV1alpha1() jobv1alpha1.JobV1alpha1Interface MinioV2() miniov2.MinioV2Interface StsV1alpha1() stsv1alpha1.StsV1alpha1Interface + StsV1beta1() stsv1beta1.StsV1beta1Interface } // Clientset contains the clients for groups. @@ -43,6 +45,7 @@ type Clientset struct { jobV1alpha1 *jobv1alpha1.JobV1alpha1Client minioV2 *miniov2.MinioV2Client stsV1alpha1 *stsv1alpha1.StsV1alpha1Client + stsV1beta1 *stsv1beta1.StsV1beta1Client } // JobV1alpha1 retrieves the JobV1alpha1Client @@ -60,6 +63,11 @@ func (c *Clientset) StsV1alpha1() stsv1alpha1.StsV1alpha1Interface { return c.stsV1alpha1 } +// StsV1beta1 retrieves the StsV1beta1Client +func (c *Clientset) StsV1beta1() stsv1beta1.StsV1beta1Interface { + return c.stsV1beta1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -116,6 +124,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, if err != nil { return nil, err } + cs.stsV1beta1, err = stsv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) if err != nil { @@ -140,6 +152,7 @@ func New(c rest.Interface) *Clientset { cs.jobV1alpha1 = jobv1alpha1.New(c) cs.minioV2 = miniov2.New(c) cs.stsV1alpha1 = stsv1alpha1.New(c) + cs.stsV1beta1 = stsv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 12d1e469ac5..8c1a6ade50b 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -26,6 +26,8 @@ import ( fakeminiov2 "github.com/minio/operator/pkg/client/clientset/versioned/typed/minio.min.io/v2/fake" stsv1alpha1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1alpha1" fakestsv1alpha1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1alpha1/fake" + stsv1beta1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1" + fakestsv1beta1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -97,3 +99,8 @@ func (c *Clientset) MinioV2() miniov2.MinioV2Interface { func (c *Clientset) StsV1alpha1() stsv1alpha1.StsV1alpha1Interface { return &fakestsv1alpha1.FakeStsV1alpha1{Fake: &c.Fake} } + +// StsV1beta1 retrieves the StsV1beta1Client +func (c *Clientset) StsV1beta1() stsv1beta1.StsV1beta1Interface { + return &fakestsv1beta1.FakeStsV1beta1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index f4d3fae6bc9..197fd788beb 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -22,6 +22,7 @@ import ( jobv1alpha1 "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1" miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" stsv1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + stsv1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -36,6 +37,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ jobv1alpha1.AddToScheme, miniov2.AddToScheme, stsv1alpha1.AddToScheme, + stsv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 4964b82af62..5bc973e9528 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -22,6 +22,7 @@ import ( jobv1alpha1 "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1" miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" stsv1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + stsv1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -36,6 +37,7 @@ var localSchemeBuilder = runtime.SchemeBuilder{ jobv1alpha1.AddToScheme, miniov2.AddToScheme, stsv1alpha1.AddToScheme, + stsv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/doc.go new file mode 100644 index 00000000000..781d84d233e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/doc.go @@ -0,0 +1,20 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/doc.go new file mode 100644 index 00000000000..85a59559240 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_policybinding.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_policybinding.go new file mode 100644 index 00000000000..77403b65326 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_policybinding.go @@ -0,0 +1,189 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + v1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" + stsminiov1beta1 "github.com/minio/operator/pkg/client/applyconfiguration/sts.min.io/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePolicyBindings implements PolicyBindingInterface +type FakePolicyBindings struct { + Fake *FakeStsV1beta1 + ns string +} + +var policybindingsResource = v1beta1.SchemeGroupVersion.WithResource("policybindings") + +var policybindingsKind = v1beta1.SchemeGroupVersion.WithKind("PolicyBinding") + +// Get takes name of the policyBinding, and returns the corresponding policyBinding object, and an error if there is any. +func (c *FakePolicyBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.PolicyBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(policybindingsResource, c.ns, name), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} + +// List takes label and field selectors, and returns the list of PolicyBindings that match those selectors. +func (c *FakePolicyBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PolicyBindingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(policybindingsResource, policybindingsKind, c.ns, opts), &v1beta1.PolicyBindingList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.PolicyBindingList{ListMeta: obj.(*v1beta1.PolicyBindingList).ListMeta} + for _, item := range obj.(*v1beta1.PolicyBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested policyBindings. +func (c *FakePolicyBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(policybindingsResource, c.ns, opts)) + +} + +// Create takes the representation of a policyBinding and creates it. Returns the server's representation of the policyBinding, and an error, if there is any. +func (c *FakePolicyBindings) Create(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.CreateOptions) (result *v1beta1.PolicyBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(policybindingsResource, c.ns, policyBinding), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} + +// Update takes the representation of a policyBinding and updates it. Returns the server's representation of the policyBinding, and an error, if there is any. +func (c *FakePolicyBindings) Update(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.UpdateOptions) (result *v1beta1.PolicyBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(policybindingsResource, c.ns, policyBinding), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePolicyBindings) UpdateStatus(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.UpdateOptions) (*v1beta1.PolicyBinding, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(policybindingsResource, "status", c.ns, policyBinding), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} + +// Delete takes name of the policyBinding and deletes it. Returns an error if one occurs. +func (c *FakePolicyBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(policybindingsResource, c.ns, name, opts), &v1beta1.PolicyBinding{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePolicyBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(policybindingsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.PolicyBindingList{}) + return err +} + +// Patch applies the patch and returns the patched policyBinding. +func (c *FakePolicyBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.PolicyBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(policybindingsResource, c.ns, name, pt, data, subresources...), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied policyBinding. +func (c *FakePolicyBindings) Apply(ctx context.Context, policyBinding *stsminiov1beta1.PolicyBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PolicyBinding, err error) { + if policyBinding == nil { + return nil, fmt.Errorf("policyBinding provided to Apply must not be nil") + } + data, err := json.Marshal(policyBinding) + if err != nil { + return nil, err + } + name := policyBinding.Name + if name == nil { + return nil, fmt.Errorf("policyBinding.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(policybindingsResource, c.ns, *name, types.ApplyPatchType, data), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakePolicyBindings) ApplyStatus(ctx context.Context, policyBinding *stsminiov1beta1.PolicyBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PolicyBinding, err error) { + if policyBinding == nil { + return nil, fmt.Errorf("policyBinding provided to Apply must not be nil") + } + data, err := json.Marshal(policyBinding) + if err != nil { + return nil, err + } + name := policyBinding.Name + if name == nil { + return nil, fmt.Errorf("policyBinding.Name must be provided to Apply") + } + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(policybindingsResource, c.ns, *name, types.ApplyPatchType, data, "status"), &v1beta1.PolicyBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.PolicyBinding), err +} diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_sts.min.io_client.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_sts.min.io_client.go new file mode 100644 index 00000000000..ec5ac3c2fd2 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/fake/fake_sts.min.io_client.go @@ -0,0 +1,40 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/minio/operator/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeStsV1beta1 struct { + *testing.Fake +} + +func (c *FakeStsV1beta1) PolicyBindings(namespace string) v1beta1.PolicyBindingInterface { + return &FakePolicyBindings{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeStsV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/generated_expansion.go new file mode 100644 index 00000000000..ec4985dc410 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type PolicyBindingExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/policybinding.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/policybinding.go new file mode 100644 index 00000000000..10e8deb4276 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/policybinding.go @@ -0,0 +1,256 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + json "encoding/json" + "fmt" + "time" + + v1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" + stsminiov1beta1 "github.com/minio/operator/pkg/client/applyconfiguration/sts.min.io/v1beta1" + scheme "github.com/minio/operator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// PolicyBindingsGetter has a method to return a PolicyBindingInterface. +// A group's client should implement this interface. +type PolicyBindingsGetter interface { + PolicyBindings(namespace string) PolicyBindingInterface +} + +// PolicyBindingInterface has methods to work with PolicyBinding resources. +type PolicyBindingInterface interface { + Create(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.CreateOptions) (*v1beta1.PolicyBinding, error) + Update(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.UpdateOptions) (*v1beta1.PolicyBinding, error) + UpdateStatus(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.UpdateOptions) (*v1beta1.PolicyBinding, 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) (*v1beta1.PolicyBinding, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.PolicyBindingList, 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 *v1beta1.PolicyBinding, err error) + Apply(ctx context.Context, policyBinding *stsminiov1beta1.PolicyBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PolicyBinding, err error) + ApplyStatus(ctx context.Context, policyBinding *stsminiov1beta1.PolicyBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PolicyBinding, err error) + PolicyBindingExpansion +} + +// policyBindings implements PolicyBindingInterface +type policyBindings struct { + client rest.Interface + ns string +} + +// newPolicyBindings returns a PolicyBindings +func newPolicyBindings(c *StsV1beta1Client, namespace string) *policyBindings { + return &policyBindings{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the policyBinding, and returns the corresponding policyBinding object, and an error if there is any. +func (c *policyBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.PolicyBinding, err error) { + result = &v1beta1.PolicyBinding{} + err = c.client.Get(). + Namespace(c.ns). + Resource("policybindings"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PolicyBindings that match those selectors. +func (c *policyBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.PolicyBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.PolicyBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("policybindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested policyBindings. +func (c *policyBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("policybindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a policyBinding and creates it. Returns the server's representation of the policyBinding, and an error, if there is any. +func (c *policyBindings) Create(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.CreateOptions) (result *v1beta1.PolicyBinding, err error) { + result = &v1beta1.PolicyBinding{} + err = c.client.Post(). + Namespace(c.ns). + Resource("policybindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(policyBinding). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a policyBinding and updates it. Returns the server's representation of the policyBinding, and an error, if there is any. +func (c *policyBindings) Update(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.UpdateOptions) (result *v1beta1.PolicyBinding, err error) { + result = &v1beta1.PolicyBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("policybindings"). + Name(policyBinding.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(policyBinding). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *policyBindings) UpdateStatus(ctx context.Context, policyBinding *v1beta1.PolicyBinding, opts v1.UpdateOptions) (result *v1beta1.PolicyBinding, err error) { + result = &v1beta1.PolicyBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("policybindings"). + Name(policyBinding.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(policyBinding). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the policyBinding and deletes it. Returns an error if one occurs. +func (c *policyBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("policybindings"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *policyBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("policybindings"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched policyBinding. +func (c *policyBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.PolicyBinding, err error) { + result = &v1beta1.PolicyBinding{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("policybindings"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied policyBinding. +func (c *policyBindings) Apply(ctx context.Context, policyBinding *stsminiov1beta1.PolicyBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PolicyBinding, err error) { + if policyBinding == nil { + return nil, fmt.Errorf("policyBinding provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(policyBinding) + if err != nil { + return nil, err + } + name := policyBinding.Name + if name == nil { + return nil, fmt.Errorf("policyBinding.Name must be provided to Apply") + } + result = &v1beta1.PolicyBinding{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("policybindings"). + Name(*name). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *policyBindings) ApplyStatus(ctx context.Context, policyBinding *stsminiov1beta1.PolicyBindingApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.PolicyBinding, err error) { + if policyBinding == nil { + return nil, fmt.Errorf("policyBinding provided to Apply must not be nil") + } + patchOpts := opts.ToPatchOptions() + data, err := json.Marshal(policyBinding) + if err != nil { + return nil, err + } + + name := policyBinding.Name + if name == nil { + return nil, fmt.Errorf("policyBinding.Name must be provided to Apply") + } + + result = &v1beta1.PolicyBinding{} + err = c.client.Patch(types.ApplyPatchType). + Namespace(c.ns). + Resource("policybindings"). + Name(*name). + SubResource("status"). + VersionedParams(&patchOpts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/sts.min.io_client.go b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/sts.min.io_client.go new file mode 100644 index 00000000000..96bc9d28435 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/sts.min.io/v1beta1/sts.min.io_client.go @@ -0,0 +1,107 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "net/http" + + v1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" + "github.com/minio/operator/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type StsV1beta1Interface interface { + RESTClient() rest.Interface + PolicyBindingsGetter +} + +// StsV1beta1Client is used to interact with features provided by the sts.min.io group. +type StsV1beta1Client struct { + restClient rest.Interface +} + +func (c *StsV1beta1Client) PolicyBindings(namespace string) PolicyBindingInterface { + return newPolicyBindings(c, namespace) +} + +// NewForConfig creates a new StsV1beta1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*StsV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new StsV1beta1Client 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) (*StsV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &StsV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new StsV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *StsV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new StsV1beta1Client for the given RESTClient. +func New(c rest.Interface) *StsV1beta1Client { + return &StsV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *StsV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 6ef90962506..0fa9370ba17 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -24,6 +24,7 @@ import ( v1alpha1 "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1" v2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" stsminiov1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + v1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -66,6 +67,10 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case stsminiov1alpha1.SchemeGroupVersion.WithResource("policybindings"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sts().V1alpha1().PolicyBindings().Informer()}, nil + // Group=sts.min.io, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("policybindings"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Sts().V1beta1().PolicyBindings().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/informers/externalversions/sts.min.io/interface.go b/pkg/client/informers/externalversions/sts.min.io/interface.go index b0c331dcafe..8f69be7a60f 100644 --- a/pkg/client/informers/externalversions/sts.min.io/interface.go +++ b/pkg/client/informers/externalversions/sts.min.io/interface.go @@ -21,12 +21,15 @@ package sts import ( internalinterfaces "github.com/minio/operator/pkg/client/informers/externalversions/internalinterfaces" v1alpha1 "github.com/minio/operator/pkg/client/informers/externalversions/sts.min.io/v1alpha1" + v1beta1 "github.com/minio/operator/pkg/client/informers/externalversions/sts.min.io/v1beta1" ) // 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 + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha1() v1alpha1.Interface { return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/sts.min.io/v1beta1/interface.go b/pkg/client/informers/externalversions/sts.min.io/v1beta1/interface.go new file mode 100644 index 00000000000..2821235feb5 --- /dev/null +++ b/pkg/client/informers/externalversions/sts.min.io/v1beta1/interface.go @@ -0,0 +1,45 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "github.com/minio/operator/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // PolicyBindings returns a PolicyBindingInformer. + PolicyBindings() PolicyBindingInformer +} + +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} +} + +// PolicyBindings returns a PolicyBindingInformer. +func (v *version) PolicyBindings() PolicyBindingInformer { + return &policyBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/sts.min.io/v1beta1/policybinding.go b/pkg/client/informers/externalversions/sts.min.io/v1beta1/policybinding.go new file mode 100644 index 00000000000..0172e7c1645 --- /dev/null +++ b/pkg/client/informers/externalversions/sts.min.io/v1beta1/policybinding.go @@ -0,0 +1,90 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + time "time" + + stsminiov1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" + versioned "github.com/minio/operator/pkg/client/clientset/versioned" + internalinterfaces "github.com/minio/operator/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/minio/operator/pkg/client/listers/sts.min.io/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// PolicyBindingInformer provides access to a shared informer and lister for +// PolicyBindings. +type PolicyBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.PolicyBindingLister +} + +type policyBindingInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPolicyBindingInformer constructs a new informer for PolicyBinding 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 NewPolicyBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPolicyBindingInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPolicyBindingInformer constructs a new informer for PolicyBinding 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 NewFilteredPolicyBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.StsV1beta1().PolicyBindings(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.StsV1beta1().PolicyBindings(namespace).Watch(context.TODO(), options) + }, + }, + &stsminiov1beta1.PolicyBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *policyBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPolicyBindingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *policyBindingInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&stsminiov1beta1.PolicyBinding{}, f.defaultInformer) +} + +func (f *policyBindingInformer) Lister() v1beta1.PolicyBindingLister { + return v1beta1.NewPolicyBindingLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/sts.min.io/v1beta1/expansion_generated.go b/pkg/client/listers/sts.min.io/v1beta1/expansion_generated.go new file mode 100644 index 00000000000..7d149cbdfcd --- /dev/null +++ b/pkg/client/listers/sts.min.io/v1beta1/expansion_generated.go @@ -0,0 +1,27 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +// PolicyBindingListerExpansion allows custom methods to be added to +// PolicyBindingLister. +type PolicyBindingListerExpansion interface{} + +// PolicyBindingNamespaceListerExpansion allows custom methods to be added to +// PolicyBindingNamespaceLister. +type PolicyBindingNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/sts.min.io/v1beta1/policybinding.go b/pkg/client/listers/sts.min.io/v1beta1/policybinding.go new file mode 100644 index 00000000000..baede6f1287 --- /dev/null +++ b/pkg/client/listers/sts.min.io/v1beta1/policybinding.go @@ -0,0 +1,99 @@ +// This file is part of MinIO Operator +// Copyright (c) 2023 MinIO, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PolicyBindingLister helps list PolicyBindings. +// All objects returned here must be treated as read-only. +type PolicyBindingLister interface { + // List lists all PolicyBindings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.PolicyBinding, err error) + // PolicyBindings returns an object that can list and get PolicyBindings. + PolicyBindings(namespace string) PolicyBindingNamespaceLister + PolicyBindingListerExpansion +} + +// policyBindingLister implements the PolicyBindingLister interface. +type policyBindingLister struct { + indexer cache.Indexer +} + +// NewPolicyBindingLister returns a new PolicyBindingLister. +func NewPolicyBindingLister(indexer cache.Indexer) PolicyBindingLister { + return &policyBindingLister{indexer: indexer} +} + +// List lists all PolicyBindings in the indexer. +func (s *policyBindingLister) List(selector labels.Selector) (ret []*v1beta1.PolicyBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.PolicyBinding)) + }) + return ret, err +} + +// PolicyBindings returns an object that can list and get PolicyBindings. +func (s *policyBindingLister) PolicyBindings(namespace string) PolicyBindingNamespaceLister { + return policyBindingNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PolicyBindingNamespaceLister helps list and get PolicyBindings. +// All objects returned here must be treated as read-only. +type PolicyBindingNamespaceLister interface { + // List lists all PolicyBindings in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.PolicyBinding, err error) + // Get retrieves the PolicyBinding from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.PolicyBinding, error) + PolicyBindingNamespaceListerExpansion +} + +// policyBindingNamespaceLister implements the PolicyBindingNamespaceLister +// interface. +type policyBindingNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PolicyBindings in the indexer for a given namespace. +func (s policyBindingNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.PolicyBinding, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.PolicyBinding)) + }) + return ret, err +} + +// Get retrieves the PolicyBinding from the indexer for a given namespace and name. +func (s policyBindingNamespaceLister) Get(name string) (*v1beta1.PolicyBinding, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("policybinding"), name) + } + return obj.(*v1beta1.PolicyBinding), nil +} diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 40f92b2379f..2db7d2cf1a6 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -23,6 +23,8 @@ import ( "syscall" "time" + stsv1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + "github.com/minio/pkg/env" "github.com/minio/operator/pkg" @@ -36,7 +38,7 @@ import ( "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1" v2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" - stsv1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + stsv1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" clientset "github.com/minio/operator/pkg/client/clientset/versioned" informers "github.com/minio/operator/pkg/client/informers/externalversions" promclientset "github.com/prometheus-operator/prometheus-operator/pkg/client/versioned" @@ -76,6 +78,7 @@ func init() { func StartOperator(kubeconfig string) { _ = v2.AddToScheme(scheme.Scheme) _ = v1alpha1.AddToScheme(scheme.Scheme) + _ = stsv1beta1.AddToScheme(scheme.Scheme) _ = stsv1alpha1.AddToScheme(scheme.Scheme) klog.Info("Starting MinIO Operator") // set up signals, so we handle the first shutdown signal gracefully @@ -164,7 +167,7 @@ func StartOperator(kubeconfig string) { kubeInformerFactory.Apps().V1().Deployments(), kubeInformerFactory.Core().V1().Pods(), minioInformerFactory.Minio().V2().Tenants(), - minioInformerFactory.Sts().V1alpha1().PolicyBindings(), + minioInformerFactory.Sts().V1beta1().PolicyBindings(), kubeInformerFactory.Core().V1().Services(), hostsTemplate, pkg.Version, diff --git a/pkg/controller/job-controller.go b/pkg/controller/job-controller.go index 1b66f84d8a5..624be58a374 100644 --- a/pkg/controller/job-controller.go +++ b/pkg/controller/job-controller.go @@ -26,7 +26,7 @@ import ( "github.com/minio/minio-go/v7/pkg/set" "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1" miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" - stsv1alpha1 "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + stsv1beta1 "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" jobinformers "github.com/minio/operator/pkg/client/informers/externalversions/job.min.io/v1alpha1" joblisters "github.com/minio/operator/pkg/client/listers/job.min.io/v1alpha1" "github.com/minio/operator/pkg/utils/miniojob" @@ -241,7 +241,7 @@ func (c *JobController) SyncHandler(key string) (Result, error) { return WrapResult(Result{RequeueAfter: time.Second * 5}, nil) } // check sa - pbs := &stsv1alpha1.PolicyBindingList{} + pbs := &stsv1beta1.PolicyBindingList{} err = c.k8sClient.List(ctx, pbs, client.InNamespace(namespace)) if err != nil { return WrapResult(Result{}, err) diff --git a/pkg/controller/main-controller.go b/pkg/controller/main-controller.go index 5502a7321f4..bdeab2f0ebf 100644 --- a/pkg/controller/main-controller.go +++ b/pkg/controller/main-controller.go @@ -76,7 +76,7 @@ import ( minioscheme "github.com/minio/operator/pkg/client/clientset/versioned/scheme" jobinformers "github.com/minio/operator/pkg/client/informers/externalversions/job.min.io/v1alpha1" informers "github.com/minio/operator/pkg/client/informers/externalversions/minio.min.io/v2" - stsInformers "github.com/minio/operator/pkg/client/informers/externalversions/sts.min.io/v1alpha1" + stsInformers "github.com/minio/operator/pkg/client/informers/externalversions/sts.min.io/v1beta1" "github.com/minio/operator/pkg/resources/statefulsets" ) diff --git a/pkg/controller/sts_handlers.go b/pkg/controller/sts_handlers.go index 505864ca6c0..388c848ecb6 100644 --- a/pkg/controller/sts_handlers.go +++ b/pkg/controller/sts_handlers.go @@ -30,7 +30,7 @@ import ( "github.com/minio/operator/pkg/common" - "github.com/minio/operator/pkg/apis/sts.min.io/v1alpha1" + "github.com/minio/operator/pkg/apis/sts.min.io/v1beta1" iampolicy "github.com/minio/pkg/iam/policy" "github.com/gorilla/mux" @@ -132,8 +132,8 @@ func (c *Controller) AssumeRoleWithWebIdentityHandler(w http.ResponseWriter, r * saName := chunks[1] // Authorized PolicyBindings for the Service Account - policyBindings := []v1alpha1.PolicyBinding{} - pbs, err := c.minioClientSet.StsV1alpha1().PolicyBindings(tenantNamespace).List(ctx, metav1.ListOptions{}) + policyBindings := []v1beta1.PolicyBinding{} + pbs, err := c.minioClientSet.StsV1beta1().PolicyBindings(tenantNamespace).List(ctx, metav1.ListOptions{}) if err != nil { writeSTSErrorResponse(w, true, ErrSTSInternalError, fmt.Errorf("Error obtaining PolicyBindings: %s", err)) return diff --git a/release.sh b/release.sh index 453d2692983..cc5eded865b 100755 --- a/release.sh +++ b/release.sh @@ -55,7 +55,7 @@ done annotations_files=( "pkg/apis/job.min.io/v1alpha1/types.go" "pkg/apis/minio.min.io/v2/types.go" - "pkg/apis/sts.min.io/v1alpha1/types.go" + "pkg/apis/sts.min.io/v1beta1/types.go" ) for file in "${annotations_files[@]}"; do diff --git a/resources/base/crds/sts.min.io_policybindings.yaml b/resources/base/crds/sts.min.io_policybindings.yaml index a2bc9a8aca4..2ef71786929 100644 --- a/resources/base/crds/sts.min.io_policybindings.yaml +++ b/resources/base/crds/sts.min.io_policybindings.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.14.0 + controller-gen.kubebuilder.io/version: v0.15.0 operator.min.io/version: v5.0.15 name: policybindings.sts.min.io spec: @@ -71,6 +71,63 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - additionalPrinterColumns: + - jsonPath: .status.currentState + name: State + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1beta1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + application: + properties: + namespace: + type: string + serviceaccount: + type: string + required: + - namespace + - serviceaccount + type: object + policies: + items: + type: string + type: array + required: + - application + - policies + type: object + status: + properties: + currentState: + type: string + usage: + nullable: true + properties: + authotizations: + format: int64 + type: integer + type: object + required: + - currentState + - usage + type: object + type: object + served: true storage: true subresources: status: {}