From 63b6ba5e9f652ea7e3c7d2b412e43f6b5723c410 Mon Sep 17 00:00:00 2001 From: Luca Burgazzoli Date: Tue, 24 Sep 2024 22:54:14 +0200 Subject: [PATCH] Dapr Kubernetes Operator CRDs should be cluster scope #180 Signed-off-by: Luca Burgazzoli --- PROJECT | 19 +- README.md | 15 +- .../v1alpha1/dapr_control_plane_types.go | 72 ----- .../{v1alpha1 => v1beta1}/common_types.go | 2 +- .../dapr_cruise_control_types.go | 6 +- .../dapr_instance_types.go | 14 +- .../groupversion_info.go | 6 +- .../zz_generated.deepcopy.go | 120 ++------- cmd/run/run.go | 7 +- .../operator.dapr.io_daprcontrolplanes.yaml | 153 ----------- .../operator.dapr.io_daprcruiscontrols.yaml | 9 +- .../bases/operator.dapr.io_daprinstances.yaml | 20 +- config/crd/kustomization.yaml | 1 - ...rnetes-operator.clusterserviceversion.yaml | 10 +- config/rbac/role.yaml | 3 - config/samples/basic/dapr-basic.yaml | 2 +- config/samples/kustomization.yaml | 1 - config/samples/olm/subscription.yaml | 2 +- config/samples/sample-daprcontrolplane.yaml | 8 - config/samples/sample-daprcruisecontrol.yaml | 3 +- config/samples/sample-daprinstance.yaml | 5 +- go.mod | 5 - go.sum | 12 - hack/scripts/gen_bundle.sh | 4 +- hack/scripts/gen_client.sh | 23 +- .../dapr_controlplane_controller.go | 135 ---------- ...pr_controlplane_controller_action_apply.go | 74 ----- ...r_controlplane_controller_action_status.go | 54 ---- .../dapr_controlplane_controller_reconcile.go | 121 --------- .../dapr_controlplane_controller_support.go | 1 - .../dapr_controlplane_controller_type.go | 29 -- .../instance/dapr_instance_controller.go | 3 +- ...r_instance_controller_action_apply_crds.go | 39 ++- ...tance_controller_action_apply_resources.go | 179 ++++-------- .../dapr_instance_controller_action_chart.go | 4 +- ...r_instance_controller_action_conditions.go | 6 +- .../dapr_instance_controller_action_gc.go | 4 +- .../dapr_instance_controller_reconcile.go | 5 +- .../dapr_instance_controller_support.go | 53 +--- .../instance/dapr_instance_controller_type.go | 2 +- .../operator/v1alpha1/daprcontrolplane.go | 218 --------------- .../operator/v1alpha1/daprcontrolplanespec.go | 38 --- .../v1alpha1/daprcontrolplanestatus.go | 72 ----- .../{v1alpha1 => v1beta1}/chartmeta.go | 2 +- .../{v1alpha1 => v1beta1}/chartspec.go | 2 +- .../daprcruisecontrol.go | 13 +- .../daprcruisecontrolstatus.go | 2 +- .../{v1alpha1 => v1beta1}/daprinstance.go | 7 +- .../{v1alpha1 => v1beta1}/daprinstancespec.go | 15 +- .../daprinstancestatus.go | 2 +- .../operator/v1beta1/deploymentspec.go | 38 +++ .../operator/{v1alpha1 => v1beta1}/json.go | 6 +- .../operator/{v1alpha1 => v1beta1}/status.go | 2 +- pkg/client/applyconfiguration/utils.go | 50 ++-- pkg/client/clientset/versioned/clientset.go | 16 +- .../clientset/versioned/scheme/register.go | 4 +- .../operator/v1alpha1/daprcontrolplane.go | 255 ------------------ .../daprcruisecontrol.go | 71 ++--- .../{v1alpha1 => v1beta1}/daprinstance.go | 71 ++--- .../operator/{v1alpha1 => v1beta1}/doc.go | 2 +- .../generated_expansion.go | 4 +- .../{v1alpha1 => v1beta1}/operator_client.go | 47 ++-- .../informers/externalversions/generic.go | 14 +- .../externalversions/operator/interface.go | 12 +- .../operator/v1alpha1/daprcontrolplane.go | 89 ------ .../daprcruisecontrol.go | 29 +- .../{v1alpha1 => v1beta1}/daprinstance.go | 29 +- .../{v1alpha1 => v1beta1}/interface.go | 13 +- .../operator/v1alpha1/daprcontrolplane.go | 98 ------- .../operator/v1alpha1/daprcruisecontrol.go | 98 ------- .../listers/operator/v1alpha1/daprinstance.go | 98 ------- .../operator/v1beta1/daprcruisecontrol.go | 67 +++++ .../listers/operator/v1beta1/daprinstance.go | 67 +++++ .../expansion_generated.go | 18 +- pkg/conditions/conditions_types.go | 1 + pkg/controller/client/client.go | 29 +- pkg/controller/client/types.go | 21 ++ pkg/controller/controller.go | 2 - pkg/controller/predicates/dependant.go | 11 +- pkg/controller/reconciler/types.go | 8 +- pkg/controller/types.go | 2 +- pkg/gvk/gvk.go | 34 +++ pkg/helm/helm.go | 9 +- test/e2e/olm/dapr_olm_test.go | 81 ++---- test/e2e/operator/dapr_controlplane_test.go | 102 ------- test/e2e/operator/dapr_instance_test.go | 100 ++++--- test/support/dapr/support_dapr.go | 2 +- .../support/dapr/support_dapr_controlplane.go | 86 ------ test/support/dapr/support_dapr_instance.go | 43 +-- test/support/olm/support_olm.go | 2 +- test/support/test.go | 2 +- 91 files changed, 702 insertions(+), 2633 deletions(-) delete mode 100644 api/operator/v1alpha1/dapr_control_plane_types.go rename api/operator/{v1alpha1 => v1beta1}/common_types.go (99%) rename api/operator/{v1alpha1 => v1beta1}/dapr_cruise_control_types.go (89%) rename api/operator/{v1alpha1 => v1beta1}/dapr_instance_types.go (83%) rename api/operator/{v1alpha1 => v1beta1}/groupversion_info.go (96%) rename api/operator/{v1alpha1 => v1beta1}/zz_generated.deepcopy.go (76%) delete mode 100644 config/crd/bases/operator.dapr.io_daprcontrolplanes.yaml delete mode 100644 config/samples/sample-daprcontrolplane.yaml delete mode 100644 internal/controller/operator/controlplane/dapr_controlplane_controller.go delete mode 100644 internal/controller/operator/controlplane/dapr_controlplane_controller_action_apply.go delete mode 100644 internal/controller/operator/controlplane/dapr_controlplane_controller_action_status.go delete mode 100644 internal/controller/operator/controlplane/dapr_controlplane_controller_reconcile.go delete mode 100644 internal/controller/operator/controlplane/dapr_controlplane_controller_support.go delete mode 100644 internal/controller/operator/controlplane/dapr_controlplane_controller_type.go delete mode 100644 pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplane.go delete mode 100644 pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanespec.go delete mode 100644 pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanestatus.go rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/chartmeta.go (99%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/chartspec.go (99%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/daprcruisecontrol.go (95%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/daprcruisecontrolstatus.go (99%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/daprinstance.go (98%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/daprinstancespec.go (73%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/daprinstancestatus.go (99%) create mode 100644 pkg/client/applyconfiguration/operator/v1beta1/deploymentspec.go rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/json.go (88%) rename pkg/client/applyconfiguration/operator/{v1alpha1 => v1beta1}/status.go (99%) delete mode 100644 pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcontrolplane.go rename pkg/client/clientset/versioned/typed/operator/{v1alpha1 => v1beta1}/daprcruisecontrol.go (72%) rename pkg/client/clientset/versioned/typed/operator/{v1alpha1 => v1beta1}/daprinstance.go (73%) rename pkg/client/clientset/versioned/typed/operator/{v1alpha1 => v1beta1}/doc.go (97%) rename pkg/client/clientset/versioned/typed/operator/{v1alpha1 => v1beta1}/generated_expansion.go (91%) rename pkg/client/clientset/versioned/typed/operator/{v1alpha1 => v1beta1}/operator_client.go (59%) delete mode 100644 pkg/client/informers/externalversions/operator/v1alpha1/daprcontrolplane.go rename pkg/client/informers/externalversions/operator/{v1alpha1 => v1beta1}/daprcruisecontrol.go (66%) rename pkg/client/informers/externalversions/operator/{v1alpha1 => v1beta1}/daprinstance.go (66%) rename pkg/client/informers/externalversions/operator/{v1alpha1 => v1beta1}/interface.go (74%) delete mode 100644 pkg/client/listers/operator/v1alpha1/daprcontrolplane.go delete mode 100644 pkg/client/listers/operator/v1alpha1/daprcruisecontrol.go delete mode 100644 pkg/client/listers/operator/v1alpha1/daprinstance.go create mode 100644 pkg/client/listers/operator/v1beta1/daprcruisecontrol.go create mode 100644 pkg/client/listers/operator/v1beta1/daprinstance.go rename pkg/client/listers/operator/{v1alpha1 => v1beta1}/expansion_generated.go (56%) create mode 100644 pkg/gvk/gvk.go delete mode 100644 test/e2e/operator/dapr_controlplane_test.go delete mode 100644 test/support/dapr/support_dapr_controlplane.go diff --git a/PROJECT b/PROJECT index 80f4dff..5555f23 100644 --- a/PROJECT +++ b/PROJECT @@ -11,27 +11,16 @@ repo: github.com/dapr/kubernetes-operator resources: - api: crdVersion: v1 - namespaced: true - controller: true - domain: dapr.io - group: operator - kind: DaprControlPlane - path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1 - version: v1alpha1 -- api: - crdVersion: v1 - namespaced: true domain: dapr.io group: operator kind: DaprInstance - path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1 - version: v1alpha1 + path: github.com/dapr/kubernetes-operator/api/operator/v1beta1 + version: v1beta1 - api: crdVersion: v1 - namespaced: true domain: dapr.io group: operator kind: DaprCruiseControl - path: github.com/dapr/kubernetes-operator/api/operator/v1alpha1 - version: v1alpha1 + path: github.com/dapr/kubernetes-operator/api/operator/v1beta1 + version: v1beta1 version: "3" diff --git a/README.md b/README.md index d671958..d2ebb2a 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Kubernetes cluster. The following example shows the most minimal valid manifest to create a new Dapr instance: ```yaml -apiVersion: operator.dapr.io/v1alpha1 +apiVersion: operator.dapr.io/v1beta1 kind: DaprInstance metadata: name: "dapr-instance" @@ -50,16 +50,6 @@ spec: values: {} ``` -```yaml -# Deprecated, use DaprInstance instead -apiVersion: operator.dapr.io/v1alpha1 -kind: DaprControlPlane -metadata: - name: "dapr-control-plane" -spec: - values: {} -``` - The `DaprInstance` resource is a Kubernetes Custom Resource (CRD) that describes the desired state for a given Dapr instance and allows for the configuration of the components that make up the instance. When the `Dapr Kubernetes Operator` sees a new `DaprInstance` resource, the Dapr components are provisioned using Kubernetes resources generated from the official [Dapr Helm Charts](https://github.com/dapr/helm-charts) and managed by the operator. @@ -67,8 +57,7 @@ This means that the same configuration option that are available when [installin When something changes on an existing `DaprInstance` resource or any resource generated by the operator, the operator works to reconfigure the cluster to ensure the actual state of the cluster matches the desired state. > [!IMPORTANT] -> The operator expect that a single `DaprInstance` named `dapr-instance` and placed in the same namespace where the operator runs exists at a given point in time. -> Any additional `DaprInstance` resources will be moved to an `Error` state and ignored. +> The operator expect that a single cluster wide `DaprInstance` named `dapr-instance`. The `DaprInstance` Custom Resource consists of the following properties diff --git a/api/operator/v1alpha1/dapr_control_plane_types.go b/api/operator/v1alpha1/dapr_control_plane_types.go deleted file mode 100644 index cb8bf08..0000000 --- a/api/operator/v1alpha1/dapr_control_plane_types.go +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - "github.com/dapr/kubernetes-operator/pkg/conditions" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type DaprControlPlaneSpec struct { - // +kubebuilder:validation:Optional - Values *JSON `json:"values"` -} - -type DaprControlPlaneStatus struct { - Status `json:",inline"` - Chart *ChartMeta `json:"chart,omitempty"` -} - -// +genclient -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:storageversion -// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`,description="Ready" -// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`,description="Reason" -// +kubebuilder:printcolumn:name="Chart Name",type=string,JSONPath=`.status.chart.name`,description="Chart Name" -// +kubebuilder:printcolumn:name="Chart Repo",type=string,JSONPath=`.status.chart.repo`,description="Chart Repo" -// +kubebuilder:printcolumn:name="Chart Version",type=string,JSONPath=`.status.chart.version`,description="Chart Version" -// +kubebuilder:resource:path=daprcontrolplanes,scope=Namespaced,shortName=dcp,categories=dapr -// +kubebuilder:deprecatedversion:warning="v1alpha1.DaprControlPlane is deprecated, please, use v1alpha1.DaprInstance instead" - -type DaprControlPlane struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec DaprControlPlaneSpec `json:"spec,omitempty"` - Status DaprControlPlaneStatus `json:"status,omitempty"` -} - -func (in *DaprControlPlane) GetStatus() *Status { - return &in.Status.Status -} - -func (in *DaprControlPlane) GetConditions() conditions.Conditions { - return in.Status.Conditions -} - -// +kubebuilder:object:root=true - -type DaprControlPlaneList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []DaprControlPlane `json:"items"` -} - -func init() { - SchemeBuilder.Register(&DaprControlPlane{}, &DaprControlPlaneList{}) -} diff --git a/api/operator/v1alpha1/common_types.go b/api/operator/v1beta1/common_types.go similarity index 99% rename from api/operator/v1alpha1/common_types.go rename to api/operator/v1beta1/common_types.go index 02adc51..0ca5328 100644 --- a/api/operator/v1alpha1/common_types.go +++ b/api/operator/v1beta1/common_types.go @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "encoding/json" diff --git a/api/operator/v1alpha1/dapr_cruise_control_types.go b/api/operator/v1beta1/dapr_cruise_control_types.go similarity index 89% rename from api/operator/v1alpha1/dapr_cruise_control_types.go rename to api/operator/v1beta1/dapr_cruise_control_types.go index 6864016..67fc138 100644 --- a/api/operator/v1alpha1/dapr_cruise_control_types.go +++ b/api/operator/v1beta1/dapr_cruise_control_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "github.com/dapr/kubernetes-operator/pkg/conditions" @@ -32,6 +32,7 @@ type DaprCruiseControlStatus struct { } // +genclient +// +genclient:nonNamespaced // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:storageversion @@ -40,7 +41,8 @@ type DaprCruiseControlStatus struct { // +kubebuilder:printcolumn:name="Chart Name",type=string,JSONPath=`.status.chart.name`,description="Chart Name" // +kubebuilder:printcolumn:name="Chart Repo",type=string,JSONPath=`.status.chart.repo`,description="Chart Repo" // +kubebuilder:printcolumn:name="Chart Version",type=string,JSONPath=`.status.chart.version`,description="Chart Version" -// +kubebuilder:resource:path=daprcruiscontrols,scope=Namespaced,shortName=dcc,categories=dapr +// +kubebuilder:resource:path=daprcruiscontrols,scope=Cluster,shortName=dcc,categories=dapr +// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'dapr-cruise-control'",message="DaprCruiseControl name must be dapr-cruise-control" // DaprCruiseControl is the Schema for the daprcruisecontrols API. type DaprCruiseControl struct { diff --git a/api/operator/v1alpha1/dapr_instance_types.go b/api/operator/v1beta1/dapr_instance_types.go similarity index 83% rename from api/operator/v1alpha1/dapr_instance_types.go rename to api/operator/v1beta1/dapr_instance_types.go index 5ccc241..4e9bce8 100644 --- a/api/operator/v1alpha1/dapr_instance_types.go +++ b/api/operator/v1beta1/dapr_instance_types.go @@ -14,15 +14,23 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "github.com/dapr/kubernetes-operator/pkg/conditions" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +type DeploymentSpec struct { + // +kubebuilder:validation:Required + // Namespace represent the target namespace where the Dapr resources will be installed + Namespace string `json:"namespace,omitempty"` +} + // DaprInstanceSpec defines the desired state of DaprInstance. type DaprInstanceSpec struct { + Deployment DeploymentSpec `json:"deployment"` + // +kubebuilder:validation:Optional Chart *ChartSpec `json:"chart,omitempty"` @@ -37,6 +45,7 @@ type DaprInstanceStatus struct { } // +genclient +// +genclient:nonNamespaced // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:storageversion @@ -45,7 +54,8 @@ type DaprInstanceStatus struct { // +kubebuilder:printcolumn:name="Chart Name",type=string,JSONPath=`.status.chart.name`,description="Chart Name" // +kubebuilder:printcolumn:name="Chart Repo",type=string,JSONPath=`.status.chart.repo`,description="Chart Repo" // +kubebuilder:printcolumn:name="Chart Version",type=string,JSONPath=`.status.chart.version`,description="Chart Version" -// +kubebuilder:resource:path=daprinstances,scope=Namespaced,shortName=di,categories=dapr +// +kubebuilder:resource:path=daprinstances,scope=Cluster,shortName=di,categories=dapr +// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'dapr-instance'",message="DaprInstance name must be dapr-instance" // DaprInstance is the Schema for the daprinstances API. type DaprInstance struct { diff --git a/api/operator/v1alpha1/groupversion_info.go b/api/operator/v1beta1/groupversion_info.go similarity index 96% rename from api/operator/v1alpha1/groupversion_info.go rename to api/operator/v1beta1/groupversion_info.go index 3739983..ff9899f 100644 --- a/api/operator/v1alpha1/groupversion_info.go +++ b/api/operator/v1beta1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the tools v1alpha1 API group +// Package v1alpha1 contains API Schema definitions for the tools v1beta1 API group // +kubebuilder:object:generate=true // +groupName=operator.dapr.io -package v1alpha1 +package v1beta1 import ( "github.com/dapr/kubernetes-operator/api/operator" @@ -27,7 +27,7 @@ import ( var ( // GroupVersion is group version used to register these objects. - GroupVersion = schema.GroupVersion{Group: operator.Group, Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: operator.Group, Version: "v1beta1"} // SchemeGroupVersion is an hack for client gen. SchemeGroupVersion = GroupVersion diff --git a/api/operator/v1alpha1/zz_generated.deepcopy.go b/api/operator/v1beta1/zz_generated.deepcopy.go similarity index 76% rename from api/operator/v1alpha1/zz_generated.deepcopy.go rename to api/operator/v1beta1/zz_generated.deepcopy.go index b1d21c0..3e774b9 100644 --- a/api/operator/v1alpha1/zz_generated.deepcopy.go +++ b/api/operator/v1beta1/zz_generated.deepcopy.go @@ -18,10 +18,10 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -55,106 +55,6 @@ func (in *ChartSpec) DeepCopy() *ChartSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DaprControlPlane) DeepCopyInto(out *DaprControlPlane) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaprControlPlane. -func (in *DaprControlPlane) DeepCopy() *DaprControlPlane { - if in == nil { - return nil - } - out := new(DaprControlPlane) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DaprControlPlane) 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 *DaprControlPlaneList) DeepCopyInto(out *DaprControlPlaneList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]DaprControlPlane, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaprControlPlaneList. -func (in *DaprControlPlaneList) DeepCopy() *DaprControlPlaneList { - if in == nil { - return nil - } - out := new(DaprControlPlaneList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *DaprControlPlaneList) 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 *DaprControlPlaneSpec) DeepCopyInto(out *DaprControlPlaneSpec) { - *out = *in - if in.Values != nil { - in, out := &in.Values, &out.Values - *out = new(JSON) - (*in).DeepCopyInto(*out) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaprControlPlaneSpec. -func (in *DaprControlPlaneSpec) DeepCopy() *DaprControlPlaneSpec { - if in == nil { - return nil - } - out := new(DaprControlPlaneSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DaprControlPlaneStatus) DeepCopyInto(out *DaprControlPlaneStatus) { - *out = *in - in.Status.DeepCopyInto(&out.Status) - if in.Chart != nil { - in, out := &in.Chart, &out.Chart - *out = new(ChartMeta) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaprControlPlaneStatus. -func (in *DaprControlPlaneStatus) DeepCopy() *DaprControlPlaneStatus { - if in == nil { - return nil - } - out := new(DaprControlPlaneStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DaprCruiseControl) DeepCopyInto(out *DaprCruiseControl) { *out = *in @@ -312,6 +212,7 @@ func (in *DaprInstanceList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DaprInstanceSpec) DeepCopyInto(out *DaprInstanceSpec) { *out = *in + out.Deployment = in.Deployment if in.Chart != nil { in, out := &in.Chart, &out.Chart *out = new(ChartSpec) @@ -355,6 +256,21 @@ func (in *DaprInstanceStatus) DeepCopy() *DaprInstanceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentSpec. +func (in *DeploymentSpec) DeepCopy() *DeploymentSpec { + if in == nil { + return nil + } + out := new(DeploymentSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JSON) DeepCopyInto(out *JSON) { *out = *in diff --git a/cmd/run/run.go b/cmd/run/run.go index 4a6eb87..e1a00b4 100644 --- a/cmd/run/run.go +++ b/cmd/run/run.go @@ -5,7 +5,6 @@ import ( "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" - "github.com/dapr/kubernetes-operator/internal/controller/operator/controlplane" "github.com/dapr/kubernetes-operator/internal/controller/operator/instance" "github.com/dapr/kubernetes-operator/pkg/helm" @@ -19,7 +18,7 @@ import ( rtclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/controller" ) @@ -80,10 +79,6 @@ func NewRunCmd() *cobra.Command { co.WatchSelectors = selector return controller.Start(co, func(manager manager.Manager, opts controller.Options) error { - if _, err := controlplane.NewReconciler(cmd.Context(), manager, helmOpts); err != nil { - return fmt.Errorf("unable to set-up DaprControlPlane reconciler: %w", err) - } - if _, err := instance.NewReconciler(cmd.Context(), manager, helmOpts); err != nil { return fmt.Errorf("unable to set-up DaprInstance reconciler: %w", err) } diff --git a/config/crd/bases/operator.dapr.io_daprcontrolplanes.yaml b/config/crd/bases/operator.dapr.io_daprcontrolplanes.yaml deleted file mode 100644 index 8747ec7..0000000 --- a/config/crd/bases/operator.dapr.io_daprcontrolplanes.yaml +++ /dev/null @@ -1,153 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.16.3 - name: daprcontrolplanes.operator.dapr.io -spec: - group: operator.dapr.io - names: - categories: - - dapr - kind: DaprControlPlane - listKind: DaprControlPlaneList - plural: daprcontrolplanes - shortNames: - - dcp - singular: daprcontrolplane - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: Ready - jsonPath: .status.conditions[?(@.type=="Ready")].status - name: Ready - type: string - - description: Reason - jsonPath: .status.conditions[?(@.type=="Ready")].reason - name: Reason - type: string - - description: Chart Name - jsonPath: .status.chart.name - name: Chart Name - type: string - - description: Chart Repo - jsonPath: .status.chart.repo - name: Chart Repo - type: string - - description: Chart Version - jsonPath: .status.chart.version - name: Chart Version - type: string - deprecated: true - deprecationWarning: v1alpha1.DaprControlPlane is deprecated, please, use v1alpha1.DaprInstance - instead - name: v1alpha1 - schema: - openAPIV3Schema: - properties: - apiVersion: - description: |- - APIVersion defines the versioned schema of this representation of an object. - Servers should convert recognized schemas to the latest internal value, and - may reject unrecognized values. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources - type: string - kind: - description: |- - Kind is a string value representing the REST resource this object represents. - Servers may infer this from the endpoint the client submits requests to. - Cannot be updated. - In CamelCase. - More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - type: string - metadata: - type: object - spec: - properties: - values: - description: |- - JSON represents any valid JSON value. - These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil. - x-kubernetes-preserve-unknown-fields: true - type: object - status: - properties: - chart: - properties: - name: - type: string - repo: - type: string - version: - type: string - type: object - conditions: - items: - description: Condition contains details for one aspect of the current - state of this API Resource. - properties: - lastTransitionTime: - description: |- - lastTransitionTime is the last time the condition transitioned from one status to another. - This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: |- - message is a human readable message indicating details about the transition. - This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: |- - observedGeneration represents the .metadata.generation that the condition was set based upon. - For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date - with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: |- - reason contains a programmatic identifier indicating the reason for the condition's last transition. - Producers of specific condition types may define expected values and meanings for this field, - and whether the values are considered a guaranteed API. - The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - observedGeneration: - format: int64 - type: integer - phase: - type: string - required: - - phase - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/bases/operator.dapr.io_daprcruiscontrols.yaml b/config/crd/bases/operator.dapr.io_daprcruiscontrols.yaml index 3d61890..5016336 100644 --- a/config/crd/bases/operator.dapr.io_daprcruiscontrols.yaml +++ b/config/crd/bases/operator.dapr.io_daprcruiscontrols.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.3 + controller-gen.kubebuilder.io/version: v0.16.0 name: daprcruiscontrols.operator.dapr.io spec: group: operator.dapr.io @@ -16,7 +16,7 @@ spec: shortNames: - dcc singular: daprcruisecontrol - scope: Namespaced + scope: Cluster versions: - additionalPrinterColumns: - description: Ready @@ -39,7 +39,7 @@ spec: jsonPath: .status.chart.version name: Chart Version type: string - name: v1alpha1 + name: v1beta1 schema: openAPIV3Schema: description: DaprCruiseControl is the Schema for the daprcruisecontrols API. @@ -141,6 +141,9 @@ spec: - phase type: object type: object + x-kubernetes-validations: + - message: DaprCruiseControl name must be dapr-cruise-control + rule: self.metadata.name == 'dapr-cruise-control' served: true storage: true subresources: diff --git a/config/crd/bases/operator.dapr.io_daprinstances.yaml b/config/crd/bases/operator.dapr.io_daprinstances.yaml index f364b4e..dee4c2d 100644 --- a/config/crd/bases/operator.dapr.io_daprinstances.yaml +++ b/config/crd/bases/operator.dapr.io_daprinstances.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.3 + controller-gen.kubebuilder.io/version: v0.16.0 name: daprinstances.operator.dapr.io spec: group: operator.dapr.io @@ -16,7 +16,7 @@ spec: shortNames: - di singular: daprinstance - scope: Namespaced + scope: Cluster versions: - additionalPrinterColumns: - description: Ready @@ -39,7 +39,7 @@ spec: jsonPath: .status.chart.version name: Chart Version type: string - name: v1alpha1 + name: v1beta1 schema: openAPIV3Schema: description: DaprInstance is the Schema for the daprinstances API. @@ -77,11 +77,22 @@ spec: version: type: string type: object + deployment: + properties: + namespace: + description: Namespace represent the target namespace where the + Dapr resources will be installed + type: string + required: + - namespace + type: object values: description: |- JSON represents any valid JSON value. These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil. x-kubernetes-preserve-unknown-fields: true + required: + - deployment type: object status: description: DaprInstanceStatus defines the observed state of DaprInstance. @@ -160,6 +171,9 @@ spec: - phase type: object type: object + x-kubernetes-validations: + - message: DaprInstance name must be dapr-instance + rule: self.metadata.name == 'dapr-instance' served: true storage: true subresources: diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index f4e0c40..798a152 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -2,7 +2,6 @@ # since it depends on service name and namespace that are out of this kustomize package. # It should be run by config/default resources: -- bases/operator.dapr.io_daprcontrolplanes.yaml - bases/operator.dapr.io_daprinstances.yaml - bases/operator.dapr.io_daprcruiscontrols.yaml #+kubebuilder:scaffold:crdkustomizeresource diff --git a/config/manifests/bases/dapr-kubernetes-operator.clusterserviceversion.yaml b/config/manifests/bases/dapr-kubernetes-operator.clusterserviceversion.yaml index e2812f8..be7df19 100644 --- a/config/manifests/bases/dapr-kubernetes-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/dapr-kubernetes-operator.clusterserviceversion.yaml @@ -16,22 +16,16 @@ spec: apiservicedefinitions: {} customresourcedefinitions: owned: - - description: DaprControlPlane is the Schema for the Dapr ControlPlane API. - displayName: DaprControlPlane - kind: DaprControlPlane - name: daprcontrolplanes.operator.dapr.io - version: v1alpha1 - deprecated: true - description: DaprInstance is the Schema for the Dapr Instance API. displayName: DaprInstance kind: DaprInstance name: daprinstances.operator.dapr.io - version: v1alpha1 + version: v1beta1 - description: DaprCruiseControl is the Schema for the Dapr CruiseControl API. displayName: DaprCruiseControl kind: DaprCruiseControl name: daprcruisecontrols.operator.dapr.io - version: v1alpha1 + version: v1beta1 description: Dapr Control Plane Operator displayName: Dapr Control Plane Operator icon: diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 60522ff..ae08ff5 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -57,7 +57,6 @@ rules: - apiGroups: - operator.dapr.io resources: - - daprcontrolplanes - daprinstances verbs: - create @@ -70,14 +69,12 @@ rules: - apiGroups: - operator.dapr.io resources: - - daprcontrolplanes/finalizers - daprinstances/finalizers verbs: - update - apiGroups: - operator.dapr.io resources: - - daprcontrolplanes/status - daprinstances/status verbs: - get diff --git a/config/samples/basic/dapr-basic.yaml b/config/samples/basic/dapr-basic.yaml index 3620daa..21be6fa 100644 --- a/config/samples/basic/dapr-basic.yaml +++ b/config/samples/basic/dapr-basic.yaml @@ -1,4 +1,4 @@ -apiVersion: operator.dapr.io/v1alpha1 +apiVersion: operator.dapr.io/v1beta1 kind: DaprInstance metadata: name: "dapr-instance" diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 5cf0557..be38541 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,6 +1,5 @@ ## Append samples of your project ## resources: -- sample-daprcontrolplane.yaml - sample-daprinstance.yaml - sample-daprcruisecontrol.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/config/samples/olm/subscription.yaml b/config/samples/olm/subscription.yaml index 975133c..485dbcc 100644 --- a/config/samples/olm/subscription.yaml +++ b/config/samples/olm/subscription.yaml @@ -4,7 +4,7 @@ metadata: name: dapr-control-plane namespace: dapr-system spec: - channel: alpha + channel: beta name: dapr-kubernetes-operator installPlanApproval: Automatic source: daprio-catalog diff --git a/config/samples/sample-daprcontrolplane.yaml b/config/samples/sample-daprcontrolplane.yaml deleted file mode 100644 index 8801d4a..0000000 --- a/config/samples/sample-daprcontrolplane.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: operator.dapr.io/v1alpha1 -kind: DaprControlPlane -metadata: - name: "dapr-control-plane" - namespace: "dapr-system" -spec: - # This object provides access to values passed into the Dpr Helm chart - values: {} diff --git a/config/samples/sample-daprcruisecontrol.yaml b/config/samples/sample-daprcruisecontrol.yaml index edfe5f3..c7dd756 100644 --- a/config/samples/sample-daprcruisecontrol.yaml +++ b/config/samples/sample-daprcruisecontrol.yaml @@ -1,6 +1,5 @@ -apiVersion: operator.dapr.io/v1alpha1 +apiVersion: operator.dapr.io/v1beta1 kind: DaprCruiseControl metadata: name: "dapr-cruise-control" - namespace: "dapr-system" spec: {} diff --git a/config/samples/sample-daprinstance.yaml b/config/samples/sample-daprinstance.yaml index 9b28c46..59d3533 100644 --- a/config/samples/sample-daprinstance.yaml +++ b/config/samples/sample-daprinstance.yaml @@ -1,8 +1,9 @@ -apiVersion: operator.dapr.io/v1alpha1 +apiVersion: operator.dapr.io/v1beta1 kind: DaprInstance metadata: name: "dapr-instance" - namespace: "dapr-system" spec: + deployment: + namespace: "dapr-system" # This object provides access to values passed into the Dpr Helm chart values: {} diff --git a/go.mod b/go.mod index 192f0fb..3857c09 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/operator-framework/operator-lifecycle-manager v0.22.0 github.com/rs/xid v1.6.0 github.com/spf13/cobra v1.8.1 - github.com/wI2L/jsondiff v0.6.0 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/time v0.6.0 gopkg.in/yaml.v3 v3.0.1 @@ -129,10 +128,6 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/cast v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/tidwall/gjson v1.17.1 // indirect - github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.1 // indirect - github.com/tidwall/sjson v1.2.5 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect diff --git a/go.sum b/go.sum index a16bd29..974264a 100644 --- a/go.sum +++ b/go.sum @@ -369,18 +369,6 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= -github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/wI2L/jsondiff v0.6.0 h1:zrsH3FbfVa3JO9llxrcDy/XLkYPLgoMX6Mz3T2PP2AI= -github.com/wI2L/jsondiff v0.6.0/go.mod h1:D6aQ5gKgPF9g17j+E9N7aasmU1O+XvfmWm1y8UMmNpw= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/hack/scripts/gen_bundle.sh b/hack/scripts/gen_bundle.sh index a630419..baebabe 100755 --- a/hack/scripts/gen_bundle.sh +++ b/hack/scripts/gen_bundle.sh @@ -25,8 +25,8 @@ ${PROJECT_ROOT}/bin/kustomize build "${PROJECT_ROOT}/config/manifests" | ${PROJE --overwrite \ --package "${BUNDLE_NAME}" \ --version "${BUNDLE_VERSION}" \ - --channels "alpha" \ - --default-channel "alpha" \ + --channels "beta" \ + --default-channel "beta" \ --output-dir "${BUNDLE_NAME}" echo "Patch bundle metadata" diff --git a/hack/scripts/gen_client.sh b/hack/scripts/gen_client.sh index 55416e3..55309a3 100755 --- a/hack/scripts/gen_client.sh +++ b/hack/scripts/gen_client.sh @@ -17,14 +17,14 @@ echo "applyconfiguration-gen" --go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \ --output-dir="${TMP_DIR}/client/applyconfiguration" \ --output-pkg=github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration \ - github.com/dapr/kubernetes-operator/api/operator/v1alpha1 + github.com/dapr/kubernetes-operator/api/operator/v1beta1 echo "client-gen" "${PROJECT_ROOT}"/bin/client-gen \ --go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \ --output-dir="${TMP_DIR}/client/clientset" \ --input-base=github.com/dapr/kubernetes-operator/api \ - --input=operator/v1alpha1 \ + --input=operator/v1beta1 \ --fake-clientset=false \ --clientset-name "versioned" \ --apply-configuration-package=github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration \ @@ -35,7 +35,7 @@ echo "lister-gen" --go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \ --output-dir="${TMP_DIR}/client/listers" \ --output-pkg=github.com/dapr/kubernetes-operator/pkg/client/listers \ - github.com/dapr/kubernetes-operator/api/operator/v1alpha1 + github.com/dapr/kubernetes-operator/api/operator/v1beta1 echo "informer-gen" "${PROJECT_ROOT}"/bin/informer-gen \ @@ -44,22 +44,19 @@ echo "informer-gen" --versioned-clientset-package=github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned \ --listers-package=github.com/dapr/kubernetes-operator/pkg/client/listers \ --output-pkg=github.com/dapr/kubernetes-operator/pkg/client/informers \ - github.com/dapr/kubernetes-operator/api/operator/v1alpha1 + github.com/dapr/kubernetes-operator/api/operator/v1beta1 # This should not be needed but for some reasons, the applyconfiguration-gen tool -# sets a wrong APIVersion for the Dapr type (operator/v1alpha1 instead of the one with -# the domain operator.dapr.io/v1alpha1). +# sets a wrong APIVersion for the Dapr type (operator/v1beta1 instead of the one with +# the domain operator.dapr.io/v1beta1). # # See: https://github.com/kubernetes/code-generator/issues/150 sed -i \ - 's/WithAPIVersion(\"operator\/v1alpha1\")/WithAPIVersion(\"operator.dapr.io\/v1alpha1\")/g' \ - "${TMP_DIR}"/client/applyconfiguration/operator/v1alpha1/daprcontrolplane.go + 's/WithAPIVersion(\"operator\/v1beta1\")/WithAPIVersion(\"operator.dapr.io\/v1beta1\")/g' \ + "${TMP_DIR}"/client/applyconfiguration/operator/v1beta1/daprinstance.go sed -i \ - 's/WithAPIVersion(\"operator\/v1alpha1\")/WithAPIVersion(\"operator.dapr.io\/v1alpha1\")/g' \ - "${TMP_DIR}"/client/applyconfiguration/operator/v1alpha1/daprinstance.go -sed -i \ - 's/WithAPIVersion(\"operator\/v1alpha1\")/WithAPIVersion(\"operator.dapr.io\/v1alpha1\")/g' \ - "${TMP_DIR}"/client/applyconfiguration/operator/v1alpha1/daprcruisecontrol.go + 's/WithAPIVersion(\"operator\/v1beta1\")/WithAPIVersion(\"operator.dapr.io\/v1beta1\")/g' \ + "${TMP_DIR}"/client/applyconfiguration/operator/v1beta1/daprcruisecontrol.go cp -r \ "${TMP_DIR}"/client/* \ diff --git a/internal/controller/operator/controlplane/dapr_controlplane_controller.go b/internal/controller/operator/controlplane/dapr_controlplane_controller.go deleted file mode 100644 index 901d72a..0000000 --- a/internal/controller/operator/controlplane/dapr_controlplane_controller.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controlplane - -import ( - "context" - "fmt" - - "k8s.io/client-go/tools/record" - - "k8s.io/apimachinery/pkg/runtime" - - "sigs.k8s.io/controller-runtime/pkg/builder" - "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/predicate" - - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - - "github.com/dapr/kubernetes-operator/pkg/controller" - "github.com/dapr/kubernetes-operator/pkg/controller/client" - "github.com/dapr/kubernetes-operator/pkg/controller/reconciler" - "github.com/dapr/kubernetes-operator/pkg/helm" - "github.com/go-logr/logr" - - ctrlRt "sigs.k8s.io/controller-runtime" - ctrl "sigs.k8s.io/controller-runtime/pkg/controller" -) - -func NewReconciler(ctx context.Context, manager ctrlRt.Manager, o helm.Options) (*Reconciler, error) { - c, err := client.NewClient(manager.GetConfig(), manager.GetScheme(), manager.GetClient()) - if err != nil { - //nolint:wrapcheck - return nil, err - } - - rec := Reconciler{} - rec.l = ctrlRt.Log.WithName("dapr-controlplane-controller") - rec.client = c - rec.Scheme = manager.GetScheme() - rec.manager = manager - rec.recorder = manager.GetEventRecorderFor(controller.FieldManager) - - rec.actions = append(rec.actions, NewApplyAction(rec.l)) - rec.actions = append(rec.actions, NewStatusAction(rec.l)) - - err = rec.init(ctx) - if err != nil { - return nil, err - } - - return &rec, nil -} - -// +kubebuilder:rbac:groups=operator.dapr.io,resources=daprcontrolplanes,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.dapr.io,resources=daprcontrolplanes/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=operator.dapr.io,resources=daprcontrolplanes/finalizers,verbs=update -// +kubebuilder:rbac:groups=operator.dapr.io,resources=daprinstances,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=operator.dapr.io,resources=daprinstances/status,verbs=get - -type Reconciler struct { - client *client.Client - Scheme *runtime.Scheme - actions []Action - l logr.Logger - manager ctrlRt.Manager - controller ctrl.Controller - recorder record.EventRecorder -} - -func (r *Reconciler) Client() *client.Client { - return r.client -} - -func (r *Reconciler) init(ctx context.Context) error { - c := ctrlRt.NewControllerManagedBy(r.manager) - - c = c.For(&daprApi.DaprControlPlane{}, builder.WithPredicates( - predicate.Or( - predicate.GenerationChangedPredicate{}, - ))) - - for i := range r.actions { - b, err := r.actions[i].Configure(ctx, r.Client(), c) - if err != nil { - //nolint:wrapcheck - return err - } - - c = b - } - - // by default, the controller expect the DaprControlPlane resource to be created - // in the same namespace where it runs, if not fallback to the default namespace - rec := reconciler.BaseReconciler[*daprApi.DaprControlPlane]{ - Delegate: r, - Client: r.client, - Log: log.FromContext(ctx), - Name: DaprControlPlaneResourceName, - Namespace: controller.OperatorNamespace(), - FinalizerName: DaprControlPlaneFinalizerName, - FinalizerAction: r.Cleanup, - } - - ct, err := c.Build(&rec) - if err != nil { - return fmt.Errorf("failure building the application controller for DaprControlPlane resource: %w", err) - } - - r.controller = ct - - return nil -} - -func (r *Reconciler) Event(object runtime.Object, eventType string, reason string, message string) { - r.recorder.Event( - object, - eventType, - reason, - message, - ) -} diff --git a/internal/controller/operator/controlplane/dapr_controlplane_controller_action_apply.go b/internal/controller/operator/controlplane/dapr_controlplane_controller_action_apply.go deleted file mode 100644 index 8579ca1..0000000 --- a/internal/controller/operator/controlplane/dapr_controlplane_controller_action_apply.go +++ /dev/null @@ -1,74 +0,0 @@ -package controlplane - -import ( - "context" - "fmt" - - "github.com/dapr/kubernetes-operator/pkg/controller" - - "github.com/dapr/kubernetes-operator/pkg/resources" - - "github.com/dapr/kubernetes-operator/internal/controller/operator/instance" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" - - "github.com/dapr/kubernetes-operator/pkg/controller/client" - "github.com/dapr/kubernetes-operator/pkg/controller/predicates" - "github.com/go-logr/logr" - "sigs.k8s.io/controller-runtime/pkg/builder" - "sigs.k8s.io/controller-runtime/pkg/predicate" -) - -func NewApplyAction(l logr.Logger) Action { - return &ApplyAction{ - l: l.WithName("action").WithName("apply"), - subscriptions: make(map[string]struct{}), - } -} - -type ApplyAction struct { - l logr.Logger - subscriptions map[string]struct{} -} - -func (a *ApplyAction) Configure(_ context.Context, _ *client.Client, b *builder.Builder) (*builder.Builder, error) { - b = b.Owns(&daprApi.DaprInstance{}, builder.WithPredicates( - predicate.Or( - predicate.GenerationChangedPredicate{}, - predicates.StatusChanged{}, - ))) - - return b, nil -} - -func (a *ApplyAction) Run(ctx context.Context, rr *ReconciliationRequest) error { - spec := daprAc.DaprInstanceSpec() - - if rr.Resource.Spec.Values != nil { - values := daprAc.JSON() - values.RawMessage = rr.Resource.Spec.Values.RawMessage - - spec = spec.WithValues(values) - } - - _, err := rr.Dapr.OperatorV1alpha1().DaprInstances(rr.Resource.Namespace).Apply( - ctx, - daprAc.DaprInstance(instance.DaprInstanceResourceName, rr.Resource.Namespace). - WithOwnerReferences(resources.WithOwnerReference(rr.Resource)). - WithSpec(spec), - metav1.ApplyOptions{ - FieldManager: controller.FieldManager, - }) - - if err != nil { - return fmt.Errorf("failure to apply changes to %s: %w", rr.NamespacedName, err) - } - - return nil -} - -func (a *ApplyAction) Cleanup(_ context.Context, _ *ReconciliationRequest) error { - return nil -} diff --git a/internal/controller/operator/controlplane/dapr_controlplane_controller_action_status.go b/internal/controller/operator/controlplane/dapr_controlplane_controller_action_status.go deleted file mode 100644 index 0e7d7db..0000000 --- a/internal/controller/operator/controlplane/dapr_controlplane_controller_action_status.go +++ /dev/null @@ -1,54 +0,0 @@ -package controlplane - -import ( - "context" - "fmt" - - "github.com/dapr/kubernetes-operator/internal/controller/operator/instance" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/dapr/kubernetes-operator/pkg/controller/client" - "github.com/go-logr/logr" - "sigs.k8s.io/controller-runtime/pkg/builder" -) - -func NewStatusAction(l logr.Logger) Action { - return &StatusAction{ - l: l.WithName("action").WithName("status"), - } -} - -// StatusAction computes the state of a DaprControlPlane resource out of the owned DaprInstance resource. -type StatusAction struct { - l logr.Logger -} - -func (a *StatusAction) Configure(_ context.Context, _ *client.Client, b *builder.Builder) (*builder.Builder, error) { - return b, nil -} - -func (a *StatusAction) Run(ctx context.Context, rr *ReconciliationRequest) error { - di, err := rr.Dapr.OperatorV1alpha1().DaprInstances(rr.Resource.Namespace).Get( - ctx, - instance.DaprInstanceResourceName, - metav1.GetOptions{}, - ) - - if err != nil && !k8serrors.IsNotFound(err) { - return fmt.Errorf("failure to lookup resource %s: %w", rr.NamespacedName, err) - } - - for i := range di.Status.Conditions { - meta.SetStatusCondition(&rr.Resource.Status.Conditions, di.Status.Conditions[i]) - } - - rr.Resource.Status.Chart = di.Status.Chart - - return nil -} - -func (a *StatusAction) Cleanup(_ context.Context, _ *ReconciliationRequest) error { - return nil -} diff --git a/internal/controller/operator/controlplane/dapr_controlplane_controller_reconcile.go b/internal/controller/operator/controlplane/dapr_controlplane_controller_reconcile.go deleted file mode 100644 index 9883bfe..0000000 --- a/internal/controller/operator/controlplane/dapr_controlplane_controller_reconcile.go +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controlplane - -import ( - "context" - "errors" - "fmt" - "sort" - - "github.com/dapr/kubernetes-operator/pkg/conditions" - - k8serrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/log" - - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" -) - -func (r *Reconciler) reconciliationRequest(res *daprApi.DaprControlPlane) ReconciliationRequest { - return ReconciliationRequest{ - Client: r.Client(), - NamespacedName: types.NamespacedName{ - Name: res.Name, - Namespace: res.Namespace, - }, - Reconciler: r, - Resource: res, - } -} - -func (r *Reconciler) Reconcile(ctx context.Context, res *daprApi.DaprControlPlane) (ctrl.Result, error) { - rr := r.reconciliationRequest(res) - - l := log.FromContext(ctx) - l.Info("Reconciling", "resource", rr.NamespacedName.String()) - - // - // Reconcile - // - - reconcileCondition := metav1.Condition{ - Type: conditions.TypeReconciled, - Status: metav1.ConditionTrue, - Reason: conditions.ReasonReconciled, - Message: conditions.ReasonReconciled, - ObservedGeneration: rr.Resource.Generation, - } - - errs := make([]error, 0, len(r.actions)+1) - - for i := range r.actions { - if err := r.actions[i].Run(ctx, &rr); err != nil { - errs = append(errs, err) - } - } - - if len(errs) > 0 { - reconcileCondition.Status = metav1.ConditionFalse - reconcileCondition.Reason = conditions.ReasonFailure - reconcileCondition.Message = conditions.ReasonFailure - - rr.Resource.Status.Phase = conditions.TypeError - } else { - rr.Resource.Status.ObservedGeneration = rr.Resource.Generation - rr.Resource.Status.Phase = conditions.TypeReady - } - - meta.SetStatusCondition(&rr.Resource.Status.Conditions, reconcileCondition) - - sort.SliceStable(rr.Resource.Status.Conditions, func(i, j int) bool { - return rr.Resource.Status.Conditions[i].Type < rr.Resource.Status.Conditions[j].Type - }) - - // - // Update status - // - - err := r.Client().Status().Update(ctx, rr.Resource) - if err != nil && k8serrors.IsConflict(err) { - l.Info(err.Error()) - return ctrl.Result{Requeue: true}, nil - } else if err != nil { - errs = append(errs, err) - } - - return ctrl.Result{}, errors.Join(errs...) -} - -func (r *Reconciler) Cleanup(ctx context.Context, res *daprApi.DaprControlPlane) error { - rr := r.reconciliationRequest(res) - - l := log.FromContext(ctx) - l.Info("Cleanup", "resource", rr.NamespacedName.String()) - - // Cleanup leftovers if needed - for i := len(r.actions) - 1; i >= 0; i-- { - if err := r.actions[i].Cleanup(ctx, &rr); err != nil { - return fmt.Errorf("failure running cleanup action: %w", err) - } - } - - return nil -} diff --git a/internal/controller/operator/controlplane/dapr_controlplane_controller_support.go b/internal/controller/operator/controlplane/dapr_controlplane_controller_support.go deleted file mode 100644 index 145ce9e..0000000 --- a/internal/controller/operator/controlplane/dapr_controlplane_controller_support.go +++ /dev/null @@ -1 +0,0 @@ -package controlplane diff --git a/internal/controller/operator/controlplane/dapr_controlplane_controller_type.go b/internal/controller/operator/controlplane/dapr_controlplane_controller_type.go deleted file mode 100644 index d0397bc..0000000 --- a/internal/controller/operator/controlplane/dapr_controlplane_controller_type.go +++ /dev/null @@ -1,29 +0,0 @@ -package controlplane - -import ( - "context" - - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - "github.com/dapr/kubernetes-operator/pkg/controller/client" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/builder" -) - -const ( - DaprControlPlaneFinalizerName = "controlplane.operator.dapr.io/finalizer" - DaprControlPlaneResourceName = "dapr-control-plane" -) - -type ReconciliationRequest struct { - *client.Client - types.NamespacedName - - Reconciler *Reconciler - Resource *daprApi.DaprControlPlane -} - -type Action interface { - Configure(ctx context.Context, c *client.Client, b *builder.Builder) (*builder.Builder, error) - Run(ctx context.Context, rc *ReconciliationRequest) error - Cleanup(ctx context.Context, rc *ReconciliationRequest) error -} diff --git a/internal/controller/operator/instance/dapr_instance_controller.go b/internal/controller/operator/instance/dapr_instance_controller.go index b25a964..b705873 100644 --- a/internal/controller/operator/instance/dapr_instance_controller.go +++ b/internal/controller/operator/instance/dapr_instance_controller.go @@ -33,7 +33,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/predicate" - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/controller" "github.com/dapr/kubernetes-operator/pkg/controller/client" @@ -161,7 +161,6 @@ func (r *Reconciler) init(ctx context.Context) error { Client: r.client, Log: log.FromContext(ctx), Name: DaprInstanceResourceName, - Namespace: controller.OperatorNamespace(), FinalizerName: DaprInstanceFinalizerName, FinalizerAction: r.Cleanup, } diff --git a/internal/controller/operator/instance/dapr_instance_controller_action_apply_crds.go b/internal/controller/operator/instance/dapr_instance_controller_action_apply_crds.go index 790231f..7853461 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_action_apply_crds.go +++ b/internal/controller/operator/instance/dapr_instance_controller_action_apply_crds.go @@ -5,6 +5,9 @@ import ( "fmt" "strconv" + "github.com/dapr/kubernetes-operator/pkg/gvk" + ctrcli "sigs.k8s.io/controller-runtime/pkg/client" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" k8serrors "k8s.io/apimachinery/pkg/api/errors" @@ -51,22 +54,29 @@ func (a *ApplyCRDsAction) Run(ctx context.Context, rc *ReconciliationRequest) er return fmt.Errorf("cannot load CRDs: %w", err) } + invalidate := false + for _, crd := range crds { resources.Labels(&crd, map[string]string{ helm.ReleaseGeneration: strconv.FormatInt(rc.Resource.Generation, 10), helm.ReleaseName: rc.Resource.Name, - helm.ReleaseNamespace: rc.Resource.Namespace, helm.ReleaseVersion: c.Version(), }) - err = a.apply(ctx, rc, &crd) + applied, err := a.apply(ctx, rc, &crd) if err != nil { return err } + + if applied { + invalidate = true + } } - // invalidate the client so it gets aware of the new CRDs - rc.Client.Invalidate() + if invalidate { + // invalidate the client so it gets aware of the new CRDs + rc.Client.Invalidate() + } return nil } @@ -75,17 +85,22 @@ func (a *ApplyCRDsAction) Cleanup(_ context.Context, _ *ReconciliationRequest) e return nil } -func (a *ApplyCRDsAction) apply(ctx context.Context, rc *ReconciliationRequest, crd *unstructured.Unstructured) error { - dc, err := rc.Client.Dynamic(rc.Resource.Namespace, crd) +func (a *ApplyCRDsAction) apply(ctx context.Context, rc *ReconciliationRequest, crd *unstructured.Unstructured) (bool, error) { + dc, err := rc.Client.Dynamic(crd) if err != nil { - return fmt.Errorf("cannot create dynamic client: %w", err) + return false, fmt.Errorf("cannot create dynamic client: %w", err) } apply := rc.Resource.Generation != rc.Resource.Status.ObservedGeneration - _, err = dc.Get(ctx, crd.GetName(), metav1.GetOptions{}) + // metadata only retrieval, no need to retrieve the entire CRD as we only need to check + // for its existence + p := metav1.PartialObjectMetadata{} + p.SetGroupVersionKind(gvk.CustomResourceDefinition) + + err = rc.Client.Get(ctx, ctrcli.ObjectKeyFromObject(crd), &p) if err != nil && !k8serrors.IsNotFound(err) { - return fmt.Errorf("cannot determine if CRD %s exists: %w", resources.Ref(crd), err) + return false, fmt.Errorf("cannot determine if CRD %s exists: %w", resources.Ref(crd), err) } if err != nil && k8serrors.IsNotFound(err) { @@ -100,7 +115,7 @@ func (a *ApplyCRDsAction) apply(ctx context.Context, rc *ReconciliationRequest, "generation-changed", rc.Resource.Generation != rc.Resource.Status.ObservedGeneration, "not-found", k8serrors.IsNotFound(err)) - return nil + return false, nil } _, err = dc.Apply(ctx, crd.GetName(), crd, metav1.ApplyOptions{ @@ -109,7 +124,7 @@ func (a *ApplyCRDsAction) apply(ctx context.Context, rc *ReconciliationRequest, }) if err != nil { - return fmt.Errorf("cannot apply CRD %s: %w", resources.Ref(crd), err) + return false, fmt.Errorf("cannot apply CRD %s: %w", resources.Ref(crd), err) } a.l.Info("run", @@ -117,5 +132,5 @@ func (a *ApplyCRDsAction) apply(ctx context.Context, rc *ReconciliationRequest, "gen", rc.Resource.Generation, "ref", resources.Ref(crd)) - return nil + return true, nil } diff --git a/internal/controller/operator/instance/dapr_instance_controller_action_apply_resources.go b/internal/controller/operator/instance/dapr_instance_controller_action_apply_resources.go index a72850e..07a57b2 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_action_apply_resources.go +++ b/internal/controller/operator/instance/dapr_instance_controller_action_apply_resources.go @@ -6,6 +6,8 @@ import ( "sort" "strconv" + "github.com/dapr/kubernetes-operator/pkg/gvk" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "github.com/dapr/kubernetes-operator/pkg/controller/predicates" @@ -19,10 +21,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/handler" - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/controller/client" "github.com/dapr/kubernetes-operator/pkg/helm" - "github.com/dapr/kubernetes-operator/pkg/pointer" "github.com/dapr/kubernetes-operator/pkg/resources" ) @@ -44,23 +45,27 @@ func (a *ApplyResourcesAction) Configure(_ context.Context, _ *client.Client, b return b, nil } +//nolint:funlen func (a *ApplyResourcesAction) Run(ctx context.Context, rc *ReconciliationRequest) error { c, err := rc.Chart(ctx) if err != nil { return fmt.Errorf("cannot load chart: %w", err) } - items, err := c.Render(ctx, rc.Resource.Name, rc.Resource.Namespace, int(rc.Resource.Generation), rc.Helm.ChartValues) + items, err := c.Render( + ctx, + rc.Resource.Name, + rc.Resource.Spec.Deployment.Namespace, + int(rc.Resource.Generation), + rc.Helm.ChartValues, + ) + if err != nil { return fmt.Errorf("cannot render a chart: %w", err) } - // TODO: this must be ordered by priority/relations sort.Slice(items, func(i int, j int) bool { - istr := items[i].GroupVersionKind().Kind + ":" + items[i].GetName() - jstr := items[j].GroupVersionKind().Kind + ":" + items[j].GetName() - - return istr < jstr + return resources.Ref(&items[i]) < resources.Ref(&items[j]) }) installedVersion := "" @@ -75,7 +80,8 @@ func (a *ApplyResourcesAction) Run(ctx context.Context, rc *ReconciliationReques rc.Resource, corev1.EventTypeNormal, "RenderFullHelmTemplate", - fmt.Sprintf("Render full Helm template (observedGeneration: %d, generation: %d, installedChartVersion: %s, chartVersion: %s)", + fmt.Sprintf( + "Render full Helm template (observedGeneration: %d, generation: %d, installedChartVersion: %s, chartVersion: %s)", rc.Resource.Status.ObservedGeneration, rc.Resource.Generation, installedVersion, @@ -87,7 +93,6 @@ func (a *ApplyResourcesAction) Run(ctx context.Context, rc *ReconciliationReques resources.Labels(&obj, map[string]string{ helm.ReleaseGeneration: strconv.FormatInt(rc.Resource.Generation, 10), helm.ReleaseName: rc.Resource.Name, - helm.ReleaseNamespace: rc.Resource.Namespace, helm.ReleaseVersion: c.Version(), }) @@ -106,113 +111,56 @@ func (a *ApplyResourcesAction) Run(ctx context.Context, rc *ReconciliationReques return nil } -func (a *ApplyResourcesAction) Cleanup(ctx context.Context, rc *ReconciliationRequest) error { - c, err := rc.Chart(ctx) - if err != nil { - return fmt.Errorf("cannot load chart: %w", err) - } - - items, err := c.Render(ctx, rc.Resource.Name, rc.Resource.Namespace, int(rc.Resource.Generation), rc.Helm.ChartValues) - if err != nil { - return fmt.Errorf("cannot render a chart: %w", err) - } - - for i := range items { - obj := items[i] - - dc, err := rc.Client.Dynamic(rc.Resource.Namespace, &obj) - if err != nil { - return fmt.Errorf("cannot create dynamic client: %w", err) - } - - // Delete clustered resources - if _, ok := dc.(*client.ClusteredResource); ok { - err := dc.Delete(ctx, obj.GetName(), metav1.DeleteOptions{ - PropagationPolicy: pointer.Any(metav1.DeletePropagationForeground), - }) - - if err != nil && !k8serrors.IsNotFound(err) { - return fmt.Errorf("cannot delete object %s: %w", resources.Ref(&obj), err) - } - - a.l.Info("delete", "ref", resources.Ref(&obj)) - } - } - +func (a *ApplyResourcesAction) Cleanup(_ context.Context, _ *ReconciliationRequest) error { return nil } -func (a *ApplyResourcesAction) watchForUpdates(gvk schema.GroupVersionKind) bool { - if gvk.Group == "" && gvk.Version == "v1" && gvk.Kind == "Secret" { +func (a *ApplyResourcesAction) watchForUpdates(in schema.GroupVersionKind) bool { + switch { + case in == gvk.Secret: return false - } - - if gvk.Group == "admissionregistration.k8s.io" && gvk.Version == "v1" && gvk.Kind == "MutatingWebhookConfiguration" { + case in == gvk.MutatingWebhookConfiguration: return false - } - - if gvk.Group == "apiextensions.k8s.io" && gvk.Version == "v1" && gvk.Kind == "CustomResourceDefinition" { + case in == gvk.CustomResourceDefinition: return false - } - - return true -} - -func (a *ApplyResourcesAction) watchStatus(gvk schema.GroupVersionKind) bool { - if gvk.Group == "apps" && gvk.Version == "v1" && gvk.Kind == "Deployment" { + default: return true } +} - return false +func (a *ApplyResourcesAction) watchStatus(in schema.GroupVersionKind) bool { + return in == gvk.Deployment } -func (a *ApplyResourcesAction) installOnly(gvk schema.GroupVersionKind) bool { - if gvk.Group == "" && gvk.Version == "v1" && gvk.Kind == "Secret" { +func (a *ApplyResourcesAction) installOnly(in schema.GroupVersionKind) bool { + switch { + case in == gvk.Secret: return true - } - - if gvk.Group == "admissionregistration.k8s.io" && gvk.Version == "v1" && gvk.Kind == "MutatingWebhookConfiguration" { + case in == gvk.MutatingWebhookConfiguration: return true - } - - if gvk.Group == "apiextensions.k8s.io" && gvk.Version == "v1" && gvk.Kind == "CustomResourceDefinition" { + case in == gvk.CustomResourceDefinition: return true + default: + return false } - - return false } -//nolint:cyclop -func (a *ApplyResourcesAction) apply(ctx context.Context, rc *ReconciliationRequest, obj *unstructured.Unstructured, force bool) error { - dc, err := rc.Client.Dynamic(rc.Resource.Namespace, obj) +func (a *ApplyResourcesAction) apply(ctx context.Context, rc *ReconciliationRequest, in *unstructured.Unstructured, force bool) error { + obj := in.DeepCopy() + obj.SetNamespace(rc.Resource.Spec.Deployment.Namespace) + obj.SetOwnerReferences(resources.OwnerReferences(rc.Resource)) + + dc, err := rc.Client.Dynamic(obj) if err != nil { return fmt.Errorf("cannot create dynamic client: %w", err) } - switch dc.(type) { - // - // NamespacedResource: in this case, filtering with ownership can be implemented - // as all the namespaced resources created by this controller have the Dapr CR as - // an owner - // - case *client.NamespacedResource: - if err := a.watchNamespaceScopeResource(rc, obj); err != nil { - return err - } + if dc.Scope() == client.ResourceScopeCluster { + obj.SetNamespace("") + } - // - // ClusteredResource: in this case, ownership based filtering is not supported - // as you cannot have a non namespaced owner. For such reason, the resource for - // which a reconcile should be triggered can be identified by using the labels - // added by the controller to all the generated resources - // - // helm.operator.dapr.io/resource.namespace = ${namespace} - // helm.operator.dapr.io/resource.name = ${name} - // - case *client.ClusteredResource: - if err := a.watchClusterScopeResource(rc, obj); err != nil { - return err - } + if err := a.watchResource(rc, obj); err != nil { + return err } if !force { @@ -259,17 +207,14 @@ func (a *ApplyResourcesAction) apply(ctx context.Context, rc *ReconciliationRequ a.l.Info("run", "apply", "true", "gen", rc.Resource.Generation, + "scope", dc.Scope(), "ref", resources.Ref(obj)) return nil } -func (a *ApplyResourcesAction) watchNamespaceScopeResource(rc *ReconciliationRequest, obj *unstructured.Unstructured) error { +func (a *ApplyResourcesAction) watchResource(rc *ReconciliationRequest, obj *unstructured.Unstructured) error { gvk := obj.GroupVersionKind() - - obj.SetOwnerReferences(resources.OwnerReferences(rc.Resource)) - obj.SetNamespace(rc.Resource.Namespace) - r := gvk.GroupVersion().String() + ":" + gvk.Kind if _, ok := a.subscriptions[r]; ok { @@ -277,7 +222,7 @@ func (a *ApplyResourcesAction) watchNamespaceScopeResource(rc *ReconciliationReq } if _, ok := a.subscriptions[r]; !ok { - a.l.Info("watch", "scope", "namespace", "ref", r) + a.l.Info("watch", "ref", r) err := rc.Reconciler.Watch( obj, @@ -298,35 +243,3 @@ func (a *ApplyResourcesAction) watchNamespaceScopeResource(rc *ReconciliationReq return nil } - -func (a *ApplyResourcesAction) watchClusterScopeResource(rc *ReconciliationRequest, obj *unstructured.Unstructured) error { - gvk := obj.GroupVersionKind() - - r := gvk.GroupVersion().String() + ":" + gvk.Kind - - if _, ok := a.subscriptions[r]; ok { - return nil - } - - if _, ok := a.subscriptions[r]; !ok { - a.l.Info("watch", "scope", "cluster", "ref", r) - - err := rc.Reconciler.Watch( - obj, - rc.Reconciler.EnqueueRequestsFromMapFunc(labelsToRequest), - dependantWithLabels( - predicates.WithWatchUpdate(a.watchForUpdates(gvk)), - predicates.WithWatchDeleted(true), - predicates.WithWatchStatus(a.watchStatus(gvk)), - ), - ) - - if err != nil { - return err - } - - a.subscriptions[r] = struct{}{} - } - - return nil -} diff --git a/internal/controller/operator/instance/dapr_instance_controller_action_chart.go b/internal/controller/operator/instance/dapr_instance_controller_action_chart.go index e17bde4..ce6a5ce 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_action_chart.go +++ b/internal/controller/operator/instance/dapr_instance_controller_action_chart.go @@ -4,7 +4,7 @@ import ( "context" "fmt" - "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/controller/client" "github.com/go-logr/logr" helme "github.com/lburgazzoli/k8s-manifests-renderer-helm/engine" @@ -40,7 +40,7 @@ func (a *ChartAction) Run(ctx context.Context, rc *ReconciliationRequest) error } if rc.Resource.Status.Chart == nil { - rc.Resource.Status.Chart = &v1alpha1.ChartMeta{} + rc.Resource.Status.Chart = &v1beta1.ChartMeta{} } rc.Resource.Status.Chart.Repo = ChartRepoEmbedded diff --git a/internal/controller/operator/instance/dapr_instance_controller_action_conditions.go b/internal/controller/operator/instance/dapr_instance_controller_action_conditions.go index eef6146..ad25fd4 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_action_conditions.go +++ b/internal/controller/operator/instance/dapr_instance_controller_action_conditions.go @@ -50,11 +50,11 @@ func (a *ConditionsAction) Run(ctx context.Context, rc *ReconciliationRequest) e var readyCondition metav1.Condition if deployments+statefulSets > 0 { - reason := "Ready" + reason := conditions.ReasonReady status := metav1.ConditionTrue if readyDeployments+readyReplicaSets != deployments+statefulSets { - reason = "InProgress" + reason = conditions.ReasonInProgress status = metav1.ConditionFalse } @@ -71,7 +71,7 @@ func (a *ConditionsAction) Run(ctx context.Context, rc *ReconciliationRequest) e readyCondition = metav1.Condition{ Type: conditions.TypeReady, Status: metav1.ConditionFalse, - Reason: "InProgress", + Reason: conditions.ReasonInProgress, Message: "no deployments/replicasets", ObservedGeneration: rc.Resource.Generation, } diff --git a/internal/controller/operator/instance/dapr_instance_controller_action_gc.go b/internal/controller/operator/instance/dapr_instance_controller_action_gc.go index 5fcac4b..e6fe66d 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_action_gc.go +++ b/internal/controller/operator/instance/dapr_instance_controller_action_gc.go @@ -5,6 +5,8 @@ import ( "fmt" "strconv" + "github.com/dapr/kubernetes-operator/pkg/controller" + "github.com/dapr/kubernetes-operator/pkg/controller/gc" "github.com/dapr/kubernetes-operator/pkg/helm" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -56,7 +58,7 @@ func (a *GCAction) Run(ctx context.Context, rc *ReconciliationRequest) error { return fmt.Errorf("cannot compute gc selector: %w", err) } - deleted, err := a.gc.Run(ctx, rc.Client, rc.Resource.Namespace, s, func(ctx context.Context, obj unstructured.Unstructured) (bool, error) { + deleted, err := a.gc.Run(ctx, rc.Client, controller.OperatorNamespace(), s, func(ctx context.Context, obj unstructured.Unstructured) (bool, error) { if obj.GetLabels() == nil { return false, nil } diff --git a/internal/controller/operator/instance/dapr_instance_controller_reconcile.go b/internal/controller/operator/instance/dapr_instance_controller_reconcile.go index bda1439..3cd1185 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_reconcile.go +++ b/internal/controller/operator/instance/dapr_instance_controller_reconcile.go @@ -34,15 +34,14 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log" - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" ) func (r *Reconciler) reconciliationRequest(res *daprApi.DaprInstance) (ReconciliationRequest, error) { rr := ReconciliationRequest{ Client: r.Client(), NamespacedName: types.NamespacedName{ - Name: res.Name, - Namespace: res.Namespace, + Name: res.Name, }, ClusterType: r.ClusterType, Reconciler: r, diff --git a/internal/controller/operator/instance/dapr_instance_controller_support.go b/internal/controller/operator/instance/dapr_instance_controller_support.go index 0fe1e51..16f28ed 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_support.go +++ b/internal/controller/operator/instance/dapr_instance_controller_support.go @@ -7,14 +7,10 @@ import ( "github.com/dapr/kubernetes-operator/pkg/helm" + "github.com/dapr/kubernetes-operator/pkg/controller/predicates" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" - "k8s.io/apimachinery/pkg/types" - ctrlCli "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/predicate" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - "github.com/dapr/kubernetes-operator/pkg/controller/predicates" ) func gcSelector(ctx context.Context, rc *ReconciliationRequest) (labels.Selector, error) { @@ -23,15 +19,6 @@ func gcSelector(ctx context.Context, rc *ReconciliationRequest) (labels.Selector return nil, fmt.Errorf("cannot load chart: %w", err) } - namespace, err := labels.NewRequirement( - helm.ReleaseNamespace, - selection.Equals, - []string{rc.Resource.Namespace}) - - if err != nil { - return nil, fmt.Errorf("cannot determine release namespace requirement: %w", err) - } - name, err := labels.NewRequirement( helm.ReleaseName, selection.Equals, @@ -60,7 +47,6 @@ func gcSelector(ctx context.Context, rc *ReconciliationRequest) (labels.Selector } selector := labels.NewSelector(). - Add(*namespace). Add(*name). Add(*generation). Add(*version) @@ -68,30 +54,6 @@ func gcSelector(ctx context.Context, rc *ReconciliationRequest) (labels.Selector return selector, nil } -func labelsToRequest(_ context.Context, object ctrlCli.Object) []reconcile.Request { - allLabels := object.GetLabels() - if allLabels == nil { - return nil - } - - name := allLabels[helm.ReleaseName] - if name == "" { - return nil - } - - namespace := allLabels[helm.ReleaseNamespace] - if namespace == "" { - return nil - } - - return []reconcile.Request{{ - NamespacedName: types.NamespacedName{ - Name: name, - Namespace: namespace, - }, - }} -} - func dependantWithLabels(opts ...predicates.DependentPredicateOption) predicate.Predicate { dp := &predicates.DependentPredicate{} @@ -103,9 +65,6 @@ func dependantWithLabels(opts ...predicates.DependentPredicateOption) predicate. &predicates.HasLabel{ Name: helm.ReleaseName, }, - &predicates.HasLabel{ - Name: helm.ReleaseNamespace, - }, dp, ) } @@ -116,15 +75,6 @@ func currentReleaseSelector(ctx context.Context, rc *ReconciliationRequest) (lab return nil, fmt.Errorf("cannot load chart: %w", err) } - namespace, err := labels.NewRequirement( - helm.ReleaseNamespace, - selection.Equals, - []string{rc.Resource.Namespace}) - - if err != nil { - return nil, fmt.Errorf("cannot determine release namespace requirement: %w", err) - } - name, err := labels.NewRequirement( helm.ReleaseName, selection.Equals, @@ -153,7 +103,6 @@ func currentReleaseSelector(ctx context.Context, rc *ReconciliationRequest) (lab } selector := labels.NewSelector(). - Add(*namespace). Add(*name). Add(*generation). Add(*version) diff --git a/internal/controller/operator/instance/dapr_instance_controller_type.go b/internal/controller/operator/instance/dapr_instance_controller_type.go index d57987b..0783bf6 100644 --- a/internal/controller/operator/instance/dapr_instance_controller_type.go +++ b/internal/controller/operator/instance/dapr_instance_controller_type.go @@ -10,7 +10,7 @@ import ( helme "github.com/lburgazzoli/k8s-manifests-renderer-helm/engine" - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/controller" "github.com/dapr/kubernetes-operator/pkg/controller/client" "k8s.io/apimachinery/pkg/types" diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplane.go b/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplane.go deleted file mode 100644 index 34c18de..0000000 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplane.go +++ /dev/null @@ -1,218 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by applyconfiguration-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - v1 "k8s.io/client-go/applyconfigurations/meta/v1" -) - -// DaprControlPlaneApplyConfiguration represents an declarative configuration of the DaprControlPlane type for use -// with apply. -type DaprControlPlaneApplyConfiguration struct { - v1.TypeMetaApplyConfiguration `json:",inline"` - *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *DaprControlPlaneSpecApplyConfiguration `json:"spec,omitempty"` - Status *DaprControlPlaneStatusApplyConfiguration `json:"status,omitempty"` -} - -// DaprControlPlane constructs an declarative configuration of the DaprControlPlane type for use with -// apply. -func DaprControlPlane(name, namespace string) *DaprControlPlaneApplyConfiguration { - b := &DaprControlPlaneApplyConfiguration{} - b.WithName(name) - b.WithNamespace(namespace) - b.WithKind("DaprControlPlane") - b.WithAPIVersion("operator.dapr.io/v1alpha1") - 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 *DaprControlPlaneApplyConfiguration) WithKind(value string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithAPIVersion(value string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithName(value string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithGenerateName(value string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithNamespace(value string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithUID(value types.UID) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithResourceVersion(value string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithGeneration(value int64) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithCreationTimestamp(value metav1.Time) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithLabels(entries map[string]string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithAnnotations(entries map[string]string) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithFinalizers(values ...string) *DaprControlPlaneApplyConfiguration { - b.ensureObjectMetaApplyConfigurationExists() - for i := range values { - b.Finalizers = append(b.Finalizers, values[i]) - } - return b -} - -func (b *DaprControlPlaneApplyConfiguration) 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 *DaprControlPlaneApplyConfiguration) WithSpec(value *DaprControlPlaneSpecApplyConfiguration) *DaprControlPlaneApplyConfiguration { - 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 *DaprControlPlaneApplyConfiguration) WithStatus(value *DaprControlPlaneStatusApplyConfiguration) *DaprControlPlaneApplyConfiguration { - b.Status = value - return b -} diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanespec.go b/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanespec.go deleted file mode 100644 index 975f1f5..0000000 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanespec.go +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by applyconfiguration-gen. DO NOT EDIT. - -package v1alpha1 - -// DaprControlPlaneSpecApplyConfiguration represents an declarative configuration of the DaprControlPlaneSpec type for use -// with apply. -type DaprControlPlaneSpecApplyConfiguration struct { - Values *JSONApplyConfiguration `json:"values,omitempty"` -} - -// DaprControlPlaneSpecApplyConfiguration constructs an declarative configuration of the DaprControlPlaneSpec type for use with -// apply. -func DaprControlPlaneSpec() *DaprControlPlaneSpecApplyConfiguration { - return &DaprControlPlaneSpecApplyConfiguration{} -} - -// WithValues sets the Values 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 Values field is set to the value of the last call. -func (b *DaprControlPlaneSpecApplyConfiguration) WithValues(value *JSONApplyConfiguration) *DaprControlPlaneSpecApplyConfiguration { - b.Values = value - return b -} diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanestatus.go b/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanestatus.go deleted file mode 100644 index 90a31c3..0000000 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprcontrolplanestatus.go +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by applyconfiguration-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1 "k8s.io/client-go/applyconfigurations/meta/v1" -) - -// DaprControlPlaneStatusApplyConfiguration represents an declarative configuration of the DaprControlPlaneStatus type for use -// with apply. -type DaprControlPlaneStatusApplyConfiguration struct { - StatusApplyConfiguration `json:",inline"` - Chart *ChartMetaApplyConfiguration `json:"chart,omitempty"` -} - -// DaprControlPlaneStatusApplyConfiguration constructs an declarative configuration of the DaprControlPlaneStatus type for use with -// apply. -func DaprControlPlaneStatus() *DaprControlPlaneStatusApplyConfiguration { - return &DaprControlPlaneStatusApplyConfiguration{} -} - -// WithPhase sets the Phase 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 Phase field is set to the value of the last call. -func (b *DaprControlPlaneStatusApplyConfiguration) WithPhase(value string) *DaprControlPlaneStatusApplyConfiguration { - b.Phase = &value - return b -} - -// WithConditions adds the given value to the Conditions field in the declarative configuration -// and returns the receiver, so that objects can be build by chaining "With" function invocations. -// If called multiple times, values provided by each call will be appended to the Conditions field. -func (b *DaprControlPlaneStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *DaprControlPlaneStatusApplyConfiguration { - for i := range values { - if values[i] == nil { - panic("nil value passed to WithConditions") - } - b.Conditions = append(b.Conditions, *values[i]) - } - return b -} - -// WithObservedGeneration sets the ObservedGeneration field in the declarative configuration to the given value -// and returns the receiver, so that objects can be built by chaining "With" function invocations. -// If called multiple times, the ObservedGeneration field is set to the value of the last call. -func (b *DaprControlPlaneStatusApplyConfiguration) WithObservedGeneration(value int64) *DaprControlPlaneStatusApplyConfiguration { - b.ObservedGeneration = &value - return b -} - -// WithChart sets the Chart 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 Chart field is set to the value of the last call. -func (b *DaprControlPlaneStatusApplyConfiguration) WithChart(value *ChartMetaApplyConfiguration) *DaprControlPlaneStatusApplyConfiguration { - b.Chart = value - return b -} diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/chartmeta.go b/pkg/client/applyconfiguration/operator/v1beta1/chartmeta.go similarity index 99% rename from pkg/client/applyconfiguration/operator/v1alpha1/chartmeta.go rename to pkg/client/applyconfiguration/operator/v1beta1/chartmeta.go index e5393dd..0b205b8 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/chartmeta.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/chartmeta.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 // ChartMetaApplyConfiguration represents an declarative configuration of the ChartMeta type for use // with apply. diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/chartspec.go b/pkg/client/applyconfiguration/operator/v1beta1/chartspec.go similarity index 99% rename from pkg/client/applyconfiguration/operator/v1alpha1/chartspec.go rename to pkg/client/applyconfiguration/operator/v1beta1/chartspec.go index 93644cf..ac4dfe0 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/chartspec.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/chartspec.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 // ChartSpecApplyConfiguration represents an declarative configuration of the ChartSpec type for use // with apply. diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprcruisecontrol.go b/pkg/client/applyconfiguration/operator/v1beta1/daprcruisecontrol.go similarity index 95% rename from pkg/client/applyconfiguration/operator/v1alpha1/daprcruisecontrol.go rename to pkg/client/applyconfiguration/operator/v1beta1/daprcruisecontrol.go index 45ccf2f..2e0a994 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprcruisecontrol.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/daprcruisecontrol.go @@ -15,10 +15,10 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" v1 "k8s.io/client-go/applyconfigurations/meta/v1" @@ -29,18 +29,17 @@ import ( type DaprCruiseControlApplyConfiguration struct { v1.TypeMetaApplyConfiguration `json:",inline"` *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` - Spec *v1alpha1.DaprCruiseControlSpec `json:"spec,omitempty"` + Spec *v1beta1.DaprCruiseControlSpec `json:"spec,omitempty"` Status *DaprCruiseControlStatusApplyConfiguration `json:"status,omitempty"` } // DaprCruiseControl constructs an declarative configuration of the DaprCruiseControl type for use with // apply. -func DaprCruiseControl(name, namespace string) *DaprCruiseControlApplyConfiguration { +func DaprCruiseControl(name string) *DaprCruiseControlApplyConfiguration { b := &DaprCruiseControlApplyConfiguration{} b.WithName(name) - b.WithNamespace(namespace) b.WithKind("DaprCruiseControl") - b.WithAPIVersion("operator.dapr.io/v1alpha1") + b.WithAPIVersion("operator.dapr.io/v1beta1") return b } @@ -205,7 +204,7 @@ func (b *DaprCruiseControlApplyConfiguration) ensureObjectMetaApplyConfiguration // 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 *DaprCruiseControlApplyConfiguration) WithSpec(value v1alpha1.DaprCruiseControlSpec) *DaprCruiseControlApplyConfiguration { +func (b *DaprCruiseControlApplyConfiguration) WithSpec(value v1beta1.DaprCruiseControlSpec) *DaprCruiseControlApplyConfiguration { b.Spec = &value return b } diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprcruisecontrolstatus.go b/pkg/client/applyconfiguration/operator/v1beta1/daprcruisecontrolstatus.go similarity index 99% rename from pkg/client/applyconfiguration/operator/v1alpha1/daprcruisecontrolstatus.go rename to pkg/client/applyconfiguration/operator/v1beta1/daprcruisecontrolstatus.go index 9f85c4a..1b6bf19 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprcruisecontrolstatus.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/daprcruisecontrolstatus.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprinstance.go b/pkg/client/applyconfiguration/operator/v1beta1/daprinstance.go similarity index 98% rename from pkg/client/applyconfiguration/operator/v1alpha1/daprinstance.go rename to pkg/client/applyconfiguration/operator/v1beta1/daprinstance.go index d038401..0fd7626 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprinstance.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/daprinstance.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -34,12 +34,11 @@ type DaprInstanceApplyConfiguration struct { // DaprInstance constructs an declarative configuration of the DaprInstance type for use with // apply. -func DaprInstance(name, namespace string) *DaprInstanceApplyConfiguration { +func DaprInstance(name string) *DaprInstanceApplyConfiguration { b := &DaprInstanceApplyConfiguration{} b.WithName(name) - b.WithNamespace(namespace) b.WithKind("DaprInstance") - b.WithAPIVersion("operator.dapr.io/v1alpha1") + b.WithAPIVersion("operator.dapr.io/v1beta1") return b } diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprinstancespec.go b/pkg/client/applyconfiguration/operator/v1beta1/daprinstancespec.go similarity index 73% rename from pkg/client/applyconfiguration/operator/v1alpha1/daprinstancespec.go rename to pkg/client/applyconfiguration/operator/v1beta1/daprinstancespec.go index b1c4e2f..f238119 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprinstancespec.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/daprinstancespec.go @@ -15,13 +15,14 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 // DaprInstanceSpecApplyConfiguration represents an declarative configuration of the DaprInstanceSpec type for use // with apply. type DaprInstanceSpecApplyConfiguration struct { - Chart *ChartSpecApplyConfiguration `json:"chart,omitempty"` - Values *JSONApplyConfiguration `json:"values,omitempty"` + Deployment *DeploymentSpecApplyConfiguration `json:"deployment,omitempty"` + Chart *ChartSpecApplyConfiguration `json:"chart,omitempty"` + Values *JSONApplyConfiguration `json:"values,omitempty"` } // DaprInstanceSpecApplyConfiguration constructs an declarative configuration of the DaprInstanceSpec type for use with @@ -30,6 +31,14 @@ func DaprInstanceSpec() *DaprInstanceSpecApplyConfiguration { return &DaprInstanceSpecApplyConfiguration{} } +// WithDeployment sets the Deployment 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 Deployment field is set to the value of the last call. +func (b *DaprInstanceSpecApplyConfiguration) WithDeployment(value *DeploymentSpecApplyConfiguration) *DaprInstanceSpecApplyConfiguration { + b.Deployment = value + return b +} + // WithChart sets the Chart 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 Chart field is set to the value of the last call. diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/daprinstancestatus.go b/pkg/client/applyconfiguration/operator/v1beta1/daprinstancestatus.go similarity index 99% rename from pkg/client/applyconfiguration/operator/v1alpha1/daprinstancestatus.go rename to pkg/client/applyconfiguration/operator/v1beta1/daprinstancestatus.go index 109d6bb..b3e2900 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/daprinstancestatus.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/daprinstancestatus.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" diff --git a/pkg/client/applyconfiguration/operator/v1beta1/deploymentspec.go b/pkg/client/applyconfiguration/operator/v1beta1/deploymentspec.go new file mode 100644 index 0000000..869ebb0 --- /dev/null +++ b/pkg/client/applyconfiguration/operator/v1beta1/deploymentspec.go @@ -0,0 +1,38 @@ +/* +Copyright 2023. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// DeploymentSpecApplyConfiguration represents an declarative configuration of the DeploymentSpec type for use +// with apply. +type DeploymentSpecApplyConfiguration struct { + Namespace *string `json:"namespace,omitempty"` +} + +// DeploymentSpecApplyConfiguration constructs an declarative configuration of the DeploymentSpec type for use with +// apply. +func DeploymentSpec() *DeploymentSpecApplyConfiguration { + return &DeploymentSpecApplyConfiguration{} +} + +// 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 *DeploymentSpecApplyConfiguration) WithNamespace(value string) *DeploymentSpecApplyConfiguration { + b.Namespace = &value + return b +} diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/json.go b/pkg/client/applyconfiguration/operator/v1beta1/json.go similarity index 88% rename from pkg/client/applyconfiguration/operator/v1alpha1/json.go rename to pkg/client/applyconfiguration/operator/v1beta1/json.go index f75d35b..ac20761 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/json.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/json.go @@ -15,16 +15,16 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" ) // JSONApplyConfiguration represents an declarative configuration of the JSON type for use // with apply. type JSONApplyConfiguration struct { - v1alpha1.RawMessage `json:",inline"` + v1beta1.RawMessage `json:",inline"` } // JSONApplyConfiguration constructs an declarative configuration of the JSON type for use with diff --git a/pkg/client/applyconfiguration/operator/v1alpha1/status.go b/pkg/client/applyconfiguration/operator/v1beta1/status.go similarity index 99% rename from pkg/client/applyconfiguration/operator/v1alpha1/status.go rename to pkg/client/applyconfiguration/operator/v1beta1/status.go index 3ba5db2..b3a78e8 100644 --- a/pkg/client/applyconfiguration/operator/v1alpha1/status.go +++ b/pkg/client/applyconfiguration/operator/v1beta1/status.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by applyconfiguration-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( v1 "k8s.io/client-go/applyconfigurations/meta/v1" diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index a25700e..acbe564 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -18,8 +18,8 @@ limitations under the License. package applyconfiguration import ( - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -27,31 +27,27 @@ import ( // apply configuration type exists for the given GroupVersionKind. func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { - // Group=operator, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithKind("ChartMeta"): - return &operatorv1alpha1.ChartMetaApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("ChartSpec"): - return &operatorv1alpha1.ChartSpecApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprControlPlane"): - return &operatorv1alpha1.DaprControlPlaneApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprControlPlaneSpec"): - return &operatorv1alpha1.DaprControlPlaneSpecApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprControlPlaneStatus"): - return &operatorv1alpha1.DaprControlPlaneStatusApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprCruiseControl"): - return &operatorv1alpha1.DaprCruiseControlApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprCruiseControlStatus"): - return &operatorv1alpha1.DaprCruiseControlStatusApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprInstance"): - return &operatorv1alpha1.DaprInstanceApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprInstanceSpec"): - return &operatorv1alpha1.DaprInstanceSpecApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("DaprInstanceStatus"): - return &operatorv1alpha1.DaprInstanceStatusApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("JSON"): - return &operatorv1alpha1.JSONApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("Status"): - return &operatorv1alpha1.StatusApplyConfiguration{} + // Group=operator, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithKind("ChartMeta"): + return &operatorv1beta1.ChartMetaApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("ChartSpec"): + return &operatorv1beta1.ChartSpecApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("DaprCruiseControl"): + return &operatorv1beta1.DaprCruiseControlApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("DaprCruiseControlStatus"): + return &operatorv1beta1.DaprCruiseControlStatusApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("DaprInstance"): + return &operatorv1beta1.DaprInstanceApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("DaprInstanceSpec"): + return &operatorv1beta1.DaprInstanceSpecApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("DaprInstanceStatus"): + return &operatorv1beta1.DaprInstanceStatusApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("DeploymentSpec"): + return &operatorv1beta1.DeploymentSpecApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("JSON"): + return &operatorv1beta1.JSONApplyConfiguration{} + case v1beta1.SchemeGroupVersion.WithKind("Status"): + return &operatorv1beta1.StatusApplyConfiguration{} } return nil diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 9ddeca8..40b0e1f 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -21,7 +21,7 @@ import ( "fmt" "net/http" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned/typed/operator/v1alpha1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned/typed/operator/v1beta1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -29,18 +29,18 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface - OperatorV1alpha1() operatorv1alpha1.OperatorV1alpha1Interface + OperatorV1beta1() operatorv1beta1.OperatorV1beta1Interface } // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient - operatorV1alpha1 *operatorv1alpha1.OperatorV1alpha1Client + operatorV1beta1 *operatorv1beta1.OperatorV1beta1Client } -// OperatorV1alpha1 retrieves the OperatorV1alpha1Client -func (c *Clientset) OperatorV1alpha1() operatorv1alpha1.OperatorV1alpha1Interface { - return c.operatorV1alpha1 +// OperatorV1beta1 retrieves the OperatorV1beta1Client +func (c *Clientset) OperatorV1beta1() operatorv1beta1.OperatorV1beta1Interface { + return c.operatorV1beta1 } // Discovery retrieves the DiscoveryClient @@ -87,7 +87,7 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error - cs.operatorV1alpha1, err = operatorv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + cs.operatorV1beta1, err = operatorv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err } @@ -112,7 +112,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset - cs.operatorV1alpha1 = operatorv1alpha1.New(c) + cs.operatorV1beta1 = operatorv1beta1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 11b9d1c..c61955f 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -18,7 +18,7 @@ limitations under the License. package scheme import ( - operatorv1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,7 +30,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ - operatorv1alpha1.AddToScheme, + operatorv1beta1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcontrolplane.go b/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcontrolplane.go deleted file mode 100644 index 63d65c8..0000000 --- a/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcontrolplane.go +++ /dev/null @@ -1,255 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - json "encoding/json" - "fmt" - "time" - - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" - scheme "github.com/dapr/kubernetes-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" -) - -// DaprControlPlanesGetter has a method to return a DaprControlPlaneInterface. -// A group's client should implement this interface. -type DaprControlPlanesGetter interface { - DaprControlPlanes(namespace string) DaprControlPlaneInterface -} - -// DaprControlPlaneInterface has methods to work with DaprControlPlane resources. -type DaprControlPlaneInterface interface { - Create(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.CreateOptions) (*v1alpha1.DaprControlPlane, error) - Update(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (*v1alpha1.DaprControlPlane, error) - UpdateStatus(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (*v1alpha1.DaprControlPlane, 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) (*v1alpha1.DaprControlPlane, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.DaprControlPlaneList, 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 *v1alpha1.DaprControlPlane, err error) - Apply(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error) - ApplyStatus(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error) - DaprControlPlaneExpansion -} - -// daprControlPlanes implements DaprControlPlaneInterface -type daprControlPlanes struct { - client rest.Interface - ns string -} - -// newDaprControlPlanes returns a DaprControlPlanes -func newDaprControlPlanes(c *OperatorV1alpha1Client, namespace string) *daprControlPlanes { - return &daprControlPlanes{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the daprControlPlane, and returns the corresponding daprControlPlane object, and an error if there is any. -func (c *daprControlPlanes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaprControlPlane, err error) { - result = &v1alpha1.DaprControlPlane{} - err = c.client.Get(). - Namespace(c.ns). - Resource("daprcontrolplanes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of DaprControlPlanes that match those selectors. -func (c *daprControlPlanes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaprControlPlaneList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.DaprControlPlaneList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("daprcontrolplanes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested daprControlPlanes. -func (c *daprControlPlanes) 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("daprcontrolplanes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a daprControlPlane and creates it. Returns the server's representation of the daprControlPlane, and an error, if there is any. -func (c *daprControlPlanes) Create(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.CreateOptions) (result *v1alpha1.DaprControlPlane, err error) { - result = &v1alpha1.DaprControlPlane{} - err = c.client.Post(). - Namespace(c.ns). - Resource("daprcontrolplanes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(daprControlPlane). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a daprControlPlane and updates it. Returns the server's representation of the daprControlPlane, and an error, if there is any. -func (c *daprControlPlanes) Update(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (result *v1alpha1.DaprControlPlane, err error) { - result = &v1alpha1.DaprControlPlane{} - err = c.client.Put(). - Namespace(c.ns). - Resource("daprcontrolplanes"). - Name(daprControlPlane.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(daprControlPlane). - 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 *daprControlPlanes) UpdateStatus(ctx context.Context, daprControlPlane *v1alpha1.DaprControlPlane, opts v1.UpdateOptions) (result *v1alpha1.DaprControlPlane, err error) { - result = &v1alpha1.DaprControlPlane{} - err = c.client.Put(). - Namespace(c.ns). - Resource("daprcontrolplanes"). - Name(daprControlPlane.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(daprControlPlane). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the daprControlPlane and deletes it. Returns an error if one occurs. -func (c *daprControlPlanes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("daprcontrolplanes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *daprControlPlanes) 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("daprcontrolplanes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched daprControlPlane. -func (c *daprControlPlanes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprControlPlane, err error) { - result = &v1alpha1.DaprControlPlane{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("daprcontrolplanes"). - 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 daprControlPlane. -func (c *daprControlPlanes) Apply(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error) { - if daprControlPlane == nil { - return nil, fmt.Errorf("daprControlPlane provided to Apply must not be nil") - } - patchOpts := opts.ToPatchOptions() - data, err := json.Marshal(daprControlPlane) - if err != nil { - return nil, err - } - name := daprControlPlane.Name - if name == nil { - return nil, fmt.Errorf("daprControlPlane.Name must be provided to Apply") - } - result = &v1alpha1.DaprControlPlane{} - err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). - Resource("daprcontrolplanes"). - 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 *daprControlPlanes) ApplyStatus(ctx context.Context, daprControlPlane *operatorv1alpha1.DaprControlPlaneApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprControlPlane, err error) { - if daprControlPlane == nil { - return nil, fmt.Errorf("daprControlPlane provided to Apply must not be nil") - } - patchOpts := opts.ToPatchOptions() - data, err := json.Marshal(daprControlPlane) - if err != nil { - return nil, err - } - - name := daprControlPlane.Name - if name == nil { - return nil, fmt.Errorf("daprControlPlane.Name must be provided to Apply") - } - - result = &v1alpha1.DaprControlPlane{} - err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). - Resource("daprcontrolplanes"). - Name(*name). - SubResource("status"). - VersionedParams(&patchOpts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcruisecontrol.go b/pkg/client/clientset/versioned/typed/operator/v1beta1/daprcruisecontrol.go similarity index 72% rename from pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcruisecontrol.go rename to pkg/client/clientset/versioned/typed/operator/v1beta1/daprcruisecontrol.go index fde5965..d02740d 100644 --- a/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprcruisecontrol.go +++ b/pkg/client/clientset/versioned/typed/operator/v1beta1/daprcruisecontrol.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "context" @@ -23,8 +23,8 @@ import ( "fmt" "time" - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" scheme "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -35,44 +35,41 @@ import ( // DaprCruiseControlsGetter has a method to return a DaprCruiseControlInterface. // A group's client should implement this interface. type DaprCruiseControlsGetter interface { - DaprCruiseControls(namespace string) DaprCruiseControlInterface + DaprCruiseControls() DaprCruiseControlInterface } // DaprCruiseControlInterface has methods to work with DaprCruiseControl resources. type DaprCruiseControlInterface interface { - Create(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.CreateOptions) (*v1alpha1.DaprCruiseControl, error) - Update(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (*v1alpha1.DaprCruiseControl, error) - UpdateStatus(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (*v1alpha1.DaprCruiseControl, error) + Create(ctx context.Context, daprCruiseControl *v1beta1.DaprCruiseControl, opts v1.CreateOptions) (*v1beta1.DaprCruiseControl, error) + Update(ctx context.Context, daprCruiseControl *v1beta1.DaprCruiseControl, opts v1.UpdateOptions) (*v1beta1.DaprCruiseControl, error) + UpdateStatus(ctx context.Context, daprCruiseControl *v1beta1.DaprCruiseControl, opts v1.UpdateOptions) (*v1beta1.DaprCruiseControl, 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) (*v1alpha1.DaprCruiseControl, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.DaprCruiseControlList, error) + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.DaprCruiseControl, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DaprCruiseControlList, 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 *v1alpha1.DaprCruiseControl, err error) - Apply(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error) - ApplyStatus(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DaprCruiseControl, err error) + Apply(ctx context.Context, daprCruiseControl *operatorv1beta1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprCruiseControl, err error) + ApplyStatus(ctx context.Context, daprCruiseControl *operatorv1beta1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprCruiseControl, err error) DaprCruiseControlExpansion } // daprCruiseControls implements DaprCruiseControlInterface type daprCruiseControls struct { client rest.Interface - ns string } // newDaprCruiseControls returns a DaprCruiseControls -func newDaprCruiseControls(c *OperatorV1alpha1Client, namespace string) *daprCruiseControls { +func newDaprCruiseControls(c *OperatorV1beta1Client) *daprCruiseControls { return &daprCruiseControls{ client: c.RESTClient(), - ns: namespace, } } // Get takes name of the daprCruiseControl, and returns the corresponding daprCruiseControl object, and an error if there is any. -func (c *daprCruiseControls) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaprCruiseControl, err error) { - result = &v1alpha1.DaprCruiseControl{} +func (c *daprCruiseControls) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.DaprCruiseControl, err error) { + result = &v1beta1.DaprCruiseControl{} err = c.client.Get(). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(name). VersionedParams(&options, scheme.ParameterCodec). @@ -82,14 +79,13 @@ func (c *daprCruiseControls) Get(ctx context.Context, name string, options v1.Ge } // List takes label and field selectors, and returns the list of DaprCruiseControls that match those selectors. -func (c *daprCruiseControls) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaprCruiseControlList, err error) { +func (c *daprCruiseControls) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DaprCruiseControlList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.DaprCruiseControlList{} + result = &v1beta1.DaprCruiseControlList{} err = c.client.Get(). - Namespace(c.ns). Resource("daprcruisecontrols"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). @@ -106,7 +102,6 @@ func (c *daprCruiseControls) Watch(ctx context.Context, opts v1.ListOptions) (wa } opts.Watch = true return c.client.Get(). - Namespace(c.ns). Resource("daprcruisecontrols"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). @@ -114,10 +109,9 @@ func (c *daprCruiseControls) Watch(ctx context.Context, opts v1.ListOptions) (wa } // Create takes the representation of a daprCruiseControl and creates it. Returns the server's representation of the daprCruiseControl, and an error, if there is any. -func (c *daprCruiseControls) Create(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.CreateOptions) (result *v1alpha1.DaprCruiseControl, err error) { - result = &v1alpha1.DaprCruiseControl{} +func (c *daprCruiseControls) Create(ctx context.Context, daprCruiseControl *v1beta1.DaprCruiseControl, opts v1.CreateOptions) (result *v1beta1.DaprCruiseControl, err error) { + result = &v1beta1.DaprCruiseControl{} err = c.client.Post(). - Namespace(c.ns). Resource("daprcruisecontrols"). VersionedParams(&opts, scheme.ParameterCodec). Body(daprCruiseControl). @@ -127,10 +121,9 @@ func (c *daprCruiseControls) Create(ctx context.Context, daprCruiseControl *v1al } // Update takes the representation of a daprCruiseControl and updates it. Returns the server's representation of the daprCruiseControl, and an error, if there is any. -func (c *daprCruiseControls) Update(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (result *v1alpha1.DaprCruiseControl, err error) { - result = &v1alpha1.DaprCruiseControl{} +func (c *daprCruiseControls) Update(ctx context.Context, daprCruiseControl *v1beta1.DaprCruiseControl, opts v1.UpdateOptions) (result *v1beta1.DaprCruiseControl, err error) { + result = &v1beta1.DaprCruiseControl{} err = c.client.Put(). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(daprCruiseControl.Name). VersionedParams(&opts, scheme.ParameterCodec). @@ -142,10 +135,9 @@ func (c *daprCruiseControls) Update(ctx context.Context, daprCruiseControl *v1al // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *daprCruiseControls) UpdateStatus(ctx context.Context, daprCruiseControl *v1alpha1.DaprCruiseControl, opts v1.UpdateOptions) (result *v1alpha1.DaprCruiseControl, err error) { - result = &v1alpha1.DaprCruiseControl{} +func (c *daprCruiseControls) UpdateStatus(ctx context.Context, daprCruiseControl *v1beta1.DaprCruiseControl, opts v1.UpdateOptions) (result *v1beta1.DaprCruiseControl, err error) { + result = &v1beta1.DaprCruiseControl{} err = c.client.Put(). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(daprCruiseControl.Name). SubResource("status"). @@ -159,7 +151,6 @@ func (c *daprCruiseControls) UpdateStatus(ctx context.Context, daprCruiseControl // Delete takes name of the daprCruiseControl and deletes it. Returns an error if one occurs. func (c *daprCruiseControls) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(name). Body(&opts). @@ -174,7 +165,6 @@ func (c *daprCruiseControls) DeleteCollection(ctx context.Context, opts v1.Delet timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). - Namespace(c.ns). Resource("daprcruisecontrols"). VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). @@ -184,10 +174,9 @@ func (c *daprCruiseControls) DeleteCollection(ctx context.Context, opts v1.Delet } // Patch applies the patch and returns the patched daprCruiseControl. -func (c *daprCruiseControls) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprCruiseControl, err error) { - result = &v1alpha1.DaprCruiseControl{} +func (c *daprCruiseControls) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DaprCruiseControl, err error) { + result = &v1beta1.DaprCruiseControl{} err = c.client.Patch(pt). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(name). SubResource(subresources...). @@ -199,7 +188,7 @@ func (c *daprCruiseControls) Patch(ctx context.Context, name string, pt types.Pa } // Apply takes the given apply declarative configuration, applies it and returns the applied daprCruiseControl. -func (c *daprCruiseControls) Apply(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error) { +func (c *daprCruiseControls) Apply(ctx context.Context, daprCruiseControl *operatorv1beta1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprCruiseControl, err error) { if daprCruiseControl == nil { return nil, fmt.Errorf("daprCruiseControl provided to Apply must not be nil") } @@ -212,9 +201,8 @@ func (c *daprCruiseControls) Apply(ctx context.Context, daprCruiseControl *opera if name == nil { return nil, fmt.Errorf("daprCruiseControl.Name must be provided to Apply") } - result = &v1alpha1.DaprCruiseControl{} + result = &v1beta1.DaprCruiseControl{} err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(*name). VersionedParams(&patchOpts, scheme.ParameterCodec). @@ -226,7 +214,7 @@ func (c *daprCruiseControls) Apply(ctx context.Context, daprCruiseControl *opera // ApplyStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -func (c *daprCruiseControls) ApplyStatus(ctx context.Context, daprCruiseControl *operatorv1alpha1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprCruiseControl, err error) { +func (c *daprCruiseControls) ApplyStatus(ctx context.Context, daprCruiseControl *operatorv1beta1.DaprCruiseControlApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprCruiseControl, err error) { if daprCruiseControl == nil { return nil, fmt.Errorf("daprCruiseControl provided to Apply must not be nil") } @@ -241,9 +229,8 @@ func (c *daprCruiseControls) ApplyStatus(ctx context.Context, daprCruiseControl return nil, fmt.Errorf("daprCruiseControl.Name must be provided to Apply") } - result = &v1alpha1.DaprCruiseControl{} + result = &v1beta1.DaprCruiseControl{} err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). Resource("daprcruisecontrols"). Name(*name). SubResource("status"). diff --git a/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprinstance.go b/pkg/client/clientset/versioned/typed/operator/v1beta1/daprinstance.go similarity index 73% rename from pkg/client/clientset/versioned/typed/operator/v1alpha1/daprinstance.go rename to pkg/client/clientset/versioned/typed/operator/v1beta1/daprinstance.go index 4ef63cb..546b983 100644 --- a/pkg/client/clientset/versioned/typed/operator/v1alpha1/daprinstance.go +++ b/pkg/client/clientset/versioned/typed/operator/v1beta1/daprinstance.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "context" @@ -23,8 +23,8 @@ import ( "fmt" "time" - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" scheme "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -35,44 +35,41 @@ import ( // DaprInstancesGetter has a method to return a DaprInstanceInterface. // A group's client should implement this interface. type DaprInstancesGetter interface { - DaprInstances(namespace string) DaprInstanceInterface + DaprInstances() DaprInstanceInterface } // DaprInstanceInterface has methods to work with DaprInstance resources. type DaprInstanceInterface interface { - Create(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.CreateOptions) (*v1alpha1.DaprInstance, error) - Update(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (*v1alpha1.DaprInstance, error) - UpdateStatus(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (*v1alpha1.DaprInstance, error) + Create(ctx context.Context, daprInstance *v1beta1.DaprInstance, opts v1.CreateOptions) (*v1beta1.DaprInstance, error) + Update(ctx context.Context, daprInstance *v1beta1.DaprInstance, opts v1.UpdateOptions) (*v1beta1.DaprInstance, error) + UpdateStatus(ctx context.Context, daprInstance *v1beta1.DaprInstance, opts v1.UpdateOptions) (*v1beta1.DaprInstance, 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) (*v1alpha1.DaprInstance, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.DaprInstanceList, error) + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.DaprInstance, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.DaprInstanceList, 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 *v1alpha1.DaprInstance, err error) - Apply(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error) - ApplyStatus(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DaprInstance, err error) + Apply(ctx context.Context, daprInstance *operatorv1beta1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprInstance, err error) + ApplyStatus(ctx context.Context, daprInstance *operatorv1beta1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprInstance, err error) DaprInstanceExpansion } // daprInstances implements DaprInstanceInterface type daprInstances struct { client rest.Interface - ns string } // newDaprInstances returns a DaprInstances -func newDaprInstances(c *OperatorV1alpha1Client, namespace string) *daprInstances { +func newDaprInstances(c *OperatorV1beta1Client) *daprInstances { return &daprInstances{ client: c.RESTClient(), - ns: namespace, } } // Get takes name of the daprInstance, and returns the corresponding daprInstance object, and an error if there is any. -func (c *daprInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaprInstance, err error) { - result = &v1alpha1.DaprInstance{} +func (c *daprInstances) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.DaprInstance, err error) { + result = &v1beta1.DaprInstance{} err = c.client.Get(). - Namespace(c.ns). Resource("daprinstances"). Name(name). VersionedParams(&options, scheme.ParameterCodec). @@ -82,14 +79,13 @@ func (c *daprInstances) Get(ctx context.Context, name string, options v1.GetOpti } // List takes label and field selectors, and returns the list of DaprInstances that match those selectors. -func (c *daprInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.DaprInstanceList, err error) { +func (c *daprInstances) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DaprInstanceList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1alpha1.DaprInstanceList{} + result = &v1beta1.DaprInstanceList{} err = c.client.Get(). - Namespace(c.ns). Resource("daprinstances"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). @@ -106,7 +102,6 @@ func (c *daprInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.I } opts.Watch = true return c.client.Get(). - Namespace(c.ns). Resource("daprinstances"). VersionedParams(&opts, scheme.ParameterCodec). Timeout(timeout). @@ -114,10 +109,9 @@ func (c *daprInstances) Watch(ctx context.Context, opts v1.ListOptions) (watch.I } // Create takes the representation of a daprInstance and creates it. Returns the server's representation of the daprInstance, and an error, if there is any. -func (c *daprInstances) Create(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.CreateOptions) (result *v1alpha1.DaprInstance, err error) { - result = &v1alpha1.DaprInstance{} +func (c *daprInstances) Create(ctx context.Context, daprInstance *v1beta1.DaprInstance, opts v1.CreateOptions) (result *v1beta1.DaprInstance, err error) { + result = &v1beta1.DaprInstance{} err = c.client.Post(). - Namespace(c.ns). Resource("daprinstances"). VersionedParams(&opts, scheme.ParameterCodec). Body(daprInstance). @@ -127,10 +121,9 @@ func (c *daprInstances) Create(ctx context.Context, daprInstance *v1alpha1.DaprI } // Update takes the representation of a daprInstance and updates it. Returns the server's representation of the daprInstance, and an error, if there is any. -func (c *daprInstances) Update(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (result *v1alpha1.DaprInstance, err error) { - result = &v1alpha1.DaprInstance{} +func (c *daprInstances) Update(ctx context.Context, daprInstance *v1beta1.DaprInstance, opts v1.UpdateOptions) (result *v1beta1.DaprInstance, err error) { + result = &v1beta1.DaprInstance{} err = c.client.Put(). - Namespace(c.ns). Resource("daprinstances"). Name(daprInstance.Name). VersionedParams(&opts, scheme.ParameterCodec). @@ -142,10 +135,9 @@ func (c *daprInstances) Update(ctx context.Context, daprInstance *v1alpha1.DaprI // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *daprInstances) UpdateStatus(ctx context.Context, daprInstance *v1alpha1.DaprInstance, opts v1.UpdateOptions) (result *v1alpha1.DaprInstance, err error) { - result = &v1alpha1.DaprInstance{} +func (c *daprInstances) UpdateStatus(ctx context.Context, daprInstance *v1beta1.DaprInstance, opts v1.UpdateOptions) (result *v1beta1.DaprInstance, err error) { + result = &v1beta1.DaprInstance{} err = c.client.Put(). - Namespace(c.ns). Resource("daprinstances"). Name(daprInstance.Name). SubResource("status"). @@ -159,7 +151,6 @@ func (c *daprInstances) UpdateStatus(ctx context.Context, daprInstance *v1alpha1 // Delete takes name of the daprInstance and deletes it. Returns an error if one occurs. func (c *daprInstances) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { return c.client.Delete(). - Namespace(c.ns). Resource("daprinstances"). Name(name). Body(&opts). @@ -174,7 +165,6 @@ func (c *daprInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOpti timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second } return c.client.Delete(). - Namespace(c.ns). Resource("daprinstances"). VersionedParams(&listOpts, scheme.ParameterCodec). Timeout(timeout). @@ -184,10 +174,9 @@ func (c *daprInstances) DeleteCollection(ctx context.Context, opts v1.DeleteOpti } // Patch applies the patch and returns the patched daprInstance. -func (c *daprInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.DaprInstance, err error) { - result = &v1alpha1.DaprInstance{} +func (c *daprInstances) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DaprInstance, err error) { + result = &v1beta1.DaprInstance{} err = c.client.Patch(pt). - Namespace(c.ns). Resource("daprinstances"). Name(name). SubResource(subresources...). @@ -199,7 +188,7 @@ func (c *daprInstances) Patch(ctx context.Context, name string, pt types.PatchTy } // Apply takes the given apply declarative configuration, applies it and returns the applied daprInstance. -func (c *daprInstances) Apply(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error) { +func (c *daprInstances) Apply(ctx context.Context, daprInstance *operatorv1beta1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprInstance, err error) { if daprInstance == nil { return nil, fmt.Errorf("daprInstance provided to Apply must not be nil") } @@ -212,9 +201,8 @@ func (c *daprInstances) Apply(ctx context.Context, daprInstance *operatorv1alpha if name == nil { return nil, fmt.Errorf("daprInstance.Name must be provided to Apply") } - result = &v1alpha1.DaprInstance{} + result = &v1beta1.DaprInstance{} err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). Resource("daprinstances"). Name(*name). VersionedParams(&patchOpts, scheme.ParameterCodec). @@ -226,7 +214,7 @@ func (c *daprInstances) Apply(ctx context.Context, daprInstance *operatorv1alpha // ApplyStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). -func (c *daprInstances) ApplyStatus(ctx context.Context, daprInstance *operatorv1alpha1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.DaprInstance, err error) { +func (c *daprInstances) ApplyStatus(ctx context.Context, daprInstance *operatorv1beta1.DaprInstanceApplyConfiguration, opts v1.ApplyOptions) (result *v1beta1.DaprInstance, err error) { if daprInstance == nil { return nil, fmt.Errorf("daprInstance provided to Apply must not be nil") } @@ -241,9 +229,8 @@ func (c *daprInstances) ApplyStatus(ctx context.Context, daprInstance *operatorv return nil, fmt.Errorf("daprInstance.Name must be provided to Apply") } - result = &v1alpha1.DaprInstance{} + result = &v1beta1.DaprInstance{} err = c.client.Patch(types.ApplyPatchType). - Namespace(c.ns). Resource("daprinstances"). Name(*name). SubResource("status"). diff --git a/pkg/client/clientset/versioned/typed/operator/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/operator/v1beta1/doc.go similarity index 97% rename from pkg/client/clientset/versioned/typed/operator/v1alpha1/doc.go rename to pkg/client/clientset/versioned/typed/operator/v1beta1/doc.go index 08b224f..e36b492 100644 --- a/pkg/client/clientset/versioned/typed/operator/v1alpha1/doc.go +++ b/pkg/client/clientset/versioned/typed/operator/v1beta1/doc.go @@ -16,4 +16,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1alpha1 +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/operator/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/operator/v1beta1/generated_expansion.go similarity index 91% rename from pkg/client/clientset/versioned/typed/operator/v1alpha1/generated_expansion.go rename to pkg/client/clientset/versioned/typed/operator/v1beta1/generated_expansion.go index ab04da9..8bdebc9 100644 --- a/pkg/client/clientset/versioned/typed/operator/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/operator/v1beta1/generated_expansion.go @@ -15,9 +15,7 @@ limitations under the License. */ // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 - -type DaprControlPlaneExpansion interface{} +package v1beta1 type DaprCruiseControlExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/operator/v1alpha1/operator_client.go b/pkg/client/clientset/versioned/typed/operator/v1beta1/operator_client.go similarity index 59% rename from pkg/client/clientset/versioned/typed/operator/v1alpha1/operator_client.go rename to pkg/client/clientset/versioned/typed/operator/v1beta1/operator_client.go index dcfb904..a06a57b 100644 --- a/pkg/client/clientset/versioned/typed/operator/v1alpha1/operator_client.go +++ b/pkg/client/clientset/versioned/typed/operator/v1beta1/operator_client.go @@ -15,44 +15,39 @@ limitations under the License. */ // Code generated by client-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "net/http" - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) -type OperatorV1alpha1Interface interface { +type OperatorV1beta1Interface interface { RESTClient() rest.Interface - DaprControlPlanesGetter DaprCruiseControlsGetter DaprInstancesGetter } -// OperatorV1alpha1Client is used to interact with features provided by the operator group. -type OperatorV1alpha1Client struct { +// OperatorV1beta1Client is used to interact with features provided by the operator group. +type OperatorV1beta1Client struct { restClient rest.Interface } -func (c *OperatorV1alpha1Client) DaprControlPlanes(namespace string) DaprControlPlaneInterface { - return newDaprControlPlanes(c, namespace) +func (c *OperatorV1beta1Client) DaprCruiseControls() DaprCruiseControlInterface { + return newDaprCruiseControls(c) } -func (c *OperatorV1alpha1Client) DaprCruiseControls(namespace string) DaprCruiseControlInterface { - return newDaprCruiseControls(c, namespace) +func (c *OperatorV1beta1Client) DaprInstances() DaprInstanceInterface { + return newDaprInstances(c) } -func (c *OperatorV1alpha1Client) DaprInstances(namespace string) DaprInstanceInterface { - return newDaprInstances(c, namespace) -} - -// NewForConfig creates a new OperatorV1alpha1Client for the given config. +// NewForConfig creates a new OperatorV1beta1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). -func NewForConfig(c *rest.Config) (*OperatorV1alpha1Client, error) { +func NewForConfig(c *rest.Config) (*OperatorV1beta1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -64,9 +59,9 @@ func NewForConfig(c *rest.Config) (*OperatorV1alpha1Client, error) { return NewForConfigAndClient(&config, httpClient) } -// NewForConfigAndClient creates a new OperatorV1alpha1Client for the given config and http client. +// NewForConfigAndClient creates a new OperatorV1beta1Client 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) (*OperatorV1alpha1Client, error) { +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*OperatorV1beta1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -75,12 +70,12 @@ func NewForConfigAndClient(c *rest.Config, h *http.Client) (*OperatorV1alpha1Cli if err != nil { return nil, err } - return &OperatorV1alpha1Client{client}, nil + return &OperatorV1beta1Client{client}, nil } -// NewForConfigOrDie creates a new OperatorV1alpha1Client for the given config and +// NewForConfigOrDie creates a new OperatorV1beta1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *OperatorV1alpha1Client { +func NewForConfigOrDie(c *rest.Config) *OperatorV1beta1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -88,13 +83,13 @@ func NewForConfigOrDie(c *rest.Config) *OperatorV1alpha1Client { return client } -// New creates a new OperatorV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *OperatorV1alpha1Client { - return &OperatorV1alpha1Client{c} +// New creates a new OperatorV1beta1Client for the given RESTClient. +func New(c rest.Interface) *OperatorV1beta1Client { + return &OperatorV1beta1Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1alpha1.SchemeGroupVersion + gv := v1beta1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() @@ -108,7 +103,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *OperatorV1alpha1Client) RESTClient() rest.Interface { +func (c *OperatorV1beta1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index f680693..6f6df00 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -20,7 +20,7 @@ package externalversions import ( "fmt" - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -51,13 +51,11 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=operator, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("daprcontrolplanes"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1alpha1().DaprControlPlanes().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("daprcruisecontrols"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1alpha1().DaprCruiseControls().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("daprinstances"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1alpha1().DaprInstances().Informer()}, nil + // Group=operator, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("daprcruisecontrols"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1beta1().DaprCruiseControls().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("daprinstances"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Operator().V1beta1().DaprInstances().Informer()}, nil } diff --git a/pkg/client/informers/externalversions/operator/interface.go b/pkg/client/informers/externalversions/operator/interface.go index 038245f..25ef414 100644 --- a/pkg/client/informers/externalversions/operator/interface.go +++ b/pkg/client/informers/externalversions/operator/interface.go @@ -19,13 +19,13 @@ package operator import ( internalinterfaces "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/operator/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 { @@ -39,7 +39,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1alpha1 returns a new v1alpha1.Interface. -func (g *group) V1alpha1() v1alpha1.Interface { - return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +// 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/operator/v1alpha1/daprcontrolplane.go b/pkg/client/informers/externalversions/operator/v1alpha1/daprcontrolplane.go deleted file mode 100644 index 24d98ab..0000000 --- a/pkg/client/informers/externalversions/operator/v1alpha1/daprcontrolplane.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by informer-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - "context" - time "time" - - operatorv1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - versioned "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned" - internalinterfaces "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/listers/operator/v1alpha1" - 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" -) - -// DaprControlPlaneInformer provides access to a shared informer and lister for -// DaprControlPlanes. -type DaprControlPlaneInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.DaprControlPlaneLister -} - -type daprControlPlaneInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewDaprControlPlaneInformer constructs a new informer for DaprControlPlane 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 NewDaprControlPlaneInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredDaprControlPlaneInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredDaprControlPlaneInformer constructs a new informer for DaprControlPlane 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 NewFilteredDaprControlPlaneInformer(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.OperatorV1alpha1().DaprControlPlanes(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.OperatorV1alpha1().DaprControlPlanes(namespace).Watch(context.TODO(), options) - }, - }, - &operatorv1alpha1.DaprControlPlane{}, - resyncPeriod, - indexers, - ) -} - -func (f *daprControlPlaneInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredDaprControlPlaneInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *daprControlPlaneInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&operatorv1alpha1.DaprControlPlane{}, f.defaultInformer) -} - -func (f *daprControlPlaneInformer) Lister() v1alpha1.DaprControlPlaneLister { - return v1alpha1.NewDaprControlPlaneLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/operator/v1alpha1/daprcruisecontrol.go b/pkg/client/informers/externalversions/operator/v1beta1/daprcruisecontrol.go similarity index 66% rename from pkg/client/informers/externalversions/operator/v1alpha1/daprcruisecontrol.go rename to pkg/client/informers/externalversions/operator/v1beta1/daprcruisecontrol.go index 6fcd9eb..f127f3c 100644 --- a/pkg/client/informers/externalversions/operator/v1alpha1/daprcruisecontrol.go +++ b/pkg/client/informers/externalversions/operator/v1beta1/daprcruisecontrol.go @@ -15,16 +15,16 @@ limitations under the License. */ // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "context" time "time" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" versioned "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned" internalinterfaces "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/listers/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/pkg/client/listers/operator/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,55 +35,54 @@ import ( // DaprCruiseControls. type DaprCruiseControlInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.DaprCruiseControlLister + Lister() v1beta1.DaprCruiseControlLister } type daprCruiseControlInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string } // NewDaprCruiseControlInformer constructs a new informer for DaprCruiseControl 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 NewDaprCruiseControlInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredDaprCruiseControlInformer(client, namespace, resyncPeriod, indexers, nil) +func NewDaprCruiseControlInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredDaprCruiseControlInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDaprCruiseControlInformer constructs a new informer for DaprCruiseControl 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 NewFilteredDaprCruiseControlInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredDaprCruiseControlInformer(client versioned.Interface, 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.OperatorV1alpha1().DaprCruiseControls(namespace).List(context.TODO(), options) + return client.OperatorV1beta1().DaprCruiseControls().List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.OperatorV1alpha1().DaprCruiseControls(namespace).Watch(context.TODO(), options) + return client.OperatorV1beta1().DaprCruiseControls().Watch(context.TODO(), options) }, }, - &operatorv1alpha1.DaprCruiseControl{}, + &operatorv1beta1.DaprCruiseControl{}, resyncPeriod, indexers, ) } func (f *daprCruiseControlInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredDaprCruiseControlInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) + return NewFilteredDaprCruiseControlInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } func (f *daprCruiseControlInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&operatorv1alpha1.DaprCruiseControl{}, f.defaultInformer) + return f.factory.InformerFor(&operatorv1beta1.DaprCruiseControl{}, f.defaultInformer) } -func (f *daprCruiseControlInformer) Lister() v1alpha1.DaprCruiseControlLister { - return v1alpha1.NewDaprCruiseControlLister(f.Informer().GetIndexer()) +func (f *daprCruiseControlInformer) Lister() v1beta1.DaprCruiseControlLister { + return v1beta1.NewDaprCruiseControlLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/operator/v1alpha1/daprinstance.go b/pkg/client/informers/externalversions/operator/v1beta1/daprinstance.go similarity index 66% rename from pkg/client/informers/externalversions/operator/v1alpha1/daprinstance.go rename to pkg/client/informers/externalversions/operator/v1beta1/daprinstance.go index 81669de..7c15db6 100644 --- a/pkg/client/informers/externalversions/operator/v1alpha1/daprinstance.go +++ b/pkg/client/informers/externalversions/operator/v1beta1/daprinstance.go @@ -15,16 +15,16 @@ limitations under the License. */ // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( "context" time "time" - operatorv1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + operatorv1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" versioned "github.com/dapr/kubernetes-operator/pkg/client/clientset/versioned" internalinterfaces "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "github.com/dapr/kubernetes-operator/pkg/client/listers/operator/v1alpha1" + v1beta1 "github.com/dapr/kubernetes-operator/pkg/client/listers/operator/v1beta1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -35,55 +35,54 @@ import ( // DaprInstances. type DaprInstanceInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha1.DaprInstanceLister + Lister() v1beta1.DaprInstanceLister } type daprInstanceInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string } // NewDaprInstanceInformer constructs a new informer for DaprInstance 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 NewDaprInstanceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredDaprInstanceInformer(client, namespace, resyncPeriod, indexers, nil) +func NewDaprInstanceInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredDaprInstanceInformer(client, resyncPeriod, indexers, nil) } // NewFilteredDaprInstanceInformer constructs a new informer for DaprInstance 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 NewFilteredDaprInstanceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredDaprInstanceInformer(client versioned.Interface, 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.OperatorV1alpha1().DaprInstances(namespace).List(context.TODO(), options) + return client.OperatorV1beta1().DaprInstances().List(context.TODO(), options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.OperatorV1alpha1().DaprInstances(namespace).Watch(context.TODO(), options) + return client.OperatorV1beta1().DaprInstances().Watch(context.TODO(), options) }, }, - &operatorv1alpha1.DaprInstance{}, + &operatorv1beta1.DaprInstance{}, resyncPeriod, indexers, ) } func (f *daprInstanceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredDaprInstanceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) + return NewFilteredDaprInstanceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } func (f *daprInstanceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&operatorv1alpha1.DaprInstance{}, f.defaultInformer) + return f.factory.InformerFor(&operatorv1beta1.DaprInstance{}, f.defaultInformer) } -func (f *daprInstanceInformer) Lister() v1alpha1.DaprInstanceLister { - return v1alpha1.NewDaprInstanceLister(f.Informer().GetIndexer()) +func (f *daprInstanceInformer) Lister() v1beta1.DaprInstanceLister { + return v1beta1.NewDaprInstanceLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/operator/v1alpha1/interface.go b/pkg/client/informers/externalversions/operator/v1beta1/interface.go similarity index 74% rename from pkg/client/informers/externalversions/operator/v1alpha1/interface.go rename to pkg/client/informers/externalversions/operator/v1beta1/interface.go index e7a02fd..92698f9 100644 --- a/pkg/client/informers/externalversions/operator/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/operator/v1beta1/interface.go @@ -15,7 +15,7 @@ limitations under the License. */ // Code generated by informer-gen. DO NOT EDIT. -package v1alpha1 +package v1beta1 import ( internalinterfaces "github.com/dapr/kubernetes-operator/pkg/client/informers/externalversions/internalinterfaces" @@ -23,8 +23,6 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // DaprControlPlanes returns a DaprControlPlaneInformer. - DaprControlPlanes() DaprControlPlaneInformer // DaprCruiseControls returns a DaprCruiseControlInformer. DaprCruiseControls() DaprCruiseControlInformer // DaprInstances returns a DaprInstanceInformer. @@ -42,17 +40,12 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// DaprControlPlanes returns a DaprControlPlaneInformer. -func (v *version) DaprControlPlanes() DaprControlPlaneInformer { - return &daprControlPlaneInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // DaprCruiseControls returns a DaprCruiseControlInformer. func (v *version) DaprCruiseControls() DaprCruiseControlInformer { - return &daprCruiseControlInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} + return &daprCruiseControlInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } // DaprInstances returns a DaprInstanceInformer. func (v *version) DaprInstances() DaprInstanceInformer { - return &daprInstanceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} + return &daprInstanceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } diff --git a/pkg/client/listers/operator/v1alpha1/daprcontrolplane.go b/pkg/client/listers/operator/v1alpha1/daprcontrolplane.go deleted file mode 100644 index e7c246f..0000000 --- a/pkg/client/listers/operator/v1alpha1/daprcontrolplane.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// DaprControlPlaneLister helps list DaprControlPlanes. -// All objects returned here must be treated as read-only. -type DaprControlPlaneLister interface { - // List lists all DaprControlPlanes in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.DaprControlPlane, err error) - // DaprControlPlanes returns an object that can list and get DaprControlPlanes. - DaprControlPlanes(namespace string) DaprControlPlaneNamespaceLister - DaprControlPlaneListerExpansion -} - -// daprControlPlaneLister implements the DaprControlPlaneLister interface. -type daprControlPlaneLister struct { - indexer cache.Indexer -} - -// NewDaprControlPlaneLister returns a new DaprControlPlaneLister. -func NewDaprControlPlaneLister(indexer cache.Indexer) DaprControlPlaneLister { - return &daprControlPlaneLister{indexer: indexer} -} - -// List lists all DaprControlPlanes in the indexer. -func (s *daprControlPlaneLister) List(selector labels.Selector) (ret []*v1alpha1.DaprControlPlane, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.DaprControlPlane)) - }) - return ret, err -} - -// DaprControlPlanes returns an object that can list and get DaprControlPlanes. -func (s *daprControlPlaneLister) DaprControlPlanes(namespace string) DaprControlPlaneNamespaceLister { - return daprControlPlaneNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// DaprControlPlaneNamespaceLister helps list and get DaprControlPlanes. -// All objects returned here must be treated as read-only. -type DaprControlPlaneNamespaceLister interface { - // List lists all DaprControlPlanes in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.DaprControlPlane, err error) - // Get retrieves the DaprControlPlane from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.DaprControlPlane, error) - DaprControlPlaneNamespaceListerExpansion -} - -// daprControlPlaneNamespaceLister implements the DaprControlPlaneNamespaceLister -// interface. -type daprControlPlaneNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all DaprControlPlanes in the indexer for a given namespace. -func (s daprControlPlaneNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprControlPlane, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.DaprControlPlane)) - }) - return ret, err -} - -// Get retrieves the DaprControlPlane from the indexer for a given namespace and name. -func (s daprControlPlaneNamespaceLister) Get(name string) (*v1alpha1.DaprControlPlane, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("daprcontrolplane"), name) - } - return obj.(*v1alpha1.DaprControlPlane), nil -} diff --git a/pkg/client/listers/operator/v1alpha1/daprcruisecontrol.go b/pkg/client/listers/operator/v1alpha1/daprcruisecontrol.go deleted file mode 100644 index a6049bb..0000000 --- a/pkg/client/listers/operator/v1alpha1/daprcruisecontrol.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// DaprCruiseControlLister helps list DaprCruiseControls. -// All objects returned here must be treated as read-only. -type DaprCruiseControlLister interface { - // List lists all DaprCruiseControls in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.DaprCruiseControl, err error) - // DaprCruiseControls returns an object that can list and get DaprCruiseControls. - DaprCruiseControls(namespace string) DaprCruiseControlNamespaceLister - DaprCruiseControlListerExpansion -} - -// daprCruiseControlLister implements the DaprCruiseControlLister interface. -type daprCruiseControlLister struct { - indexer cache.Indexer -} - -// NewDaprCruiseControlLister returns a new DaprCruiseControlLister. -func NewDaprCruiseControlLister(indexer cache.Indexer) DaprCruiseControlLister { - return &daprCruiseControlLister{indexer: indexer} -} - -// List lists all DaprCruiseControls in the indexer. -func (s *daprCruiseControlLister) List(selector labels.Selector) (ret []*v1alpha1.DaprCruiseControl, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.DaprCruiseControl)) - }) - return ret, err -} - -// DaprCruiseControls returns an object that can list and get DaprCruiseControls. -func (s *daprCruiseControlLister) DaprCruiseControls(namespace string) DaprCruiseControlNamespaceLister { - return daprCruiseControlNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// DaprCruiseControlNamespaceLister helps list and get DaprCruiseControls. -// All objects returned here must be treated as read-only. -type DaprCruiseControlNamespaceLister interface { - // List lists all DaprCruiseControls in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.DaprCruiseControl, err error) - // Get retrieves the DaprCruiseControl from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.DaprCruiseControl, error) - DaprCruiseControlNamespaceListerExpansion -} - -// daprCruiseControlNamespaceLister implements the DaprCruiseControlNamespaceLister -// interface. -type daprCruiseControlNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all DaprCruiseControls in the indexer for a given namespace. -func (s daprCruiseControlNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprCruiseControl, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.DaprCruiseControl)) - }) - return ret, err -} - -// Get retrieves the DaprCruiseControl from the indexer for a given namespace and name. -func (s daprCruiseControlNamespaceLister) Get(name string) (*v1alpha1.DaprCruiseControl, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("daprcruisecontrol"), name) - } - return obj.(*v1alpha1.DaprCruiseControl), nil -} diff --git a/pkg/client/listers/operator/v1alpha1/daprinstance.go b/pkg/client/listers/operator/v1alpha1/daprinstance.go deleted file mode 100644 index 3827127..0000000 --- a/pkg/client/listers/operator/v1alpha1/daprinstance.go +++ /dev/null @@ -1,98 +0,0 @@ -/* -Copyright 2023. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - v1alpha1 "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// DaprInstanceLister helps list DaprInstances. -// All objects returned here must be treated as read-only. -type DaprInstanceLister interface { - // List lists all DaprInstances in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.DaprInstance, err error) - // DaprInstances returns an object that can list and get DaprInstances. - DaprInstances(namespace string) DaprInstanceNamespaceLister - DaprInstanceListerExpansion -} - -// daprInstanceLister implements the DaprInstanceLister interface. -type daprInstanceLister struct { - indexer cache.Indexer -} - -// NewDaprInstanceLister returns a new DaprInstanceLister. -func NewDaprInstanceLister(indexer cache.Indexer) DaprInstanceLister { - return &daprInstanceLister{indexer: indexer} -} - -// List lists all DaprInstances in the indexer. -func (s *daprInstanceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprInstance, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.DaprInstance)) - }) - return ret, err -} - -// DaprInstances returns an object that can list and get DaprInstances. -func (s *daprInstanceLister) DaprInstances(namespace string) DaprInstanceNamespaceLister { - return daprInstanceNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// DaprInstanceNamespaceLister helps list and get DaprInstances. -// All objects returned here must be treated as read-only. -type DaprInstanceNamespaceLister interface { - // List lists all DaprInstances in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.DaprInstance, err error) - // Get retrieves the DaprInstance from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.DaprInstance, error) - DaprInstanceNamespaceListerExpansion -} - -// daprInstanceNamespaceLister implements the DaprInstanceNamespaceLister -// interface. -type daprInstanceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all DaprInstances in the indexer for a given namespace. -func (s daprInstanceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.DaprInstance, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.DaprInstance)) - }) - return ret, err -} - -// Get retrieves the DaprInstance from the indexer for a given namespace and name. -func (s daprInstanceNamespaceLister) Get(name string) (*v1alpha1.DaprInstance, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("daprinstance"), name) - } - return obj.(*v1alpha1.DaprInstance), nil -} diff --git a/pkg/client/listers/operator/v1beta1/daprcruisecontrol.go b/pkg/client/listers/operator/v1beta1/daprcruisecontrol.go new file mode 100644 index 0000000..f3b06cf --- /dev/null +++ b/pkg/client/listers/operator/v1beta1/daprcruisecontrol.go @@ -0,0 +1,67 @@ +/* +Copyright 2023. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// DaprCruiseControlLister helps list DaprCruiseControls. +// All objects returned here must be treated as read-only. +type DaprCruiseControlLister interface { + // List lists all DaprCruiseControls in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.DaprCruiseControl, err error) + // Get retrieves the DaprCruiseControl from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.DaprCruiseControl, error) + DaprCruiseControlListerExpansion +} + +// daprCruiseControlLister implements the DaprCruiseControlLister interface. +type daprCruiseControlLister struct { + indexer cache.Indexer +} + +// NewDaprCruiseControlLister returns a new DaprCruiseControlLister. +func NewDaprCruiseControlLister(indexer cache.Indexer) DaprCruiseControlLister { + return &daprCruiseControlLister{indexer: indexer} +} + +// List lists all DaprCruiseControls in the indexer. +func (s *daprCruiseControlLister) List(selector labels.Selector) (ret []*v1beta1.DaprCruiseControl, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.DaprCruiseControl)) + }) + return ret, err +} + +// Get retrieves the DaprCruiseControl from the index for a given name. +func (s *daprCruiseControlLister) Get(name string) (*v1beta1.DaprCruiseControl, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("daprcruisecontrol"), name) + } + return obj.(*v1beta1.DaprCruiseControl), nil +} diff --git a/pkg/client/listers/operator/v1beta1/daprinstance.go b/pkg/client/listers/operator/v1beta1/daprinstance.go new file mode 100644 index 0000000..d226775 --- /dev/null +++ b/pkg/client/listers/operator/v1beta1/daprinstance.go @@ -0,0 +1,67 @@ +/* +Copyright 2023. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/dapr/kubernetes-operator/api/operator/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// DaprInstanceLister helps list DaprInstances. +// All objects returned here must be treated as read-only. +type DaprInstanceLister interface { + // List lists all DaprInstances in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.DaprInstance, err error) + // Get retrieves the DaprInstance from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.DaprInstance, error) + DaprInstanceListerExpansion +} + +// daprInstanceLister implements the DaprInstanceLister interface. +type daprInstanceLister struct { + indexer cache.Indexer +} + +// NewDaprInstanceLister returns a new DaprInstanceLister. +func NewDaprInstanceLister(indexer cache.Indexer) DaprInstanceLister { + return &daprInstanceLister{indexer: indexer} +} + +// List lists all DaprInstances in the indexer. +func (s *daprInstanceLister) List(selector labels.Selector) (ret []*v1beta1.DaprInstance, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.DaprInstance)) + }) + return ret, err +} + +// Get retrieves the DaprInstance from the index for a given name. +func (s *daprInstanceLister) Get(name string) (*v1beta1.DaprInstance, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("daprinstance"), name) + } + return obj.(*v1beta1.DaprInstance), nil +} diff --git a/pkg/client/listers/operator/v1alpha1/expansion_generated.go b/pkg/client/listers/operator/v1beta1/expansion_generated.go similarity index 56% rename from pkg/client/listers/operator/v1alpha1/expansion_generated.go rename to pkg/client/listers/operator/v1beta1/expansion_generated.go index 8b4cbfb..87d3c46 100644 --- a/pkg/client/listers/operator/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/operator/v1beta1/expansion_generated.go @@ -15,28 +15,12 @@ limitations under the License. */ // Code generated by lister-gen. DO NOT EDIT. -package v1alpha1 - -// DaprControlPlaneListerExpansion allows custom methods to be added to -// DaprControlPlaneLister. -type DaprControlPlaneListerExpansion interface{} - -// DaprControlPlaneNamespaceListerExpansion allows custom methods to be added to -// DaprControlPlaneNamespaceLister. -type DaprControlPlaneNamespaceListerExpansion interface{} +package v1beta1 // DaprCruiseControlListerExpansion allows custom methods to be added to // DaprCruiseControlLister. type DaprCruiseControlListerExpansion interface{} -// DaprCruiseControlNamespaceListerExpansion allows custom methods to be added to -// DaprCruiseControlNamespaceLister. -type DaprCruiseControlNamespaceListerExpansion interface{} - // DaprInstanceListerExpansion allows custom methods to be added to // DaprInstanceLister. type DaprInstanceListerExpansion interface{} - -// DaprInstanceNamespaceListerExpansion allows custom methods to be added to -// DaprInstanceNamespaceLister. -type DaprInstanceNamespaceListerExpansion interface{} diff --git a/pkg/conditions/conditions_types.go b/pkg/conditions/conditions_types.go index 12345a5..8a03044 100644 --- a/pkg/conditions/conditions_types.go +++ b/pkg/conditions/conditions_types.go @@ -6,6 +6,7 @@ const ( TypeError = "Error" ReasonReady = "Ready" ReasonReconciled = "Ready" + ReasonInProgress = "InProgress" ReasonFailure = "Failure" ReasonUnsupportedConfiguration = "UnsupportedConfiguration" ) diff --git a/pkg/controller/client/client.go b/pkg/controller/client/client.go index 7e456e7..3128d22 100644 --- a/pkg/controller/client/client.go +++ b/pkg/controller/client/client.go @@ -118,13 +118,11 @@ func newRESTClientForConfig(config *rest.Config) (*rest.RESTClient, error) { return rc, nil } -func (c *Client) Dynamic(namespace string, obj *unstructured.Unstructured) (dynamic.ResourceInterface, error) { +func (c *Client) Dynamic(obj *unstructured.Unstructured) (ResourceInterface, error) { if c.discoveryLimiter.Allow() { c.discoveryCache.Invalidate() } - c.discoveryCache.Fresh() - mapping, err := c.mapper.RESTMapping(obj.GroupVersionKind().GroupKind(), obj.GroupVersionKind().Version) if err != nil { return nil, fmt.Errorf( @@ -134,19 +132,28 @@ func (c *Client) Dynamic(namespace string, obj *unstructured.Unstructured) (dyna err) } - var dr dynamic.ResourceInterface + switch mapping.Scope { + case meta.RESTScopeNamespace: + if obj.GetNamespace() == "" { + //nolint:err113 + return nil, fmt.Errorf( + "missing required filed: namespace, gvk=%s, name=%s", + obj.GetObjectKind().GroupVersionKind().String(), + obj.GetName()) + } - if mapping.Scope.Name() == meta.RESTScopeNameNamespace { - dr = &NamespacedResource{ - ResourceInterface: c.dynamic.Resource(mapping.Resource).Namespace(namespace), + dr := &NamespacedResource{ + ResourceInterface: c.dynamic.Resource(mapping.Resource).Namespace(obj.GetNamespace()), } - } else { - dr = &ClusteredResource{ + + return dr, nil + default: + dr := &ClusteredResource{ ResourceInterface: c.dynamic.Resource(mapping.Resource), } - } - return dr, nil + return dr, nil + } } func (c *Client) Invalidate() { diff --git a/pkg/controller/client/types.go b/pkg/controller/client/types.go index 2ec9d07..88dfcc3 100644 --- a/pkg/controller/client/types.go +++ b/pkg/controller/client/types.go @@ -2,10 +2,31 @@ package client import "k8s.io/client-go/dynamic" +type ResourceScope string + +const ( + ResourceScopeNamespace ResourceScope = "namespace" + ResourceScopeCluster ResourceScope = "cluster" +) + +type ResourceInterface interface { + dynamic.ResourceInterface + + Scope() ResourceScope +} + type NamespacedResource struct { dynamic.ResourceInterface } +func (r *NamespacedResource) Scope() ResourceScope { + return ResourceScopeNamespace +} + type ClusteredResource struct { dynamic.ResourceInterface } + +func (r *ClusteredResource) Scope() ResourceScope { + return ResourceScopeCluster +} diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index a53ff0e..0e1a132 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -85,8 +85,6 @@ func Start(options Options, setup func(manager.Manager, Options) error) error { } func OperatorNamespace() string { - // by default, the controller expect singleton resources to be created in the same - // namespace where it runs, if not fallback to the default namespace ns := os.Getenv(NamespaceEnv) if ns == "" { ns = NamespaceDefault diff --git a/pkg/controller/predicates/dependant.go b/pkg/controller/predicates/dependant.go index 4e93755..adfb6e4 100644 --- a/pkg/controller/predicates/dependant.go +++ b/pkg/controller/predicates/dependant.go @@ -3,8 +3,6 @@ package predicates import ( "reflect" - "github.com/wI2L/jsondiff" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" @@ -113,18 +111,11 @@ func (p DependentPredicate) Update(e event.UpdateEvent) bool { return false } - patch, err := jsondiff.Compare(oldObj, newObj) - if err != nil { - log.Error(err, "failed to generate diff") - return true - } - log.Info("Reconciling due to dependent resource update", "name", newObj.GetName(), "namespace", newObj.GetNamespace(), "apiVersion", newObj.GroupVersionKind().GroupVersion(), - "kind", newObj.GroupVersionKind().Kind, - "diff", patch.String()) + "kind", newObj.GroupVersionKind().Kind) return true } diff --git a/pkg/controller/reconciler/types.go b/pkg/controller/reconciler/types.go index 7774001..fba612d 100644 --- a/pkg/controller/reconciler/types.go +++ b/pkg/controller/reconciler/types.go @@ -69,7 +69,6 @@ func RemoveFinalizer(ctx context.Context, client ctrlClient.Client, o ctrlClient type BaseReconciler[T controller.ResourceObject] struct { Log logr.Logger Name string - Namespace string FinalizerName string FinalizerAction func(ctx context.Context, res T) error Delegate reconcile.ObjectReconciler[T] @@ -83,7 +82,7 @@ func (s *BaseReconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (ct return ctrl.Result{}, ctrlClient.IgnoreNotFound(err) } - if res.GetName() != s.Name || res.GetNamespace() != s.Namespace { + if res.GetName() != s.Name { res.GetStatus().Phase = conditions.TypeError meta.SetStatusCondition(&res.GetStatus().Conditions, metav1.Condition{ @@ -91,10 +90,9 @@ func (s *BaseReconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (ct Status: metav1.ConditionFalse, Reason: conditions.ReasonUnsupportedConfiguration, Message: fmt.Sprintf( - "Unsupported resource, the operator handles a single %s resource named %s in namespace %s", + "Unsupported resource, the operator handles a single %s resource named %s", res.GetObjectKind().GroupVersionKind().String(), - s.Name, - s.Namespace), + s.Name), }) err := s.Client.Status().Update(ctx, res) diff --git a/pkg/controller/types.go b/pkg/controller/types.go index e70616e..0f80030 100644 --- a/pkg/controller/types.go +++ b/pkg/controller/types.go @@ -1,7 +1,7 @@ package controller import ( - daptCtrlApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daptCtrlApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" rtcache "sigs.k8s.io/controller-runtime/pkg/cache" rtclient "sigs.k8s.io/controller-runtime/pkg/client" ) diff --git a/pkg/gvk/gvk.go b/pkg/gvk/gvk.go new file mode 100644 index 0000000..7cc6be3 --- /dev/null +++ b/pkg/gvk/gvk.go @@ -0,0 +1,34 @@ +package gvk + +import ( + admissionregistrationv1 "k8s.io/api/admissionregistration/v1" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var CustomResourceDefinition = schema.GroupVersionKind{ + Group: apiextensions.GroupName, + Version: "v1", + Kind: "CustomResourceDefinition", +} + +var Secret = schema.GroupVersionKind{ + Group: corev1.GroupName, + Version: "v1", + Kind: "Secret", +} + +var Deployment = schema.GroupVersionKind{ + Group: appsv1.GroupName, + Version: "v1", + Kind: "Deployment", +} + +var MutatingWebhookConfiguration = schema.GroupVersionKind{ + Group: admissionregistrationv1.GroupName, + Version: "v1", + Kind: "MutatingWebhookConfiguration", +} diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index 97722d0..048781d 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -8,7 +8,6 @@ import ( const ( ReleaseGeneration = "helm.operator.dapr.io/release.generation" ReleaseName = "helm.operator.dapr.io/release.name" - ReleaseNamespace = "helm.operator.dapr.io/release.namespace" ReleaseVersion = "helm.operator.dapr.io/release.version" ChartsDir = "helm-charts/dapr" @@ -25,14 +24,8 @@ func ReleaseSelector() (labels.Selector, error) { return nil, err } - hasReleaseNamespaceLabel, err := labels.NewRequirement(ReleaseNamespace, selection.Exists, []string{}) - if err != nil { - return nil, err - } - selector := labels.NewSelector(). - Add(*hasReleaseNameLabel). - Add(*hasReleaseNamespaceLabel) + Add(*hasReleaseNameLabel) return selector, nil } diff --git a/test/e2e/olm/dapr_olm_test.go b/test/e2e/olm/dapr_olm_test.go index 7a35d18..0edf897 100644 --- a/test/e2e/olm/dapr_olm_test.go +++ b/test/e2e/olm/dapr_olm_test.go @@ -4,14 +4,10 @@ import ( "os" "testing" - "github.com/dapr/kubernetes-operator/internal/controller/operator/controlplane" - "github.com/dapr/kubernetes-operator/internal/controller/operator/instance" - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" "github.com/dapr/kubernetes-operator/test/support/dapr" - "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/dapr/kubernetes-operator/test/support/olm" + daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" daprTC "github.com/dapr/kubernetes-operator/test/e2e/common" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -21,53 +17,7 @@ import ( ) func TestDaprDeploy(t *testing.T) { - t.Run("With ControlPlane", func(t *testing.T) { - testDaprDeploy( - With(t), - func(test Test, ns *corev1.Namespace) client.Object { - return dapr.DeployControlPlane( - test, - daprAc.DaprControlPlaneSpec(). - WithValues(dapr.Values(test, map[string]interface{}{ - // enable pod watchdog as sometimes the sidecar for some - // (yet) unknown reason is not injected when the pod is - // created, hence the dapr app won't properly start up - "dapr_operator": map[string]interface{}{ - "watchInterval": "1s", - }, - })), - dapr.WithControlPlaneName(controlplane.DaprControlPlaneResourceName), - dapr.WithControlPlaneNamespace(ns.Name), - ) - }, - ) - }) - - t.Run("With Instance", func(t *testing.T) { - testDaprDeploy( - With(t), - func(test Test, ns *corev1.Namespace) client.Object { - return dapr.DeployInstance( - test, - daprAc.DaprInstanceSpec(). - WithValues(dapr.Values(test, map[string]interface{}{ - // enable pod watchdog as sometimes the sidecar for some - // (yet) unknown reason is not injected when the pod is - // created, hence the dapr app won't properly start up - "dapr_operator": map[string]interface{}{ - "watchInterval": "1s", - }, - })), - dapr.WithInstanceName(instance.DaprInstanceResourceName), - dapr.WithInstanceNamespace(ns.Name), - ) - }, - ) - }) -} - -func testDaprDeploy(test Test, f func(t Test, ns *corev1.Namespace) client.Object) { - test.T().Helper() + test := With(t) ns := test.NewTestNamespace() image := os.Getenv("CATALOG_CONTAINER_IMAGE") @@ -92,18 +42,33 @@ func testDaprDeploy(test Test, f func(t Test, ns *corev1.Namespace) client.Objec // Dapr // - res := f(test, ns) - - test.Eventually(Deployment(test, "dapr-operator", res.GetNamespace()), TestTimeoutLong).Should( + _ = dapr.DeployInstance( + test, + daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns.Name), + ). + WithValues(dapr.Values(test, map[string]interface{}{ + // enable pod watchdog as sometimes the sidecar for some + // (yet) unknown reason is not injected when the pod is + // created, hence the dapr app won't properly start up + "dapr_operator": map[string]interface{}{ + "watchInterval": "1s", + }, + })), + ) + + test.Eventually(Deployment(test, "dapr-operator", ns.Name), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", res.GetNamespace()), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns.Name), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", res.GetNamespace()), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns.Name), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) // // Dapr Application // - daprTC.ValidateDaprApp(test, res.GetNamespace()) + daprTC.ValidateDaprApp(test, ns.Name) } diff --git a/test/e2e/operator/dapr_controlplane_test.go b/test/e2e/operator/dapr_controlplane_test.go deleted file mode 100644 index 6abcebb..0000000 --- a/test/e2e/operator/dapr_controlplane_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package operator - -import ( - "testing" - - "github.com/dapr/kubernetes-operator/pkg/conditions" - "github.com/dapr/kubernetes-operator/pkg/controller" - "github.com/dapr/kubernetes-operator/test/support/dapr" - - "github.com/rs/xid" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - - . "github.com/dapr/kubernetes-operator/test/support" - . "github.com/onsi/gomega" - - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" - daprTC "github.com/dapr/kubernetes-operator/test/e2e/common" -) - -func TestDaprControlPlaneDeploy(t *testing.T) { - test := With(t) - - instance := dapr.DeployControlPlane( - test, - daprAc.DaprControlPlaneSpec(). - WithValues(dapr.Values(test, map[string]interface{}{ - // enable pod watchdog as sometimes the sidecar for some - // (yet) unknown reason is not injected when the pod is - // created, hence the dapr app won't properly start up - "dapr_operator": map[string]interface{}{ - "watchInterval": "1s", - }, - })), - ) - - test.Eventually(CustomResourceDefinition(test, "components.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "configurations.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "httpendpoints.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "resiliencies.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "subscriptions.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( - WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( - WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( - WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) -} - -func TestDaprControlPlaneDeployWithApp(t *testing.T) { - test := With(t) - - instance := dapr.DeployControlPlane( - test, - daprAc.DaprControlPlaneSpec(). - WithValues(dapr.Values(test, map[string]interface{}{ - // enable pod watchdog as sometimes the sidecar for some - // (yet) unknown reason is not injected when the pod is - // created, hence the dapr app won't properly start up - "dapr_operator": map[string]interface{}{ - "watchInterval": "1s", - }, - })), - ) - - test.Eventually(CustomResourceDefinition(test, "components.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "configurations.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "httpendpoints.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "resiliencies.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(CustomResourceDefinition(test, "subscriptions.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( - WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( - WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( - WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - - // - // Dapr Application - // - - daprTC.ValidateDaprApp(test, instance.Namespace) -} - -func TestDaprControlPlaneDeployWrongCR(t *testing.T) { - test := With(t) - - instance := dapr.DeployControlPlane( - test, - daprAc.DaprControlPlaneSpec(). - WithValues(nil), - dapr.WithControlPlaneName(xid.New().String()), - dapr.WithControlPlaneNamespace(controller.NamespaceDefault), - ) - - test.Eventually(dapr.ControlPlane(test, instance), TestTimeoutLong).Should( - WithTransform(ConditionStatus(conditions.TypeReconciled), Equal(corev1.ConditionFalse))) - test.Eventually(dapr.ControlPlane(test, instance), TestTimeoutLong).Should( - WithTransform(ConditionReason(conditions.TypeReconciled), Equal(conditions.ReasonUnsupportedConfiguration))) -} diff --git a/test/e2e/operator/dapr_instance_test.go b/test/e2e/operator/dapr_instance_test.go index 32fe201..2c68f07 100644 --- a/test/e2e/operator/dapr_instance_test.go +++ b/test/e2e/operator/dapr_instance_test.go @@ -7,28 +7,31 @@ import ( "github.com/lburgazzoli/gomega-matchers/pkg/matchers/jq" - "github.com/dapr/kubernetes-operator/pkg/conditions" "github.com/dapr/kubernetes-operator/pkg/controller" "github.com/dapr/kubernetes-operator/test/support/dapr" - "github.com/rs/xid" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" . "github.com/dapr/kubernetes-operator/test/support" . "github.com/onsi/gomega" - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" + daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" daprTC "github.com/dapr/kubernetes-operator/test/e2e/common" ) func TestDaprInstanceDeployWithDefaults(t *testing.T) { test := With(t) + ns := controller.NamespaceDefault + instance := dapr.DeployInstance( test, daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns), + ). WithValues(nil), ) @@ -38,11 +41,11 @@ func TestDaprInstanceDeployWithDefaults(t *testing.T) { test.Eventually(CustomResourceDefinition(test, "resiliencies.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) test.Eventually(CustomResourceDefinition(test, "subscriptions.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-operator", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) test.Eventually(dapr.Instance(test, instance), TestTimeoutLong).Should( @@ -57,25 +60,35 @@ func TestDaprInstanceDeployWithDefaults(t *testing.T) { func TestDaprInstanceGC(t *testing.T) { test := With(t) + ns := controller.NamespaceDefault + { - instance := dapr.DeployInstance( + _ = dapr.DeployInstance( test, daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns), + ). WithValues(nil), ) - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-operator", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) } { - instance := dapr.DeployInstance( + _ = dapr.DeployInstance( test, daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns), + ). WithValues(dapr.Values(test, map[string]any{ "dapr_sidecar_injector": map[string]any{ "enabled": false, @@ -83,11 +96,11 @@ func TestDaprInstanceGC(t *testing.T) { })), ) - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-operator", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns), TestTimeoutLong).Should( BeNil()) } } @@ -95,9 +108,15 @@ func TestDaprInstanceGC(t *testing.T) { func TestDaprInstanceDeployWithCustomChart(t *testing.T) { test := With(t) + ns := controller.NamespaceDefault + instance := dapr.DeployInstance( test, daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns), + ). WithChart(daprAc.ChartSpec(). WithVersion("1.14.0")). WithValues(nil), @@ -109,11 +128,11 @@ func TestDaprInstanceDeployWithCustomChart(t *testing.T) { test.Eventually(CustomResourceDefinition(test, "resiliencies.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) test.Eventually(CustomResourceDefinition(test, "subscriptions.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-operator", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) test.Eventually(dapr.Instance(test, instance), TestTimeoutLong).Should( @@ -128,9 +147,15 @@ func TestDaprInstanceDeployWithCustomChart(t *testing.T) { func TestDaprInstanceDeployWithCustomSidecarImage(t *testing.T) { test := With(t) + ns := controller.NamespaceDefault + instance := dapr.DeployInstance( test, daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns), + ). WithValues(dapr.Values(test, map[string]any{ "dapr_sidecar_injector": map[string]any{ "image": map[string]any{ @@ -146,11 +171,11 @@ func TestDaprInstanceDeployWithCustomSidecarImage(t *testing.T) { test.Eventually(CustomResourceDefinition(test, "resiliencies.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) test.Eventually(CustomResourceDefinition(test, "subscriptions.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-operator", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) test.Eventually(dapr.Instance(test, instance), TestTimeoutLong).Should( @@ -161,7 +186,7 @@ func TestDaprInstanceDeployWithCustomSidecarImage(t *testing.T) { )), ) - test.Eventually(PodList(test, "app=dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(PodList(test, "app=dapr-sidecar-injector", ns), TestTimeoutLong).Should( WithTransform(json.Marshal, And( jq.Match(`.items[0].spec.containers[0].env[] | select(.name == "SIDECAR_IMAGE") | .value == "docker.io/daprio/daprd:%s"`, test.ID()), jq.Match(`.items[0].spec.containers[0].env[] | select(.name == "SIDECAR_IMAGE_PULL_POLICY") | .value == "%s"`, corev1.PullAlways), @@ -172,9 +197,15 @@ func TestDaprInstanceDeployWithCustomSidecarImage(t *testing.T) { func TestDaprInstanceDeployWithApp(t *testing.T) { test := With(t) + ns := controller.NamespaceDefault + instance := dapr.DeployInstance( test, daprAc.DaprInstanceSpec(). + WithDeployment( + daprAc.DeploymentSpec(). + WithNamespace(ns), + ). WithValues(dapr.Values(test, map[string]interface{}{ // enable pod watchdog as sometimes the sidecar for some // (yet) unknown reason is not injected when the pod is @@ -191,11 +222,11 @@ func TestDaprInstanceDeployWithApp(t *testing.T) { test.Eventually(CustomResourceDefinition(test, "resiliencies.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) test.Eventually(CustomResourceDefinition(test, "subscriptions.dapr.io"), TestTimeoutLong).Should(Not(BeNil())) - test.Eventually(Deployment(test, "dapr-operator", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-operator", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sentry", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sentry", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) - test.Eventually(Deployment(test, "dapr-sidecar-injector", instance.Namespace), TestTimeoutLong).Should( + test.Eventually(Deployment(test, "dapr-sidecar-injector", ns), TestTimeoutLong).Should( WithTransform(ConditionStatus(appsv1.DeploymentAvailable), Equal(corev1.ConditionTrue))) test.Eventually(dapr.Instance(test, instance), TestTimeoutLong).Should( @@ -210,22 +241,5 @@ func TestDaprInstanceDeployWithApp(t *testing.T) { // Dapr Application // - daprTC.ValidateDaprApp(test, instance.Namespace) -} - -func TestDaprInstanceDeployWrongCR(t *testing.T) { - test := With(t) - - instance := dapr.DeployInstance( - test, - daprAc.DaprInstanceSpec(). - WithValues(nil), - dapr.WithInstanceName(xid.New().String()), - dapr.WithInstanceNamespace(controller.NamespaceDefault), - ) - - test.Eventually(dapr.Instance(test, instance), TestTimeoutLong).Should( - WithTransform(ConditionStatus(conditions.TypeReconciled), Equal(corev1.ConditionFalse))) - test.Eventually(dapr.Instance(test, instance), TestTimeoutLong).Should( - WithTransform(ConditionReason(conditions.TypeReconciled), Equal(conditions.ReasonUnsupportedConfiguration))) + daprTC.ValidateDaprApp(test, ns) } diff --git a/test/support/dapr/support_dapr.go b/test/support/dapr/support_dapr.go index d57df58..df643d0 100644 --- a/test/support/dapr/support_dapr.go +++ b/test/support/dapr/support_dapr.go @@ -12,7 +12,7 @@ import ( netv1 "k8s.io/api/networking/v1" netv1ac "k8s.io/client-go/applyconfigurations/networking/v1" - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" + daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" "github.com/dapr/kubernetes-operator/pkg/resources" "github.com/dapr/kubernetes-operator/test/support" "github.com/onsi/gomega" diff --git a/test/support/dapr/support_dapr_controlplane.go b/test/support/dapr/support_dapr_controlplane.go deleted file mode 100644 index 49d1564..0000000 --- a/test/support/dapr/support_dapr_controlplane.go +++ /dev/null @@ -1,86 +0,0 @@ -package dapr - -import ( - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" - "github.com/dapr/kubernetes-operator/internal/controller/operator/controlplane" - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" - "github.com/dapr/kubernetes-operator/pkg/controller" - "github.com/dapr/kubernetes-operator/test/support" - "github.com/onsi/gomega" - k8serrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" -) - -func ControlPlane(t support.Test, dapr *daprApi.DaprControlPlane) func(g gomega.Gomega) (*daprApi.DaprControlPlane, error) { - return func(g gomega.Gomega) (*daprApi.DaprControlPlane, error) { - answer, err := t.Client().Dapr().OperatorV1alpha1().DaprControlPlanes(dapr.Namespace).Get( - t.Ctx(), - dapr.Name, - metav1.GetOptions{}, - ) - - if k8serrors.IsNotFound(err) { - return nil, nil - } - - return answer, err - } -} - -type ControlPlaneOptions struct { - types.NamespacedName -} - -type ControlPlaneOption func(*ControlPlaneOptions) - -func WithControlPlaneName(value string) ControlPlaneOption { - return func(options *ControlPlaneOptions) { - options.Name = value - } -} - -func WithControlPlaneNamespace(value string) ControlPlaneOption { - return func(options *ControlPlaneOptions) { - options.Namespace = value - } -} - -func DeployControlPlane( - t support.Test, - spec *daprAc.DaprControlPlaneSpecApplyConfiguration, - opts ...ControlPlaneOption, -) *daprApi.DaprControlPlane { - t.T().Helper() - - cpo := ControlPlaneOptions{} - cpo.Name = controlplane.DaprControlPlaneResourceName - cpo.Namespace = controller.NamespaceDefault - - for _, o := range opts { - o(&cpo) - } - - t.T().Logf("Setting up DaprControlPlane %s in namespace %s", cpo.Name, cpo.Namespace) - - cp := t.Client().Dapr().OperatorV1alpha1().DaprControlPlanes(cpo.Namespace) - - res, err := cp.Apply( - t.Ctx(), - daprAc.DaprControlPlane(cpo.Name, cpo.Namespace). - WithSpec(spec), - metav1.ApplyOptions{ - FieldManager: "dapr-e2e-" + t.ID(), - Force: true, - }) - - t.Expect(err). - ToNot(gomega.HaveOccurred()) - - t.Cleanup(func() []runtime.Object { - return []runtime.Object{res} - }) - - return res -} diff --git a/test/support/dapr/support_dapr_instance.go b/test/support/dapr/support_dapr_instance.go index 0f63a18..69df429 100644 --- a/test/support/dapr/support_dapr_instance.go +++ b/test/support/dapr/support_dapr_instance.go @@ -1,21 +1,19 @@ package dapr import ( - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "github.com/dapr/kubernetes-operator/internal/controller/operator/instance" - daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1alpha1" - "github.com/dapr/kubernetes-operator/pkg/controller" + daprAc "github.com/dapr/kubernetes-operator/pkg/client/applyconfiguration/operator/v1beta1" "github.com/dapr/kubernetes-operator/test/support" "github.com/onsi/gomega" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" ) func Instance(t support.Test, dapr *daprApi.DaprInstance) func(g gomega.Gomega) (*daprApi.DaprInstance, error) { return func(g gomega.Gomega) (*daprApi.DaprInstance, error) { - answer, err := t.Client().Dapr().OperatorV1alpha1().DaprInstances(dapr.Namespace).Get( + answer, err := t.Client().Dapr().OperatorV1beta1().DaprInstances().Get( t.Ctx(), dapr.Name, metav1.GetOptions{}, @@ -29,46 +27,17 @@ func Instance(t support.Test, dapr *daprApi.DaprInstance) func(g gomega.Gomega) } } -type InstanceOptions struct { - types.NamespacedName -} - -type InstanceOption func(*InstanceOptions) - -func WithInstanceName(value string) InstanceOption { - return func(options *InstanceOptions) { - options.Name = value - } -} - -func WithInstanceNamespace(value string) InstanceOption { - return func(options *InstanceOptions) { - options.Namespace = value - } -} - func DeployInstance( t support.Test, spec *daprAc.DaprInstanceSpecApplyConfiguration, - opts ...InstanceOption, ) *daprApi.DaprInstance { t.T().Helper() - io := InstanceOptions{} - io.Name = instance.DaprInstanceResourceName - io.Namespace = controller.NamespaceDefault - - for _, o := range opts { - o(&io) - } - - t.T().Logf("Setting up DaprInstance %s in namespace %s", io.Name, io.Namespace) - - cp := t.Client().Dapr().OperatorV1alpha1().DaprInstances(io.Namespace) + cp := t.Client().Dapr().OperatorV1beta1().DaprInstances() res, err := cp.Apply( t.Ctx(), - daprAc.DaprInstance(io.Name, io.Namespace). + daprAc.DaprInstance(instance.DaprInstanceResourceName). WithSpec(spec), metav1.ApplyOptions{ FieldManager: "dapr-e2e-" + t.ID(), @@ -78,7 +47,7 @@ func DeployInstance( t.Expect(err). ToNot(gomega.HaveOccurred()) - t.T().Logf("DaprInstance %s in namespace %s created", io.Name, io.Namespace) + t.T().Logf("DaprInstance %s in namespace %s created", res.Name, res.Spec.Deployment.Namespace) t.Cleanup(func() []runtime.Object { return []runtime.Object{res} diff --git a/test/support/olm/support_olm.go b/test/support/olm/support_olm.go index 9b01fec..95edc9c 100644 --- a/test/support/olm/support_olm.go +++ b/test/support/olm/support_olm.go @@ -125,7 +125,7 @@ func DeployOperator(test support.Test, ns *corev1.Namespace, image string) { Namespace: ns.Name, }, Spec: &olmV1Alpha1.SubscriptionSpec{ - Channel: "alpha", + Channel: "beta", Package: "dapr-kubernetes-operator", InstallPlanApproval: olmV1Alpha1.ApprovalAutomatic, CatalogSource: catalog.Name, diff --git a/test/support/test.go b/test/support/test.go index 4b4bc75..2157f0b 100644 --- a/test/support/test.go +++ b/test/support/test.go @@ -11,7 +11,7 @@ import ( helmsupport "github.com/dapr/kubernetes-operator/test/support/helm" - daprApi "github.com/dapr/kubernetes-operator/api/operator/v1alpha1" + daprApi "github.com/dapr/kubernetes-operator/api/operator/v1beta1" "k8s.io/client-go/kubernetes/scheme" "github.com/go-logr/logr/testr"