From 4e9702031e1f13a434a1c024c82592851e7abd4a Mon Sep 17 00:00:00 2001 From: akhandelwal Date: Mon, 22 Jan 2024 12:25:54 -0800 Subject: [PATCH] chargedBack field added --- .../bases/registry.ethos.adobe.com_clusters.yaml | 4 ++++ local/client/dummy-crd.yaml | 1 + local/database/dummy-data.yaml | 1 + pkg/api/registry/v1/cluster_types.go | 4 ++++ pkg/apiserver/docs/docs.go | 4 ++++ pkg/apiserver/docs/swagger.json | 4 ++++ pkg/apiserver/docs/swagger.yaml | 5 +++++ pkg/client/controllers/cluster_controller_test.go | 1 + pkg/client/webhook/webhook_test.go | 1 + pkg/database/database_test.go | 15 +++++++++++++++ pkg/database/testdata/clusters.yaml | 3 +++ test/testdata/cluster05-prod-useast1-update.json | 1 + test/testdata/cluster05-prod-useast1.json | 1 + 13 files changed, 45 insertions(+) diff --git a/config/crd/bases/registry.ethos.adobe.com_clusters.yaml b/config/crd/bases/registry.ethos.adobe.com_clusters.yaml index d22fdbf1..c9b7d9ca 100644 --- a/config/crd/bases/registry.ethos.adobe.com_clusters.yaml +++ b/config/crd/bases/registry.ethos.adobe.com_clusters.yaml @@ -111,6 +111,9 @@ spec: chargebackBusinessUnit: description: The BU responsible for paying for the cluster. type: string + chargedBack: + description: Whether the cluster is charged back to the chargebackBusinessUnit + type: boolean cloudProviderRegion: description: The cloud provider standard region type: string @@ -321,6 +324,7 @@ spec: - apiServer - businessUnit - chargebackBusinessUnit + - chargedBack - cloudProviderRegion - cloudType - environment diff --git a/local/client/dummy-crd.yaml b/local/client/dummy-crd.yaml index 5a83aec7..f22aad17 100644 --- a/local/client/dummy-crd.yaml +++ b/local/client/dummy-crd.yaml @@ -16,6 +16,7 @@ spec: type: Shared businessUnit: BU1 chargebackBusinessUnit: BU1 + chargedBack: true offering: - CaaS - PaaS diff --git a/local/database/dummy-data.yaml b/local/database/dummy-data.yaml index 40eb4650..04b3d651 100644 --- a/local/database/dummy-data.yaml +++ b/local/database/dummy-data.yaml @@ -16,6 +16,7 @@ type: Shared businessUnit: BU1 chargebackBusinessUnit: BU1 + chargedBack: true offering: - CaaS - PaaS diff --git a/pkg/api/registry/v1/cluster_types.go b/pkg/api/registry/v1/cluster_types.go index 243620b0..4f79bb59 100644 --- a/pkg/api/registry/v1/cluster_types.go +++ b/pkg/api/registry/v1/cluster_types.go @@ -59,6 +59,10 @@ type ClusterSpec struct { // +kubebuilder:validation:Required ChargebackBusinessUnit string `json:"chargebackBusinessUnit"` + // Whether the cluster is charged back to the chargebackBusinessUnit + // +kubebuilder:validation:Required + ChargedBack bool `json:"chargedBack"` + // The Org that is responsible for the cluster operations // +kubebuilder:validation:Required ManagingOrg string `json:"managingOrg"` diff --git a/pkg/apiserver/docs/docs.go b/pkg/apiserver/docs/docs.go index 4f03cd26..e4a6c100 100644 --- a/pkg/apiserver/docs/docs.go +++ b/pkg/apiserver/docs/docs.go @@ -545,6 +545,10 @@ const docTemplate = `{ "description": "The BU responsible for paying for the cluster.\n+kubebuilder:validation:Required", "type": "string" }, + "chargedBack": { + "description": "Whether the cluster is charged back to the chargebackBusinessUnit\n+kubebuilder:validation:Required", + "type": "boolean" + }, "cloudProviderRegion": { "description": "The cloud provider standard region\n+kubebuilder:validation:Required", "type": "string" diff --git a/pkg/apiserver/docs/swagger.json b/pkg/apiserver/docs/swagger.json index 46fc7eaf..1c26d422 100644 --- a/pkg/apiserver/docs/swagger.json +++ b/pkg/apiserver/docs/swagger.json @@ -543,6 +543,10 @@ "description": "The BU responsible for paying for the cluster.\n+kubebuilder:validation:Required", "type": "string" }, + "chargedBack": { + "description": "Whether the cluster is charged back to the chargebackBusinessUnit\n+kubebuilder:validation:Required", + "type": "boolean" + }, "cloudProviderRegion": { "description": "The cloud provider standard region\n+kubebuilder:validation:Required", "type": "string" diff --git a/pkg/apiserver/docs/swagger.yaml b/pkg/apiserver/docs/swagger.yaml index f752e5c3..8d292191 100644 --- a/pkg/apiserver/docs/swagger.yaml +++ b/pkg/apiserver/docs/swagger.yaml @@ -88,6 +88,11 @@ definitions: The BU responsible for paying for the cluster. +kubebuilder:validation:Required type: string + chargedBack: + description: |- + Whether the cluster is charged back to the chargebackBusinessUnit + +kubebuilder:validation:Required + type: boolean cloudProviderRegion: description: |- The cloud provider standard region diff --git a/pkg/client/controllers/cluster_controller_test.go b/pkg/client/controllers/cluster_controller_test.go index dcba363c..22aef9f3 100644 --- a/pkg/client/controllers/cluster_controller_test.go +++ b/pkg/client/controllers/cluster_controller_test.go @@ -75,6 +75,7 @@ var _ = Describe("Cluster Controller", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{}, AccountID: "", Tiers: []registryv1.Tier{}, diff --git a/pkg/client/webhook/webhook_test.go b/pkg/client/webhook/webhook_test.go index d2df8949..f942cd1e 100644 --- a/pkg/client/webhook/webhook_test.go +++ b/pkg/client/webhook/webhook_test.go @@ -190,6 +190,7 @@ var _ = Describe("Webhook Server", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{}, AccountID: "", Tiers: []registryv1.Tier{}, diff --git a/pkg/database/database_test.go b/pkg/database/database_test.go index 7d6ebc89..1d7ee9cc 100644 --- a/pkg/database/database_test.go +++ b/pkg/database/database_test.go @@ -100,6 +100,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -435,6 +436,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -526,6 +528,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU2", ChargebackBusinessUnit: "BU2", + ChargedBack: false, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-55555555", Tiers: []registryv1.Tier{ @@ -594,6 +597,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"paas"}, AccountID: "12345678", Tiers: []registryv1.Tier{ @@ -688,6 +692,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -795,6 +800,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU2", ChargebackBusinessUnit: "BU2", + ChargedBack: false, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-55555555", Tiers: []registryv1.Tier{ @@ -927,6 +933,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -1018,6 +1025,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU2", ChargebackBusinessUnit: "BU2", + ChargedBack: false, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-55555555", Tiers: []registryv1.Tier{ @@ -1086,6 +1094,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"paas"}, AccountID: "12345678", Tiers: []registryv1.Tier{ @@ -1160,6 +1169,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -1251,6 +1261,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU2", ChargebackBusinessUnit: "BU2", + ChargedBack: false, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-55555555", Tiers: []registryv1.Tier{ @@ -1330,6 +1341,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -1421,6 +1433,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"paas"}, AccountID: "12345678", Tiers: []registryv1.Tier{ @@ -1498,6 +1511,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU1", ChargebackBusinessUnit: "BU1", + ChargedBack: true, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-555555555", Tiers: []registryv1.Tier{ @@ -1589,6 +1603,7 @@ var _ = Describe("Database Suite", func() { Environment: "Prod", BusinessUnit: "BU2", ChargebackBusinessUnit: "BU2", + ChargedBack: false, Offering: []registryv1.Offering{"caas", "paas"}, AccountID: "11111-2222-3333-4444-55555555", Tiers: []registryv1.Tier{ diff --git a/pkg/database/testdata/clusters.yaml b/pkg/database/testdata/clusters.yaml index bc29eb96..6a9d4c8f 100644 --- a/pkg/database/testdata/clusters.yaml +++ b/pkg/database/testdata/clusters.yaml @@ -15,6 +15,7 @@ type: Shared businessUnit: BU1 chargebackBusinessUnit: BU1 + chargedBack: true offering: - caas - paas @@ -104,6 +105,7 @@ type: Dedicated businessUnit: BU2 chargebackBusinessUnit: BU2 + chargedBack: false offering: - caas - paas @@ -170,6 +172,7 @@ type: Dedicated businessUnit: BU1 chargebackBusinessUnit: BU1 + chargedBack: true offering: - paas allowedTeams: diff --git a/test/testdata/cluster05-prod-useast1-update.json b/test/testdata/cluster05-prod-useast1-update.json index fc9d8607..d5fc477e 100644 --- a/test/testdata/cluster05-prod-useast1-update.json +++ b/test/testdata/cluster05-prod-useast1-update.json @@ -13,6 +13,7 @@ }, "businessUnit": "BU1", "chargebackBusinessUnit": "BU1", + "chargedBack": true, "managingOrg": "Org1", "cloudType": "azure", "environment": "prod", diff --git a/test/testdata/cluster05-prod-useast1.json b/test/testdata/cluster05-prod-useast1.json index 3d092ae0..20e5324d 100644 --- a/test/testdata/cluster05-prod-useast1.json +++ b/test/testdata/cluster05-prod-useast1.json @@ -13,6 +13,7 @@ }, "businessUnit": "BU1", "chargebackBusinessUnit": "BU1", + "chargedBack": true, "managingOrg": "Org1", "cloudType": "azure", "environment": "prod",