diff --git a/PROJECT b/PROJECT index b639ba2..77ce596 100644 --- a/PROJECT +++ b/PROJECT @@ -27,13 +27,4 @@ resources: kind: TenantResourceQuota path: github.com/edgenet-project/edgenet-software/api/multitenancy/v1 version: v1 -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: edge-net.io - group: deployments - kind: SelectiveDeployment - path: github.com/edgenet-project/edgenet-software/api/deployments/v1 - version: v1 version: "3" diff --git a/api/deployments/v1/groupversion_info.go b/api/deployments/v1/groupversion_info.go deleted file mode 100644 index 4152a21..0000000 --- a/api/deployments/v1/groupversion_info.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 v1 contains API Schema definitions for the deployments v1 API group -// +kubebuilder:object:generate=true -// +groupName=deployments.edge-net.io -package v1 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var ( - // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "deployments.edge-net.io", Version: "v1"} - - // SchemeBuilder is used to add go types to the GroupVersionKind scheme - SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} - - // AddToScheme adds the types in this group-version to the given scheme. - AddToScheme = SchemeBuilder.AddToScheme -) diff --git a/api/deployments/v1/selectivedeployment_types.go b/api/deployments/v1/selectivedeployment_types.go deleted file mode 100644 index 737d3cb..0000000 --- a/api/deployments/v1/selectivedeployment_types.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 v1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// SelectiveDeploymentSpec defines the desired state of SelectiveDeployment -type SelectiveDeploymentSpec struct { -} - -// SelectiveDeploymentStatus defines the observed state of SelectiveDeployment -type SelectiveDeploymentStatus struct { -} - -// SelectiveDeployment is the Schema for the selectivedeployments API -// +kubebuilder:object:root=true -// +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=sd -// +kubebuilder:resource:scope=Namespaced -type SelectiveDeployment struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec SelectiveDeploymentSpec `json:"spec,omitempty"` - Status SelectiveDeploymentStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// SelectiveDeploymentList contains a list of SelectiveDeployment -type SelectiveDeploymentList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []SelectiveDeployment `json:"items"` -} - -func init() { - SchemeBuilder.Register(&SelectiveDeployment{}, &SelectiveDeploymentList{}) -} diff --git a/api/deployments/v1/zz_generated.deepcopy.go b/api/deployments/v1/zz_generated.deepcopy.go deleted file mode 100644 index e333d24..0000000 --- a/api/deployments/v1/zz_generated.deepcopy.go +++ /dev/null @@ -1,114 +0,0 @@ -//go:build !ignore_autogenerated - -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 controller-gen. DO NOT EDIT. - -package v1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SelectiveDeployment) DeepCopyInto(out *SelectiveDeployment) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectiveDeployment. -func (in *SelectiveDeployment) DeepCopy() *SelectiveDeployment { - if in == nil { - return nil - } - out := new(SelectiveDeployment) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SelectiveDeployment) 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 *SelectiveDeploymentList) DeepCopyInto(out *SelectiveDeploymentList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]SelectiveDeployment, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectiveDeploymentList. -func (in *SelectiveDeploymentList) DeepCopy() *SelectiveDeploymentList { - if in == nil { - return nil - } - out := new(SelectiveDeploymentList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SelectiveDeploymentList) 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 *SelectiveDeploymentSpec) DeepCopyInto(out *SelectiveDeploymentSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectiveDeploymentSpec. -func (in *SelectiveDeploymentSpec) DeepCopy() *SelectiveDeploymentSpec { - if in == nil { - return nil - } - out := new(SelectiveDeploymentSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SelectiveDeploymentStatus) DeepCopyInto(out *SelectiveDeploymentStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectiveDeploymentStatus. -func (in *SelectiveDeploymentStatus) DeepCopy() *SelectiveDeploymentStatus { - if in == nil { - return nil - } - out := new(SelectiveDeploymentStatus) - in.DeepCopyInto(out) - return out -} diff --git a/config/crd/bases/deployments.edge-net.io_selectivedeployments.yaml b/config/crd/bases/deployments.edge-net.io_selectivedeployments.yaml deleted file mode 100644 index 5394d67..0000000 --- a/config/crd/bases/deployments.edge-net.io_selectivedeployments.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.14.0 - name: selectivedeployments.deployments.edge-net.io -spec: - group: deployments.edge-net.io - names: - kind: SelectiveDeployment - listKind: SelectiveDeploymentList - plural: selectivedeployments - singular: selectivedeployment - scope: Namespaced - versions: - - name: v1 - schema: - openAPIV3Schema: - description: SelectiveDeployment is the Schema for the selectivedeployments - API - 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: - description: SelectiveDeploymentSpec defines the desired state of SelectiveDeployment - type: object - status: - description: SelectiveDeploymentStatus defines the observed state of SelectiveDeployment - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index c49d90d..5429f81 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -6,7 +6,6 @@ resources: # - edgenet_system_namespace.yaml - bases/multitenancy.edge-net.io_tenants.yaml - bases/multitenancy.edge-net.io_tenantresourcequotas.yaml -- bases/deployments.edge-net.io_selectivedeployments.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: @@ -14,14 +13,12 @@ patches: # patches here are for enabling the conversion webhook for each CRD #- path: patches/webhook_in_multitenancy_tenants.yaml #- path: patches/webhook_in_multitenancy_tenantresourcequotas.yaml -#- path: patches/webhook_in_deployments_selectivedeployments.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- path: patches/cainjection_in_multitenancy_tenants.yaml #- path: patches/cainjection_in_multitenancy_tenantresourcequotas.yaml -#- path: patches/cainjection_in_deployments_selectivedeployments.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/config/rbac/deployments_selectivedeployment_editor_role.yaml b/config/rbac/deployments_selectivedeployment_editor_role.yaml deleted file mode 100644 index 1df5576..0000000 --- a/config/rbac/deployments_selectivedeployment_editor_role.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# permissions for end users to edit selectivedeployments. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: selectivedeployment-editor-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: edgenet - app.kubernetes.io/part-of: edgenet - app.kubernetes.io/managed-by: kustomize - name: selectivedeployment-editor-role -rules: -- apiGroups: - - deployments.edge-net.io - resources: - - selectivedeployments - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - deployments.edge-net.io - resources: - - selectivedeployments/status - verbs: - - get diff --git a/config/rbac/deployments_selectivedeployment_viewer_role.yaml b/config/rbac/deployments_selectivedeployment_viewer_role.yaml deleted file mode 100644 index d8351ca..0000000 --- a/config/rbac/deployments_selectivedeployment_viewer_role.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# permissions for end users to view selectivedeployments. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - labels: - app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: selectivedeployment-viewer-role - app.kubernetes.io/component: rbac - app.kubernetes.io/created-by: edgenet - app.kubernetes.io/part-of: edgenet - app.kubernetes.io/managed-by: kustomize - name: selectivedeployment-viewer-role -rules: -- apiGroups: - - deployments.edge-net.io - resources: - - selectivedeployments - verbs: - - get - - list - - watch -- apiGroups: - - deployments.edge-net.io - resources: - - selectivedeployments/status - verbs: - - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 3603cdd..f4e2db3 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -1,4 +1,3 @@ ---- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -17,9 +16,33 @@ rules: - update - watch - apiGroups: - - crd.antrea.io + - apps resources: - - clusternetworkpolicies + - cronjobs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - apps + resources: + - daemonsets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - apps + resources: + - deployments verbs: - create - delete @@ -29,9 +52,9 @@ rules: - update - watch - apiGroups: - - deployments.edge-net.io + - apps resources: - - selectivedeployments + - jobs verbs: - create - delete @@ -41,19 +64,29 @@ rules: - update - watch - apiGroups: - - deployments.edge-net.io + - apps resources: - - selectivedeployments/finalizers + - statefulsets verbs: + - create + - delete + - get + - list + - patch - update + - watch - apiGroups: - - deployments.edge-net.io + - crd.antrea.io resources: - - selectivedeployments/status + - clusternetworkpolicies verbs: + - create + - delete - get + - list - patch - update + - watch - apiGroups: - multitenancy.edge-net.io resources: diff --git a/config/samples/deployments_v1_selectivedeployment.yaml b/config/samples/deployments_v1_selectivedeployment.yaml deleted file mode 100644 index d0395f2..0000000 --- a/config/samples/deployments_v1_selectivedeployment.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: deployments.edge-net.io/v1 -kind: SelectiveDeployment -metadata: - labels: - app.kubernetes.io/name: selectivedeployment - app.kubernetes.io/instance: selectivedeployment-sample - app.kubernetes.io/part-of: edgenet - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: edgenet - name: selectivedeployment-sample -spec: - # TODO(user): Add fields here diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index df66528..e0098a3 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -2,5 +2,4 @@ resources: - multitenancy_v1_tenant.yaml - multitenancy_v1_tenantresourcequota.yaml -- deployments_v1_selectivedeployment.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/internal/controller/deployments/selectivedeployment_controller.go b/internal/controller/deployments/selectivedeployment_controller.go deleted file mode 100644 index ce644f7..0000000 --- a/internal/controller/deployments/selectivedeployment_controller.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 deployments - -import ( - "context" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/tools/record" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/log" - - deploymentsv1 "github.com/edgenet-project/edgenet-software/api/deployments/v1" - "github.com/edgenet-project/edgenet-software/internal/deployments/v1" - "github.com/edgenet-project/edgenet-software/internal/utils" -) - -// SelectiveDeploymentReconciler reconciles a SelectiveDeployment object -type SelectiveDeploymentReconciler struct { - client.Client - Scheme *runtime.Scheme - recorder record.EventRecorder -} - -//+kubebuilder:rbac:groups=deployments.edge-net.io,resources=selectivedeployments,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=deployments.edge-net.io,resources=selectivedeployments/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=deployments.edge-net.io,resources=selectivedeployments/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the SelectiveDeployment object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.17.0/pkg/reconcile -func (r *SelectiveDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx) - sd := deploymentsv1.SelectiveDeployment{} - isMarkedForDeletion, reconcileResult, err := utils.GetResourceWithFinalizer(ctx, r.Client, &sd, req.NamespacedName) - - if !utils.IsObjectInitialized(&sd) { - return reconcileResult, err - } - - deploymentManager, err := deployments.NewDeploymentManager(ctx, r.Client) - - if err != nil { - logger.Error(err, "cannot create deployment manager") - return ctrl.Result{}, nil - } - - if isMarkedForDeletion { - if err := deploymentManager.SelectiveDeploymentCleanup(ctx, &sd); err != nil { - utils.RecordEventError(r.recorder, &sd, "Selective Deployment cleanup failed") - return ctrl.Result{Requeue: true}, err - } - - return utils.AllowObjectDeletion(ctx, r.Client, &sd) - } else { - logger.Info("Reconciliation...") - // See how SD is implemented... - // TODO - } - - utils.RecordEventInfo(r.recorder, &sd, "Selective Deployment reconciliation successfull") - return ctrl.Result{}, nil -} - -// SetupWithManager sets up the controller with the Manager. -func (r *SelectiveDeploymentReconciler) SetupWithManager(mgr ctrl.Manager) error { - // Setup the event recorder - r.recorder = utils.GetEventRecorder(mgr) - return ctrl.NewControllerManagedBy(mgr). - For(&deploymentsv1.SelectiveDeployment{}). - Complete(r) -} diff --git a/internal/controller/deployments/selectivedeployment_controller_test.go b/internal/controller/deployments/selectivedeployment_controller_test.go deleted file mode 100644 index 3650fa2..0000000 --- a/internal/controller/deployments/selectivedeployment_controller_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 deployments - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - deploymentsv1 "github.com/edgenet-project/edgenet-software/api/deployments/v1" -) - -var _ = Describe("SelectiveDeployment Controller", func() { - Context("When reconciling a resource", func() { - const resourceName = "test-resource" - - ctx := context.Background() - - typeNamespacedName := types.NamespacedName{ - Name: resourceName, - Namespace: "default", // TODO(user):Modify as needed - } - selectivedeployment := &deploymentsv1.SelectiveDeployment{} - - BeforeEach(func() { - By("creating the custom resource for the Kind SelectiveDeployment") - err := k8sClient.Get(ctx, typeNamespacedName, selectivedeployment) - if err != nil && errors.IsNotFound(err) { - resource := &deploymentsv1.SelectiveDeployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: resourceName, - Namespace: "default", - }, - // TODO(user): Specify other spec details if needed. - } - Expect(k8sClient.Create(ctx, resource)).To(Succeed()) - } - }) - - AfterEach(func() { - // TODO(user): Cleanup logic after each test, like removing the resource instance. - resource := &deploymentsv1.SelectiveDeployment{} - err := k8sClient.Get(ctx, typeNamespacedName, resource) - Expect(err).NotTo(HaveOccurred()) - - By("Cleanup the specific resource instance SelectiveDeployment") - Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) - }) - It("should successfully reconcile the resource", func() { - By("Reconciling the created resource") - controllerReconciler := &SelectiveDeploymentReconciler{ - Client: k8sClient, - Scheme: k8sClient.Scheme(), - } - - _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: typeNamespacedName, - }) - Expect(err).NotTo(HaveOccurred()) - // TODO(user): Add more specific assertions depending on your controller's reconciliation logic. - // Example: If you expect a certain status condition after reconciliation, verify it here. - }) - }) -}) diff --git a/internal/controller/deployments/suite_test.go b/internal/controller/deployments/suite_test.go deleted file mode 100644 index 69d3f50..0000000 --- a/internal/controller/deployments/suite_test.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 deployments - -import ( - "fmt" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - deploymentsv1 "github.com/edgenet-project/edgenet-software/api/deployments/v1" - //+kubebuilder:scaffold:imports -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment - -func TestControllers(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Controller Suite") -} - -var _ = BeforeSuite(func() { - logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) - - By("bootstrapping test environment") - testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, - ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.29.0-%s-%s", runtime.GOOS, runtime.GOARCH)), - } - - var err error - // cfg is defined in this file globally. - cfg, err = testEnv.Start() - Expect(err).NotTo(HaveOccurred()) - Expect(cfg).NotTo(BeNil()) - - err = deploymentsv1.AddToScheme(scheme.Scheme) - Expect(err).NotTo(HaveOccurred()) - - //+kubebuilder:scaffold:scheme - - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(err).NotTo(HaveOccurred()) - Expect(k8sClient).NotTo(BeNil()) - -}) - -var _ = AfterSuite(func() { - By("tearing down the test environment") - err := testEnv.Stop() - Expect(err).NotTo(HaveOccurred()) -}) diff --git a/internal/controller/multitenancy/tenant_controller.go b/internal/controller/multitenancy/tenant_controller.go index 3e89d0e..871856c 100644 --- a/internal/controller/multitenancy/tenant_controller.go +++ b/internal/controller/multitenancy/tenant_controller.go @@ -38,13 +38,13 @@ type TenantReconciler struct { } // These are required to have the permissions. -//+kubebuilder:rbac:groups=multitenancy.edge-net.io,resources=tenants,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups="multitenancy.edge-net.io",resources=tenants,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups="networking.k8s.io",resources=networkpolicies;clusternetworkpolicies,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups="crd.antrea.io",resources=clusternetworkpolicies,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=multitenancy.edge-net.io,resources=tenants/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=multitenancy.edge-net.io,resources=tenants/finalizers,verbs=update +//+kubebuilder:rbac:groups="multitenancy.edge-net.io",resources=tenants/status,verbs=get;update;patch +//+kubebuilder:rbac:groups="multitenancy.edge-net.io",resources=tenants/finalizers,verbs=update // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. diff --git a/internal/deployments/v1/deployments.go b/internal/deployments/v1/deployments.go deleted file mode 100644 index 607d85c..0000000 --- a/internal/deployments/v1/deployments.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2024 Contributors to EdgeNet Project. - -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 deployments - -import ( - "context" - - deploymentsv1 "github.com/edgenet-project/edgenet-software/api/deployments/v1" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -// This interface contains the necessary functions to perform the operations related to -// deployments. Most of the implementation here is retrieved from the old implementation. -// However, some of the functions are changed. -type DeploymentManager interface { - // Cleanup the Selective Deployment's derivatives. - SelectiveDeploymentCleanup(context.Context, *deploymentsv1.SelectiveDeployment) error -} - -type deploymentManager struct { - DeploymentManager - client client.Client -} - -func NewDeploymentManager(ctx context.Context, client client.Client) (DeploymentManager, error) { - return &deploymentManager{ - client: client, - }, nil -} - -func (m *deploymentManager) SelectiveDeploymentCleanup(ctx context.Context, sd *deploymentsv1.SelectiveDeployment) error { - return nil -}