From e0e49975dc840439eed050a12c0bafc24a9c9b79 Mon Sep 17 00:00:00 2001 From: AmaliMatharaarachchi Date: Mon, 30 Oct 2023 16:58:29 +0530 Subject: [PATCH] add crd changes to helm in gradle build --- adapter/README.md | 4 +- adapter/build.gradle | 7 ++ adapter/internal/operator/Makefile | 3 +- .../crd/bases/cp.wso2.com_applications.yaml | 76 ------------------- .../crd/bases/cp.wso2.com_subscriptions.yaml | 67 ---------------- helm-charts/crds/dp.wso2.com_apipolicies.yaml | 17 ----- helm-charts/crds/dp.wso2.com_backends.yaml | 15 ---- .../crds/dp.wso2.com_interceptorservices.yaml | 16 ---- helm-charts/crds/dp.wso2.com_scopes.yaml | 16 ---- 9 files changed, 10 insertions(+), 211 deletions(-) delete mode 100644 adapter/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml delete mode 100644 adapter/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml diff --git a/adapter/README.md b/adapter/README.md index 82fa02e24..a25ebac91 100644 --- a/adapter/README.md +++ b/adapter/README.md @@ -206,15 +206,13 @@ Following are some tasks with the steps that a developer might do in operator de 14. Generating CRD and other resource yamls: ```bash - make manifests + gradle build ``` This will generate artefacts inside `{OPERATOR_HOME}/config` directory. 15. To make the CRD and other resource changes affect, you need to move the k8s resources to the helm chart in `PROJECT_HOME/helm-charts` directory: - - Copy the newly created CRD (in this example `dp.wso2.com_apipolicies.yaml`) from `adapter/internal/operator/config/crd/bases` to `helm-charts/crds`. - - Append new rules to the `ClusterRole` in `helm-charts/templates/serviceAccount/apk-cluster-role.yaml`. ```yaml diff --git a/adapter/build.gradle b/adapter/build.gradle index f68e6026b..e284fa340 100644 --- a/adapter/build.gradle +++ b/adapter/build.gradle @@ -65,6 +65,7 @@ tasks.register('go_test', Exec) { tasks.named('go_revive_run').configure { finalizedBy go_tidy finalizedBy go_test + finalizedBy add_crds_helm dependsOn operator_make dependsOn operator_make_manifests } @@ -85,6 +86,12 @@ tasks.register('operator_make_manifests', Exec) { finalizedBy go_build } +tasks.register('add_crds_helm', Exec) { + group 'go' + description 'copy new CRD changes to helm chart' + commandLine 'cp','-r', "$rootDir/../adapter/internal/operator/config/crd/bases/", "$rootDir/../helm-charts/crds" +} + tasks.named('go_build').configure { dependsOn operator_make_manifests dependsOn go_revive_run diff --git a/adapter/internal/operator/Makefile b/adapter/internal/operator/Makefile index e1f6acc4a..e937e99e8 100644 --- a/adapter/internal/operator/Makefile +++ b/adapter/internal/operator/Makefile @@ -40,7 +40,8 @@ help: ## Display this help. .PHONY: manifests manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases + $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./apis/dp/..." output:crd:artifacts:config=config/crd/bases + .PHONY: generate generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. diff --git a/adapter/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml b/adapter/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml deleted file mode 100644 index 72de96d01..000000000 --- a/adapter/internal/operator/config/crd/bases/cp.wso2.com_applications.yaml +++ /dev/null @@ -1,76 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null - name: applications.cp.wso2.com -spec: - group: cp.wso2.com - names: - kind: Application - listKind: ApplicationList - plural: applications - singular: application - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Application is the Schema for the applications 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: ApplicationSpec defines the desired state of Application - properties: - attributes: - additionalProperties: - type: string - type: object - keys: - items: - description: Key defines the keys of Application - properties: - key: - type: string - keyManager: - type: string - required: - - key - - keyManager - type: object - type: array - name: - type: string - organization: - type: string - owner: - type: string - policy: - type: string - required: - - name - - organization - - owner - - policy - type: object - status: - description: ApplicationStatus defines the observed state of Application - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/adapter/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml b/adapter/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml deleted file mode 100644 index ab870295f..000000000 --- a/adapter/internal/operator/config/crd/bases/cp.wso2.com_subscriptions.yaml +++ /dev/null @@ -1,67 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.9.2 - creationTimestamp: null - name: subscriptions.cp.wso2.com -spec: - group: cp.wso2.com - names: - kind: Subscription - listKind: SubscriptionList - plural: subscriptions - singular: subscription - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Subscription is the Schema for the subscriptions 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: SubscriptionSpec defines the desired state of Subscription - properties: - apiRef: - description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - Important: Run "make" to regenerate code after modifying this file' - type: string - applicationRef: - type: string - organization: - type: string - policyId: - type: string - subscriber: - type: string - subscriptionStatus: - type: string - required: - - apiRef - - applicationRef - - organization - - policyId - - subscriber - - subscriptionStatus - type: object - status: - description: SubscriptionStatus defines the observed state of Subscription - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/helm-charts/crds/dp.wso2.com_apipolicies.yaml b/helm-charts/crds/dp.wso2.com_apipolicies.yaml index 154632cc7..562864106 100644 --- a/helm-charts/crds/dp.wso2.com_apipolicies.yaml +++ b/helm-charts/crds/dp.wso2.com_apipolicies.yaml @@ -1,20 +1,3 @@ -# -------------------------------------------------------------------- -# Copyright (c) 2023, WSO2 LLC. (http://wso2.com) All Rights Reserved. -# -# 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. -# ----------------------------------------------------------------------- - - --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition diff --git a/helm-charts/crds/dp.wso2.com_backends.yaml b/helm-charts/crds/dp.wso2.com_backends.yaml index d2b77572e..40f5798b1 100644 --- a/helm-charts/crds/dp.wso2.com_backends.yaml +++ b/helm-charts/crds/dp.wso2.com_backends.yaml @@ -1,18 +1,3 @@ -# -------------------------------------------------------------------- -# Copyright (c) 2023, WSO2 LLC. (http://wso2.com) All Rights Reserved. -# -# 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. -# ----------------------------------------------------------------------- --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition diff --git a/helm-charts/crds/dp.wso2.com_interceptorservices.yaml b/helm-charts/crds/dp.wso2.com_interceptorservices.yaml index 5d180e3f4..41592984d 100644 --- a/helm-charts/crds/dp.wso2.com_interceptorservices.yaml +++ b/helm-charts/crds/dp.wso2.com_interceptorservices.yaml @@ -1,19 +1,3 @@ -# -------------------------------------------------------------------- -# Copyright (c) 2023, WSO2 LLC. (http://wso2.com) All Rights Reserved. -# -# 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. -# ----------------------------------------------------------------------- - --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition diff --git a/helm-charts/crds/dp.wso2.com_scopes.yaml b/helm-charts/crds/dp.wso2.com_scopes.yaml index c4447ea4e..9012b5e74 100644 --- a/helm-charts/crds/dp.wso2.com_scopes.yaml +++ b/helm-charts/crds/dp.wso2.com_scopes.yaml @@ -1,19 +1,3 @@ -# -------------------------------------------------------------------- -# Copyright (c) 2023, WSO2 LLC. (http://wso2.com) All Rights Reserved. -# -# 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. -# ----------------------------------------------------------------------- - --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition