From f755b9351a2478753f09316688e06211977c7687 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Fri, 13 Dec 2024 10:40:54 -0800 Subject: [PATCH] Remove TSM integration support (#475) Signed-off-by: Vivek Goyal --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- Makefile | 2 +- docs/data-sources/integration.md | 68 ------ docs/resources/integration.md | 83 ------- .../data-sources/integration/data-source.tf | 7 - examples/resources/integration/resource.tf | 22 -- internal/client/http_client.go | 3 - .../integration/integration_resource.go | 121 ---------- .../integration/create_integration_request.go | 38 ---- .../create_integration_response.go | 38 ---- .../delete_integration_response.go | 38 ---- .../models/cluster/integration/full_name.go | 51 ----- .../integration/get_integration_response.go | 38 ---- .../models/cluster/integration/indicator.go | 53 ----- .../models/cluster/integration/integration.go | 53 ----- .../models/cluster/integration/operator.go | 53 ----- internal/models/cluster/integration/phase.go | 69 ------ internal/models/cluster/integration/spec.go | 47 ---- internal/models/cluster/integration/status.go | 63 ----- .../update_integration_response.go | 38 ---- .../models/cluster/integration/workload.go | 43 ---- .../models/organization/integration/phase.go | 79 ------- internal/provider/provider.go | 3 - .../resources/cluster/integration/constant.go | 20 -- .../integration/data_source_integration.go | 98 -------- .../data_source_integration_test.go | 33 --- .../integration/default_integration_client.go | 27 --- .../integration/resource_integration.go | 112 --------- .../resource_integration_helper.go | 83 ------- .../resource_integration_helper_test.go | 215 ------------------ .../integration/resource_integration_spec.go | 130 ----------- .../resource_integration_spec_test.go | 64 ------ .../integration/resource_integration_test.go | 74 ------ resource_templates/tsm-integration.tf | 33 --- templates/data-sources/integration.md.tmpl | 20 -- templates/resources/integration.md.tmpl | 20 -- 37 files changed, 3 insertions(+), 1940 deletions(-) delete mode 100644 docs/data-sources/integration.md delete mode 100644 docs/resources/integration.md delete mode 100644 examples/data-sources/integration/data-source.tf delete mode 100644 examples/resources/integration/resource.tf delete mode 100644 internal/client/integration/integration_resource.go delete mode 100644 internal/models/cluster/integration/create_integration_request.go delete mode 100644 internal/models/cluster/integration/create_integration_response.go delete mode 100644 internal/models/cluster/integration/delete_integration_response.go delete mode 100644 internal/models/cluster/integration/full_name.go delete mode 100644 internal/models/cluster/integration/get_integration_response.go delete mode 100644 internal/models/cluster/integration/indicator.go delete mode 100644 internal/models/cluster/integration/integration.go delete mode 100644 internal/models/cluster/integration/operator.go delete mode 100644 internal/models/cluster/integration/phase.go delete mode 100644 internal/models/cluster/integration/spec.go delete mode 100644 internal/models/cluster/integration/status.go delete mode 100644 internal/models/cluster/integration/update_integration_response.go delete mode 100644 internal/models/cluster/integration/workload.go delete mode 100644 internal/models/organization/integration/phase.go delete mode 100644 internal/resources/cluster/integration/constant.go delete mode 100644 internal/resources/cluster/integration/data_source_integration.go delete mode 100644 internal/resources/cluster/integration/data_source_integration_test.go delete mode 100644 internal/resources/cluster/integration/default_integration_client.go delete mode 100644 internal/resources/cluster/integration/resource_integration.go delete mode 100644 internal/resources/cluster/integration/resource_integration_helper.go delete mode 100644 internal/resources/cluster/integration/resource_integration_helper_test.go delete mode 100644 internal/resources/cluster/integration/resource_integration_spec.go delete mode 100644 internal/resources/cluster/integration/resource_integration_spec_test.go delete mode 100644 internal/resources/cluster/integration/resource_integration_test.go delete mode 100644 resource_templates/tsm-integration.tf delete mode 100644 templates/data-sources/integration.md.tmpl delete mode 100644 templates/resources/integration.md.tmpl diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 09a2b4200..634bd8acc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - "v*" env: - BUILD_TAGS: "akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner inspections custompolicytemplate customiamrole permissiontemplate" + BUILD_TAGS: "akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner inspections custompolicytemplate customiamrole permissiontemplate" permissions: contents: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d017019a..24e61de7f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: - 'README.md' env: - BUILD_TAGS: 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner inspections custompolicytemplate customiamrole permissiontemplate' + BUILD_TAGS: 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner inspections custompolicytemplate customiamrole permissiontemplate' jobs: build: diff --git a/Makefile b/Makefile index 0744f5c86..c90188744 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ ifeq ($(TEST_FLAGS),) endif ifeq ($(BUILD_TAGS),) - BUILD_TAGS := 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy helmfeature helmrelease helmcharts helmrepository backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner inspections custompolicytemplate customiamrole permissiontemplate' + BUILD_TAGS := 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret mutationpolicy helmfeature helmrelease helmcharts helmrepository backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner inspections custompolicytemplate customiamrole permissiontemplate' endif .PHONY: build clean-up test gofmt vet lint acc-test website-lint website-lint-fix diff --git a/docs/data-sources/integration.md b/docs/data-sources/integration.md deleted file mode 100644 index 63ac384d6..000000000 --- a/docs/data-sources/integration.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -Title: "Tanzu Service Mesh Integration Resource" -Description: |- - Fetching the details of Integration by Tanzu Service Mesh. ---- - -# Tanzu Service Mesh Integration - -The `Tanzu Service Mesh integration` is available on the Tanzu Mission Control platform. -When the Tanzu Service Mesh service has been enabled on your organization, your Tanzu Mission Control organization administrator can enable the integration for use on clusters that are managed through Tanzu Mission Control. -Then, cluster administrators can add Tanzu Service Mesh to managed clusters and designate which namespaces should belong in the mesh. -`Tanzu Mission Control` takes care of the installation of service mesh components in the cluster, provides health status, and onboards it into Tanzu Service Mesh. - -For reading the Tanzu Service Mesh Integration via the terraform provider, use the following configuration. - -## Example Usage - -```terraform -# Read Tanzu Mission Control TSM integration : fetch details -data "tanzu-mission-control_integration" "read_tsm-integration" { - management_cluster_name = "attached" - provisioner_name = "attached" - cluster_name = "test-cluster" - integration_name = "tanzu-service-mesh" -} -``` - - -## Schema - -### Required - -- `cluster_name` (String) Name of this cluster -- `integration_name` (String) Name of the Integration; valid options are currently only ['tanzu-service-mesh'] -- `spec` (Block List, Min: 1, Max: 1) Specification for the Integration (see [below for nested schema](#nestedblock--spec)) - -### Optional - -- `management_cluster_name` (String) Name of the management cluster -- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta)) -- `provisioner_name` (String) Provisioner of the cluster - -### Read-Only - -- `id` (String) The ID of this resource. -- `status` (Map of String) Status of Integration - - -### Nested Schema for `spec` - -Optional: - -- `configurations` (String) Integration specific configurations in JSON format - - - -### Nested Schema for `meta` - -Optional: - -- `annotations` (Map of String) Annotations for the resource -- `description` (String) Description of the resource -- `labels` (Map of String) Labels for the resource - -Read-Only: - -- `resource_version` (String) Resource version of the resource -- `uid` (String) UID of the resource diff --git a/docs/resources/integration.md b/docs/resources/integration.md deleted file mode 100644 index 21f1b2643..000000000 --- a/docs/resources/integration.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -Title: "Tanzu Service Mesh Integration Resource" -Description: |- - Creating the Integration by Tanzu Service Mesh on a cluster. ---- - -# Tanzu Service Mesh Integration - -The `Tanzu Service Mesh integration` is available on the Tanzu Mission Control platform. -When the Tanzu Service Mesh service has been enabled on your organization, your Tanzu Mission Control organization administrator can enable the integration for use on clusters that are managed through Tanzu Mission Control. -Then, cluster administrators can add Tanzu Service Mesh to managed clusters and designate which namespaces should belong in the mesh. -`Tanzu Mission Control` takes care of the installation of service mesh components in the cluster, provides health status, and onboards it into Tanzu Service Mesh. - -For leveraging this feature via the terraform provider, use the following configuration. - -## Example Usage - -```terraform -# Create Tanzu Mission Control TSM Integration resource -resource "tanzu-mission-control_integration" "create_tsm-integration" { - management_cluster_name = "attached" - provisioner_name = "attached" - cluster_name = "test-cluster" - integration_name = "tanzu-service-mesh" - - spec { - configurations = jsonencode({ - enableNamespaceExclusions = true - namespaceExclusions = [ - { - match = "custom-namespace-1" - type = "EXACT" - }, { - match = "kube" - type = "START_WITH" - } - ] - }) - } -} -``` - - -## Schema - -### Required - -- `cluster_name` (String) Name of this cluster -- `integration_name` (String) Name of the Integration; valid options are currently only ['tanzu-service-mesh'] -- `spec` (Block List, Min: 1, Max: 1) Specification for the Integration (see [below for nested schema](#nestedblock--spec)) - -### Optional - -- `management_cluster_name` (String) Name of the management cluster -- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta)) -- `provisioner_name` (String) Provisioner of the cluster - -### Read-Only - -- `id` (String) The ID of this resource. -- `status` (Map of String) Status of Integration - - -### Nested Schema for `spec` - -Optional: - -- `configurations` (String) Integration specific configurations in JSON format - - - -### Nested Schema for `meta` - -Optional: - -- `annotations` (Map of String) Annotations for the resource -- `description` (String) Description of the resource -- `labels` (Map of String) Labels for the resource - -Read-Only: - -- `resource_version` (String) Resource version of the resource -- `uid` (String) UID of the resource diff --git a/examples/data-sources/integration/data-source.tf b/examples/data-sources/integration/data-source.tf deleted file mode 100644 index e9c0041e1..000000000 --- a/examples/data-sources/integration/data-source.tf +++ /dev/null @@ -1,7 +0,0 @@ -# Read Tanzu Mission Control TSM integration : fetch details -data "tanzu-mission-control_integration" "read_tsm-integration" { - management_cluster_name = "attached" - provisioner_name = "attached" - cluster_name = "test-cluster" - integration_name = "tanzu-service-mesh" -} diff --git a/examples/resources/integration/resource.tf b/examples/resources/integration/resource.tf deleted file mode 100644 index d2ac0d9c8..000000000 --- a/examples/resources/integration/resource.tf +++ /dev/null @@ -1,22 +0,0 @@ -# Create Tanzu Mission Control TSM Integration resource -resource "tanzu-mission-control_integration" "create_tsm-integration" { - management_cluster_name = "attached" - provisioner_name = "attached" - cluster_name = "test-cluster" - integration_name = "tanzu-service-mesh" - - spec { - configurations = jsonencode({ - enableNamespaceExclusions = true - namespaceExclusions = [ - { - match = "custom-namespace-1" - type = "EXACT" - }, { - match = "kube" - type = "START_WITH" - } - ] - }) - } -} diff --git a/internal/client/http_client.go b/internal/client/http_client.go index 8f98fcf1a..8fdb1adc8 100644 --- a/internal/client/http_client.go +++ b/internal/client/http_client.go @@ -44,7 +44,6 @@ import ( eksclusterclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/ekscluster" eksnodepoolclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/ekscluster/nodepool" inspectionsclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/inspections" - integrationclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/integration" kubeconfigclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/kubeconfig" secretclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/kubernetessecret" secretexportclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/kubernetessecret/secretexport" @@ -117,7 +116,6 @@ func newHTTPClient(httpClient *transport.Client) *TanzuMissionControl { WorkspacePolicyResourceService: policyworkspaceclient.New(httpClient), OrganizationPolicyResourceService: policyorganizationclient.New(httpClient), CredentialResourceService: credentialclient.New(httpClient), - IntegrationResourceService: integrationclient.New(httpClient), ClusterContinuousDeliveryResourceService: continuousdeliveryclusterclient.New(httpClient), ClusterGitRepositoryResourceService: gitrepositoryclusterclient.New(httpClient), ClusterKustomizationResourceService: kustomizationclusterclient.New(httpClient), @@ -182,7 +180,6 @@ type TanzuMissionControl struct { WorkspacePolicyResourceService policyworkspaceclient.ClientService OrganizationPolicyResourceService policyorganizationclient.ClientService CredentialResourceService credentialclient.ClientService - IntegrationResourceService integrationclient.ClientService ClusterContinuousDeliveryResourceService continuousdeliveryclusterclient.ClientService ClusterGitRepositoryResourceService gitrepositoryclusterclient.ClientService ClusterKustomizationResourceService kustomizationclusterclient.ClientService diff --git a/internal/client/integration/integration_resource.go b/internal/client/integration/integration_resource.go deleted file mode 100644 index fc91257fa..000000000 --- a/internal/client/integration/integration_resource.go +++ /dev/null @@ -1,121 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integrationclient - -import ( - "fmt" - "net/url" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" -) - -func New(transport *transport.Client) ClientService { - return &client{Client: transport} -} - -type client struct { - *transport.Client -} - -type ClientService interface { - ManageV1alpha1ClusterIntegrationResourceServiceCreate( - *integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest, - ) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse, error) - - ManageV1alpha1ClusterIntegrationResourceServiceRead( - *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName, - ) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse, error) - - ManageV1alpha1ClusterIntegrationResourceServiceDelete( - *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName, - ) error -} - -func (c *client) ManageV1alpha1ClusterIntegrationResourceServiceCreate( - request *integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest, -) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse, error) { - response := &integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse{} - - fn := request.Integration.FullName - if errors := validateFullName(fn); len(errors) > 0 { - return nil, fmt.Errorf("incomplete full name: %v (%v)", errors, fn) - } - - err := c.Create(collectionEndpoint(fn), request, response) - - return response, err -} - -func (c *client) ManageV1alpha1ClusterIntegrationResourceServiceRead( - fn *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName, -) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse, error) { - if errors := validateFullName(fn); len(errors) > 0 { - return nil, fmt.Errorf("incomplete full name: %v (%v)", errors, fn) - } - - response := &integration.VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse{} - err := c.Get(resourceEndpoint(fn), response) - - return response, err -} - -func (c *client) ManageV1alpha1ClusterIntegrationResourceServiceDelete( - fn *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName, -) error { - if errors := validateFullName(fn); len(errors) > 0 { - return fmt.Errorf("incomplete full name: %v (%v)", errors, fn) - } - - return c.Delete(resourceEndpoint(fn)) -} - -const ( - clusterIntegrationPrefix = "v1alpha1/clusters" - integrationsResourceName = "integrations" -) - -func collectionEndpoint(fn *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) string { - return helper.ConstructRequestURL(clusterIntegrationPrefix, fn.ClusterName, integrationsResourceName).String() -} - -func resourceEndpoint(fn *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) string { - p := url.Values{} - p.Set("fullName.managementClusterName", fn.ManagementClusterName) - p.Set("fullName.provisionerName", fn.ProvisionerName) - p.Set("fullName.name", fn.Name) - - return helper. - ConstructRequestURL(clusterIntegrationPrefix, fn.ClusterName, integrationsResourceName, fn.Name). - AppendQueryParams(p). - String() -} - -func validateFullName(fn *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) []string { - if fn == nil { - return []string{"FullName is "} - } - - var errors []string - - if fn.Name == "" { - errors = append(errors, "missing Name") - } - - if fn.ClusterName == "" { - errors = append(errors, "missing ClusterName") - } - - if fn.ManagementClusterName == "" { - errors = append(errors, "missing ManagementClusterName") - } - - if fn.ProvisionerName == "" { - errors = append(errors, "missing ProvisionerName") - } - - return errors -} diff --git a/internal/models/cluster/integration/create_integration_request.go b/internal/models/cluster/integration/create_integration_request.go deleted file mode 100644 index 0c3b6ff3d..000000000 --- a/internal/models/cluster/integration/create_integration_request.go +++ /dev/null @@ -1,38 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest Request to create an Integration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.CreateIntegrationRequest -type VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest struct { - // Integration to create. - Integration *VmwareTanzuManageV1alpha1ClusterIntegrationIntegration `json:"integration,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/create_integration_response.go b/internal/models/cluster/integration/create_integration_response.go deleted file mode 100644 index cfbc83cde..000000000 --- a/internal/models/cluster/integration/create_integration_response.go +++ /dev/null @@ -1,38 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse Response from creating an Integration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.CreateIntegrationResponse -type VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse struct { - // Integration created. - Integration *VmwareTanzuManageV1alpha1ClusterIntegrationIntegration `json:"integration,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/delete_integration_response.go b/internal/models/cluster/integration/delete_integration_response.go deleted file mode 100644 index 90c75b31f..000000000 --- a/internal/models/cluster/integration/delete_integration_response.go +++ /dev/null @@ -1,38 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationDeleteIntegrationResponse Response from deleting an Integration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.DeleteIntegrationResponse -type VmwareTanzuManageV1alpha1ClusterIntegrationDeleteIntegrationResponse struct { - // Message regarding deletion. - Message string `json:"message,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationDeleteIntegrationResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationDeleteIntegrationResponse) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationDeleteIntegrationResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/full_name.go b/internal/models/cluster/integration/full_name.go deleted file mode 100644 index 8e54584b1..000000000 --- a/internal/models/cluster/integration/full_name.go +++ /dev/null @@ -1,51 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationFullName Full name of the cluster integration configuration. This includes the object name along -// with any parents or further identifiers. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.FullName -type VmwareTanzuManageV1alpha1ClusterIntegrationFullName struct { - // Name of the cluster. - ClusterName string `json:"clusterName,omitempty"` - - // Name of the management cluster. - ManagementClusterName string `json:"managementClusterName,omitempty"` - - // Name of the integration. - Name string `json:"name,omitempty"` - - // ID of Organization. - OrgID string `json:"orgId,omitempty"` - - // Name of the cluster provisioner. - ProvisionerName string `json:"provisionerName,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationFullName) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationFullName) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationFullName - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/get_integration_response.go b/internal/models/cluster/integration/get_integration_response.go deleted file mode 100644 index 5f86c173f..000000000 --- a/internal/models/cluster/integration/get_integration_response.go +++ /dev/null @@ -1,38 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse Response from getting an Integration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.GetIntegrationResponse -type VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse struct { - // Integration returned. - Integration *VmwareTanzuManageV1alpha1ClusterIntegrationIntegration `json:"integration,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/indicator.go b/internal/models/cluster/integration/indicator.go deleted file mode 100644 index 5d4079895..000000000 --- a/internal/models/cluster/integration/indicator.go +++ /dev/null @@ -1,53 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "encoding/json" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationIndicator Indicator is the value of the abstracted statuses. -// -// - INDICATOR_UNSPECIFIED: Default indicator. -// - OK: OK indicates everything is good. -// - ATTENTION_REQUIRED: ATTENTION_REQUIRED indicates something is bad / requires attention of user. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Indicator -type VmwareTanzuManageV1alpha1ClusterIntegrationIndicator string - -func NewVmwareTanzuManageV1alpha1ClusterIntegrationIndicator(value VmwareTanzuManageV1alpha1ClusterIntegrationIndicator) *VmwareTanzuManageV1alpha1ClusterIntegrationIndicator { - return &value -} - -// Pointer returns a pointer to a freshly-allocated VmwareTanzuManageV1alpha1ClusterIntegrationIndicator. -func (m VmwareTanzuManageV1alpha1ClusterIntegrationIndicator) Pointer() *VmwareTanzuManageV1alpha1ClusterIntegrationIndicator { - return &m -} - -const ( - - // VmwareTanzuManageV1alpha1ClusterIntegrationIndicatorINDICATORUNSPECIFIED captures enum value "INDICATOR_UNSPECIFIED". - VmwareTanzuManageV1alpha1ClusterIntegrationIndicatorINDICATORUNSPECIFIED VmwareTanzuManageV1alpha1ClusterIntegrationIndicator = "INDICATOR_UNSPECIFIED" - - // VmwareTanzuManageV1alpha1ClusterIntegrationIndicatorOK captures enum value "OK". - VmwareTanzuManageV1alpha1ClusterIntegrationIndicatorOK VmwareTanzuManageV1alpha1ClusterIntegrationIndicator = "OK" - - // VmwareTanzuManageV1alpha1ClusterIntegrationIndicatorATTENTIONREQUIRED captures enum value "ATTENTION_REQUIRED". - VmwareTanzuManageV1alpha1ClusterIntegrationIndicatorATTENTIONREQUIRED VmwareTanzuManageV1alpha1ClusterIntegrationIndicator = "ATTENTION_REQUIRED" -) - -// for schema. -var vmwareTanzuManageV1alpha1ClusterIntegrationIndicatorEnum []interface{} - -func init() { - var res []VmwareTanzuManageV1alpha1ClusterIntegrationIndicator - if err := json.Unmarshal([]byte(`["INDICATOR_UNSPECIFIED","OK","ATTENTION_REQUIRED"]`), &res); err != nil { - panic(err) - } - - for _, v := range res { - vmwareTanzuManageV1alpha1ClusterIntegrationIndicatorEnum = append(vmwareTanzuManageV1alpha1ClusterIntegrationIndicatorEnum, v) - } -} diff --git a/internal/models/cluster/integration/integration.go b/internal/models/cluster/integration/integration.go deleted file mode 100644 index 824735122..000000000 --- a/internal/models/cluster/integration/integration.go +++ /dev/null @@ -1,53 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" - - objectmetamodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/objectmeta" - policymodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/policy" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationIntegration An integration configuration for a cluster. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Integration -type VmwareTanzuManageV1alpha1ClusterIntegrationIntegration struct { - // Full name for the Cluster integration. - FullName *VmwareTanzuManageV1alpha1ClusterIntegrationFullName `json:"fullName,omitempty"` - - // Metadata for the Cluster policy. - Meta *objectmetamodel.VmwareTanzuCoreV1alpha1ObjectMeta `json:"meta,omitempty"` - - // Spec for the Cluster integration configuration. - Spec *VmwareTanzuManageV1alpha1ClusterIntegrationSpec `json:"spec,omitempty"` - - // Status for the Integration. - Status *VmwareTanzuManageV1alpha1ClusterIntegrationStatus `json:"status,omitempty"` - - // Metadata describing the type of the resource. - Type *policymodel.VmwareTanzuCoreV1alpha1ObjectType `json:"type,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationIntegration) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationIntegration) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationIntegration - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/operator.go b/internal/models/cluster/integration/operator.go deleted file mode 100644 index 3c28bc23b..000000000 --- a/internal/models/cluster/integration/operator.go +++ /dev/null @@ -1,53 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/extension" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/nodepool" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationOperator Status of the Integration Partner's operator deployed by TMC. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Operator -type VmwareTanzuManageV1alpha1ClusterIntegrationOperator struct { - // The Conditions attached to an extension resource. - Conditions map[string]nodepool.VmwareTanzuCoreV1alpha1StatusCondition `json:"conditions,omitempty"` - - // Health of the deployed extension. - Health *extension.VmwareTanzuManageV1alpha1ClusterExtensionHealth `json:"health,omitempty"` - - // Previous version of the extension. - PreviousVersion string `json:"previousVersion,omitempty"` - - // Phase of the extension. - State *extension.VmwareTanzuManageV1alpha1ClusterExtensionPhase `json:"state,omitempty"` - - // Version of the extension. - Version string `json:"version,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationOperator) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationOperator) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationOperator - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/phase.go b/internal/models/cluster/integration/phase.go deleted file mode 100644 index d02bbd42d..000000000 --- a/internal/models/cluster/integration/phase.go +++ /dev/null @@ -1,69 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "encoding/json" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationPhase Integration Lifecycle Phase. -// -// - PHASE_UNSPECIFIED: Unspecified phase. -// - CREATING: CREATING phase when process for adding integration to cluster is started. -// - UPDATING: Updating phase when need to update configuration for the added integration. -// - READY: READY phase when integration is added to cluster. -// - ERROR: Error phase when there is any issue during addition/update/deletion of the integration. -// - DELETING: DELETING phase when when process for removing integration to cluster is started. -// - PENDING: PENDING phase when the process is waiting for changes in the cluster after addition/update of the integration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Phase -type VmwareTanzuManageV1alpha1ClusterIntegrationPhase string - -func NewVmwareTanzuManageV1alpha1ClusterIntegrationPhase(value VmwareTanzuManageV1alpha1ClusterIntegrationPhase) *VmwareTanzuManageV1alpha1ClusterIntegrationPhase { - return &value -} - -// Pointer returns a pointer to a freshly-allocated VmwareTanzuManageV1alpha1ClusterIntegrationPhase. -func (m VmwareTanzuManageV1alpha1ClusterIntegrationPhase) Pointer() *VmwareTanzuManageV1alpha1ClusterIntegrationPhase { - return &m -} - -const ( - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhasePHASEUNSPECIFIED captures enum value "PHASE_UNSPECIFIED". - VmwareTanzuManageV1alpha1ClusterIntegrationPhasePHASEUNSPECIFIED VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "PHASE_UNSPECIFIED" - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhaseCREATING captures enum value "CREATING". - VmwareTanzuManageV1alpha1ClusterIntegrationPhaseCREATING VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "CREATING" - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhaseUPDATING captures enum value "UPDATING". - VmwareTanzuManageV1alpha1ClusterIntegrationPhaseUPDATING VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "UPDATING" - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhaseREADY captures enum value "READY". - VmwareTanzuManageV1alpha1ClusterIntegrationPhaseREADY VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "READY" - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhaseERROR captures enum value "ERROR". - VmwareTanzuManageV1alpha1ClusterIntegrationPhaseERROR VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "ERROR" - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhaseDELETING captures enum value "DELETING". - VmwareTanzuManageV1alpha1ClusterIntegrationPhaseDELETING VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "DELETING" - - // VmwareTanzuManageV1alpha1ClusterIntegrationPhasePENDING captures enum value "PENDING". - VmwareTanzuManageV1alpha1ClusterIntegrationPhasePENDING VmwareTanzuManageV1alpha1ClusterIntegrationPhase = "PENDING" -) - -// for schema. -var vmwareTanzuManageV1alpha1ClusterIntegrationPhaseEnum []interface{} - -func init() { - var res []VmwareTanzuManageV1alpha1ClusterIntegrationPhase - if err := json.Unmarshal([]byte(`["PHASE_UNSPECIFIED","CREATING","UPDATING","READY","ERROR","DELETING","PENDING"]`), &res); err != nil { - panic(err) - } - - for _, v := range res { - vmwareTanzuManageV1alpha1ClusterIntegrationPhaseEnum = append(vmwareTanzuManageV1alpha1ClusterIntegrationPhaseEnum, v) - } -} diff --git a/internal/models/cluster/integration/spec.go b/internal/models/cluster/integration/spec.go deleted file mode 100644 index dc2691957..000000000 --- a/internal/models/cluster/integration/spec.go +++ /dev/null @@ -1,47 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationSpec The integration configuration spec. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Spec -type VmwareTanzuManageV1alpha1ClusterIntegrationSpec struct { - // Configurations. The expected input schema can be found in v1alpha1/integration API. - Configurations map[string]interface{} `json:"configurations,omitempty"` - - // Credential name is the name of the Organization's Account Credential to be used instead of secrets to add an integration on this cluster. - CredentialName string `json:"credentialName,omitempty"` - - // Secrets are for sensitive configurations. The values are write-only and will be masked when read. - Secrets map[string]string `json:"secrets,omitempty"` - - // Version of the integration which is input for upgrade or rollback operation. - Version string `json:"version,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationSpec) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationSpec) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationSpec - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/status.go b/internal/models/cluster/integration/status.go deleted file mode 100644 index 4ee61afaa..000000000 --- a/internal/models/cluster/integration/status.go +++ /dev/null @@ -1,63 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/nodepool" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationStatus Status of the integration configuration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Status -type VmwareTanzuManageV1alpha1ClusterIntegrationStatus struct { - // Deep link to integration service that shows details for this cluster. - ClusterViewURL string `json:"clusterViewUrl,omitempty"` - - // Conditions that help identify the phase. - Conditions map[string]nodepool.VmwareTanzuCoreV1alpha1StatusCondition `json:"conditions,omitempty"` - - // Integration Workload backed indicator abstracts workload in Status. This indicator indicates the state of - // the workload deployed by the Integration Partner team. In case of issues with this indicator, Integration Partner - // team should be able to help resolve the issues related to this indicator. - IntegrationWorkload *VmwareTanzuManageV1alpha1ClusterIntegrationIndicator `json:"integrationWorkload,omitempty"` - - // Status of the Integration Partner's Operator deployed by TMC. - Operator *VmwareTanzuManageV1alpha1ClusterIntegrationOperator `json:"operator,omitempty"` - - // Phase of the integration. - Phase *VmwareTanzuManageV1alpha1ClusterIntegrationPhase `json:"phase,omitempty"` - - // System indicator abstracts Phase and Operator in Status. - TmcAdapter *VmwareTanzuManageV1alpha1ClusterIntegrationIndicator `json:"tmcAdapter,omitempty"` - - // Existing version of the integration. - Version string `json:"version,omitempty"` - - // Status of the Integration Partner's workloads. - Workload *VmwareTanzuManageV1alpha1ClusterIntegrationWorkload `json:"workload,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationStatus) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationStatus) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationStatus - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/update_integration_response.go b/internal/models/cluster/integration/update_integration_response.go deleted file mode 100644 index 7b19f2383..000000000 --- a/internal/models/cluster/integration/update_integration_response.go +++ /dev/null @@ -1,38 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationUpdateIntegrationResponse Response from updating an Integration. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.UpdateIntegrationResponse -type VmwareTanzuManageV1alpha1ClusterIntegrationUpdateIntegrationResponse struct { - // Integration updated. - Integration *VmwareTanzuManageV1alpha1ClusterIntegrationIntegration `json:"integration,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationUpdateIntegrationResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationUpdateIntegrationResponse) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationUpdateIntegrationResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/cluster/integration/workload.go b/internal/models/cluster/integration/workload.go deleted file mode 100644 index 6eabff4fd..000000000 --- a/internal/models/cluster/integration/workload.go +++ /dev/null @@ -1,43 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/go-openapi/swag" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/nodepool" -) - -// VmwareTanzuManageV1alpha1ClusterIntegrationWorkload Status of the Integration Partner's workloads. -// -// swagger:model vmware.tanzu.manage.v1alpha1.cluster.integration.Workload -type VmwareTanzuManageV1alpha1ClusterIntegrationWorkload struct { - // Conditions of the workloads that supports readiness and health. - Conditions map[string]nodepool.VmwareTanzuCoreV1alpha1StatusCondition `json:"conditions,omitempty"` - - // Version of the application. - Version string `json:"version,omitempty"` -} - -// MarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationWorkload) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation. -func (m *VmwareTanzuManageV1alpha1ClusterIntegrationWorkload) UnmarshalBinary(b []byte) error { - var res VmwareTanzuManageV1alpha1ClusterIntegrationWorkload - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - - *m = res - - return nil -} diff --git a/internal/models/organization/integration/phase.go b/internal/models/organization/integration/phase.go deleted file mode 100644 index ac721d045..000000000 --- a/internal/models/organization/integration/phase.go +++ /dev/null @@ -1,79 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "encoding/json" -) - -// VmwareTanzuManageV1alpha1OrganizationIntegrationPhase Integration Lifecycle Phase. -// -// - UNSPECIFIED: Unspecified phase. -// - ENABLING: Enabling phase when process for enabling integration for an organization is started. -// - REGISTERED: Registered phase when communication between inter product services is completed successfully for enabling integration. -// - ENABLED: Enabled phase when integration is enabled for an organization. -// - INITIATION_ERROR: Initiation Error phase when there is any issue during enablement of the integration. -// - DISABLING: Disabling phase when process for removing integration from organization is started. -// - UNREGISTERED: Unregistered phase when communication between inter product services is completed successfully -// -// for disabling integration. -// - TERMINATION_ERROR: Termination Error phase when there is any issue during disablement of the integration. -// - DISABLED: Disabled phase when integration is disabled from org / yet to be enabled. -// -// swagger:model vmware.tanzu.manage.v1alpha1.organization.integration.Phase -type VmwareTanzuManageV1alpha1OrganizationIntegrationPhase string - -func NewVmwareTanzuManageV1alpha1OrganizationIntegrationPhase(value VmwareTanzuManageV1alpha1OrganizationIntegrationPhase) *VmwareTanzuManageV1alpha1OrganizationIntegrationPhase { - return &value -} - -// Pointer returns a pointer to a freshly-allocated VmwareTanzuManageV1alpha1OrganizationIntegrationPhase. -func (m VmwareTanzuManageV1alpha1OrganizationIntegrationPhase) Pointer() *VmwareTanzuManageV1alpha1OrganizationIntegrationPhase { - return &m -} - -const ( - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseUNSPECIFIED captures enum value "UNSPECIFIED". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseUNSPECIFIED VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "UNSPECIFIED" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseENABLING captures enum value "ENABLING". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseENABLING VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "ENABLING" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseREGISTERED captures enum value "REGISTERED". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseREGISTERED VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "REGISTERED" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseENABLED captures enum value "ENABLED". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseENABLED VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "ENABLED" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseINITIATIONERROR captures enum value "INITIATION_ERROR". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseINITIATIONERROR VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "INITIATION_ERROR" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseDISABLING captures enum value "DISABLING". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseDISABLING VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "DISABLING" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseUNREGISTERED captures enum value "UNREGISTERED". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseUNREGISTERED VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "UNREGISTERED" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseTERMINATIONERROR captures enum value "TERMINATION_ERROR". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseTERMINATIONERROR VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "TERMINATION_ERROR" - - // VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseDISABLED captures enum value "DISABLED". - VmwareTanzuManageV1alpha1OrganizationIntegrationPhaseDISABLED VmwareTanzuManageV1alpha1OrganizationIntegrationPhase = "DISABLED" -) - -// for schema. -var vmwareTanzuManageV1alpha1OrganizationIntegrationPhaseEnum []interface{} - -func init() { - var res []VmwareTanzuManageV1alpha1OrganizationIntegrationPhase - if err := json.Unmarshal([]byte(`["UNSPECIFIED","ENABLING","REGISTERED","ENABLED","INITIATION_ERROR","DISABLING","UNREGISTERED","TERMINATION_ERROR","DISABLED"]`), &res); err != nil { - panic(err) - } - - for _, v := range res { - vmwareTanzuManageV1alpha1OrganizationIntegrationPhaseEnum = append(vmwareTanzuManageV1alpha1OrganizationIntegrationPhaseEnum, v) - } -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e259fd85f..a4c9f4353 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -11,7 +11,6 @@ import ( "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/akscluster" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/backupschedule" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/cluster" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/cluster/integration" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/cluster/nodepools" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/clusterclass" "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/clustergroup" @@ -74,7 +73,6 @@ func Provider() *schema.Provider { quotapolicy.ResourceName: quotapolicyresource.ResourceQuotaPolicy(), networkpolicy.ResourceName: networkpolicyresource.ResourceNetworkPolicy(), credential.ResourceName: credential.ResourceCredential(), - integration.ResourceName: integration.ResourceIntegration(), gitrepository.ResourceName: gitrepository.ResourceGitRepository(), kustomization.ResourceName: kustomization.ResourceKustomization(), sourcesecret.ResourceName: sourcesecret.ResourceSourceSecret(), @@ -103,7 +101,6 @@ func Provider() *schema.Provider { clustergroup.ResourceName: clustergroup.DataSourceClusterGroup(), nodepools.ResourceName: nodepools.DataSourceClusterNodePool(), credential.ResourceName: credential.DataSourceCredential(), - integration.ResourceName: integration.DataSourceIntegration(), gitrepository.ResourceName: gitrepository.DataSourceGitRepository(), sourcesecret.ResourceName: sourcesecret.DataSourceSourcesecret(), packagerepository.ResourceName: packagerepository.DataSourcePackageRepository(), diff --git a/internal/resources/cluster/integration/constant.go b/internal/resources/cluster/integration/constant.go deleted file mode 100644 index 6f0f01182..000000000 --- a/internal/resources/cluster/integration/constant.go +++ /dev/null @@ -1,20 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -const ( - ResourceName = "tanzu-mission-control_integration" - - attachedValue = "attached" - clusterNameKey = "cluster_name" - configurationKey = "configurations" - integrationNameKey = "integration_name" - managementClusterNameKey = "management_cluster_name" - provisionerNameKey = "provisioner_name" - specKey = "spec" - statusKey = "status" - tanzuObservabilitySaaSValue = "tanzu-observability-saas" - tanzuServiceMeshValue = "tanzu-service-mesh" -) diff --git a/internal/resources/cluster/integration/data_source_integration.go b/internal/resources/cluster/integration/data_source_integration.go deleted file mode 100644 index 2aff5520d..000000000 --- a/internal/resources/cluster/integration/data_source_integration.go +++ /dev/null @@ -1,98 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pkg/errors" - - clienterrors "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/errors" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/common" -) - -func DataSourceIntegration() *schema.Resource { - ri := &resourceIntegration{} - - return &schema.Resource{ - ReadContext: ri.read, - Schema: integrationSchema, - } -} - -func (r *resourceIntegration) read(_ context.Context, d *schema.ResourceData, m interface{}) (diags diag.Diagnostics) { - fn := constructFullName(d) - - resp, err := r.client(m).ManageV1alpha1ClusterIntegrationResourceServiceRead(fn) - if err != nil { - if clienterrors.IsNotFoundError(err) { - d.SetId("") - return - } - - return diag.FromErr(errors.Wrapf(err, "Unable to get Tanzu Mission Control integration entry, name: %s", fn.Name)) - } - - if resp == nil || resp.Integration == nil { - return diag.Errorf("invalid nil value reading resource %v", fn) - } - - // Meta - meta := resp.Integration.Meta - if meta == nil { - return diag.Errorf("invalid nil meta value %v", fn) - } - - d.SetId(meta.UID) - - if err = d.Set(common.MetaKey, common.FlattenMeta(meta)); err != nil { - return diag.FromErr(err) - } - - // FullName - fn = resp.Integration.FullName - - if fn == nil { - return diag.Errorf("invalid nil full name reading resource %v", fn) - } - - switch fn.Name { - case tanzuServiceMeshValue: - case tanzuObservabilitySaaSValue: - default: - return diag.Errorf("Integration Name must be one of %v", validIntegrationNames) - } - - if err = d.Set(managementClusterNameKey, fn.ManagementClusterName); err != nil { - return diag.FromErr(err) - } - - if err = d.Set(provisionerNameKey, fn.ProvisionerName); err != nil { - return diag.FromErr(err) - } - - if err = d.Set(clusterNameKey, fn.ClusterName); err != nil { - return diag.FromErr(err) - } - - // Spec - spec := resp.Integration.Spec - if spec == nil { - return diag.Errorf("invalid nil spec reading resource %v", fn) - } - - if err = d.Set(specKey, flattenSpec(spec)); err != nil { - return diag.FromErr(err) - } - - // Status - if err = d.Set(statusKey, flattenStatus(resp.Integration.Status)); err != nil { - return diag.FromErr(err) - } - - return diags -} diff --git a/internal/resources/cluster/integration/data_source_integration_test.go b/internal/resources/cluster/integration/data_source_integration_test.go deleted file mode 100644 index dbf7765bd..000000000 --- a/internal/resources/cluster/integration/data_source_integration_test.go +++ /dev/null @@ -1,33 +0,0 @@ -//go:build integration -// +build integration - -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - - testhelper "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/testing" -) - -func TestAcceptanceForIntegrationDataSource(t *testing.T) { - provider := initTestProvider(t) - - resource.Test(t, resource.TestCase{ - PreCheck: testhelper.TestPreCheck(t), - ProviderFactories: testhelper.GetTestProviderFactories(provider), - CheckDestroy: nil, - Steps: []resource.TestStep{ - { - Config: "", - Check: resource.ComposeTestCheckFunc(), - }, - }, - }) - t.Log("integration data source acceptance test complete!") -} diff --git a/internal/resources/cluster/integration/default_integration_client.go b/internal/resources/cluster/integration/default_integration_client.go deleted file mode 100644 index 17e82d545..000000000 --- a/internal/resources/cluster/integration/default_integration_client.go +++ /dev/null @@ -1,27 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "github.com/pkg/errors" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" -) - -var ErrMissingIntegrationClientService = errors.New("missing integration client service") - -type defaultClient struct{} - -func (d defaultClient) ManageV1alpha1ClusterIntegrationResourceServiceCreate(*integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse, error) { - panic(ErrMissingIntegrationClientService) -} - -func (d defaultClient) ManageV1alpha1ClusterIntegrationResourceServiceRead(*integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse, error) { - panic(ErrMissingIntegrationClientService) -} - -func (d defaultClient) ManageV1alpha1ClusterIntegrationResourceServiceDelete(*integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) error { - panic(ErrMissingIntegrationClientService) -} diff --git a/internal/resources/cluster/integration/resource_integration.go b/internal/resources/cluster/integration/resource_integration.go deleted file mode 100644 index 84f5f9b6f..000000000 --- a/internal/resources/cluster/integration/resource_integration.go +++ /dev/null @@ -1,112 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "context" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/pkg/errors" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/authctx" - clienterrors "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/errors" - integrationclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/integration" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/common" -) - -func ResourceIntegration(alternateClients ...integrationclient.ClientService) *schema.Resource { - ri := &resourceIntegration{alternateClients: append(alternateClients, &defaultClient{})} - - return &schema.Resource{ - CreateContext: ri.create, - ReadContext: ri.read, - UpdateContext: ri.update, - DeleteContext: ri.integrationDelete, - Schema: integrationSchema, - } -} - -type resourceIntegration struct { - alternateClients []integrationclient.ClientService -} - -func (r *resourceIntegration) create(ctx context.Context, d *schema.ResourceData, m interface{}) (diags diag.Diagnostics) { - fn := constructFullName(d) - - req := &integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest{ - Integration: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration{ - FullName: fn, - Meta: common.ConstructMeta(d), - Spec: constructSpec(d), - }, - } - - resp, err := r.client(m).ManageV1alpha1ClusterIntegrationResourceServiceCreate(req) - if err != nil { - return diag.FromErr(errors.Wrapf(err, "Unable to create Tanzu Mission Control cluster integration entry, name : %s", fn.Name)) - } - - if resp == nil || resp.Integration == nil { - return diag.Errorf("invalid nil-response creating resource %v", fn) - } - - d.SetId(resp.Integration.Meta.UID) - - return append(diags, r.read(ctx, d, m)...) -} - -func (r *resourceIntegration) update(context.Context, *schema.ResourceData, interface{}) (diags diag.Diagnostics) { - return diag.FromErr(errors.New("update of Tanzu Mission Control integration is not supported")) -} - -func (r *resourceIntegration) integrationDelete(_ context.Context, d *schema.ResourceData, m interface{}) (diags diag.Diagnostics) { - fn := constructFullName(d) - - err := r.client(m).ManageV1alpha1ClusterIntegrationResourceServiceDelete(fn) - if err != nil && !clienterrors.IsNotFoundError(err) { - return diag.FromErr(errors.Wrapf(err, "Unable to delete Tanzu Mission Control integration entry, name: %s", fn.Name)) - } - - // d.SetId("") is automatically called assuming delete returns no errors, but - // it is added here for explicitness. - d.SetId("") - - getIntegrationResourceRetryable := func() (retry bool, err error) { - if _, err = r.client(m).ManageV1alpha1ClusterIntegrationResourceServiceRead(fn); err == nil { - return true, errors.New("integration deletion in progress") - } - - if !clienterrors.IsNotFoundError(err) { - return true, err - } - - return false, nil - } - - if _, err = helper.Retry(getIntegrationResourceRetryable, 10*time.Second, 18); err != nil { - diag.FromErr(errors.Wrapf(err, "verify %s cluster integration resource clean up", fn.Name)) - } - - return diags -} - -func (r *resourceIntegration) client(m interface{}) integrationclient.ClientService { - switch c := m.(type) { - case authctx.TanzuContext: - return c.TMCConnection.IntegrationResourceService - case integrationclient.ClientService: - return c - default: - if len(r.alternateClients) == 0 { - return nil - } - - return r.alternateClients[0] - } -} diff --git a/internal/resources/cluster/integration/resource_integration_helper.go b/internal/resources/cluster/integration/resource_integration_helper.go deleted file mode 100644 index 6d56b93cd..000000000 --- a/internal/resources/cluster/integration/resource_integration_helper.go +++ /dev/null @@ -1,83 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "encoding/json" - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" -) - -func constructFullName(d *schema.ResourceData) (fn *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) { - fn = &integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName{} - - fn.ManagementClusterName, _ = d.Get(managementClusterNameKey).(string) - fn.ProvisionerName, _ = d.Get(provisionerNameKey).(string) - fn.ClusterName, _ = d.Get(clusterNameKey).(string) - fn.Name, _ = d.Get(integrationNameKey).(string) - - return fn -} - -func constructSpec(d *schema.ResourceData) (spec *integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec) { // nolint:unused - spec = &integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec{ - Configurations: map[string]interface{}{}, - } - - configs, ok := d.Get(specKey).([]interface{}) - if !ok || len(configs) < 1 { - return spec - } - - item, ok := configs[0].(map[string]interface{}) - if !ok { - return spec - } - - v, ok := item[configurationKey].(string) - if !ok { - return spec - } - - var m map[string]interface{} - if err := json.Unmarshal([]byte(v), &m); err == nil { - spec.Configurations = m - } - - return spec -} - -func flattenSpec(spec *integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec) interface{} { - flattened := map[string]interface{}{} - - if spec != nil && spec.Configurations != nil { - flattened[configurationKey] = toJSON(spec.Configurations) - } - - return []map[string]interface{}{flattened} -} - -func flattenStatus(status *integration.VmwareTanzuManageV1alpha1ClusterIntegrationStatus) interface{} { - return map[string]interface{}{ - "cluster_view_url": status.ClusterViewURL, - "phase": status.Phase, - "tmcAdapter": status.TmcAdapter, - "conditions": toJSON(status.Conditions), - "operator": toJSON(status.Operator), - "workload": toJSON(status.Workload), - } -} - -func toJSON(data any) string { - v, err := json.Marshal(data) - if err != nil { - return fmt.Sprintf(`{"error": %q}`, err) - } - - return string(v) -} diff --git a/internal/resources/cluster/integration/resource_integration_helper_test.go b/internal/resources/cluster/integration/resource_integration_helper_test.go deleted file mode 100644 index 09c6daecd..000000000 --- a/internal/resources/cluster/integration/resource_integration_helper_test.go +++ /dev/null @@ -1,215 +0,0 @@ -//go:build integration -// +build integration - -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "context" - "encoding/base64" - "fmt" - "strings" - "testing" - "text/template" - - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/stretchr/testify/require" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/authctx" - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" - objectmetamodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/objectmeta" -) - -func TestGenerate(t *testing.T) { - for expect, given := range map[string]*integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration{ - "Cg==": nil, - "cmVzb3VyY2UgInRhbnp1LW1pc3Npb24tY29udHJvbF9pbnRlZ3JhdGlvbiIgImRlZmF1bHQiIHsKfQo=": { - FullName: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName{}, - }, - "cmVzb3VyY2UgInRhbnp1LW1pc3Npb24tY29udHJvbF9pbnRlZ3JhdGlvbiIgImRlZmF1bHQiIHsKICBpbnRlZ3JhdGlvbl9uYW1lICAgICAgICA9ICJ0YW56dS1zZXJ2aWNlLW1lc2giCiAgY2x1c3Rlcl9uYW1lICAgICAgICAgICAgPSAidGVzdC1jbHVzdGVyLW5hbWUiCiAgcHJvdmlzaW9uZXJfbmFtZSAgICAgICAgPSAiYXR0YWNoZWQiCiAgbWFuYWdlbWVudF9jbHVzdGVyX25hbWUgPSAiYXR0YWNoZWQiCiAgbWV0YSB7CiAgICBkZXNjcmlwdGlvbiA9ICJtZXRhLCBtZXRhLCBtZXRhLCBtb2RlbCIKICAgIGxhYmVscyA9IHsKICAgICAgImtleSI6ICJ2YWx1ZSIKICAgIH0KICB9CiAgc3BlYyB7IAogICAgY29uZmlndXJhdGlvbnMgPSAie1wiZW5hYmxlTmFtZXNwYWNlRXhjbHVzaW9uc1wiOnRydWUsXCJuYW1lc3BhY2VFeGNsdXNpb25zXCI6W119IgogIH0KfQo=": { - FullName: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName{ - ClusterName: "test-cluster-name", - ManagementClusterName: "attached", - Name: "tanzu-service-mesh", - ProvisionerName: "attached", - }, - Meta: &objectmetamodel.VmwareTanzuCoreV1alpha1ObjectMeta{ - Description: "meta, meta, meta, model", - Labels: map[string]string{"key": "value"}, - }, - Spec: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec{ - Configurations: map[string]interface{}{ - enableNamespaceExclusionsSpecKey: true, - namespaceExclusionsSpecKey: []map[string]interface{}{}, - }, - }, - }, - } { - expectStr := decode(expect) - - got, err := generateResourceManifest(given) - if err != nil { - t.Fatalf("got error: %v\nexpected %q", err, expectStr) - } - - encodedGot := encode(got) - - if encodedGot != expect { - t.Errorf("expected: %q\n%s\ngot: %q\n%s", expect, expectStr, encodedGot, got) - } - - t.Logf("got:\n%s", got) - } -} - -func generateResourceManifest(model *integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration) (string, error) { - var dst strings.Builder - - tmpl := template.Must(template.New("manifest"). - Funcs(map[string]any{ - "toJSON": toJSON, - }). - Parse(integrationResourceManifestTemplate), - ) - - if err := tmpl.Execute(&dst, model); err != nil { - return "", err - } - - return dst.String(), nil -} - -func generateID(name *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) string { - if name == nil { - return "" - } - - return fmt.Sprintf( - "ID:%s:%s:%s:%s:%s", - name.ManagementClusterName, - name.ProvisionerName, - name.ClusterName, - name.Name, - name.OrgID) -} - -func initTestProvider(t *testing.T) *schema.Provider { - provider := &schema.Provider{ - Schema: authctx.ProviderAuthSchema(), - DataSourcesMap: map[string]*schema.Resource{ - ResourceName: DataSourceIntegration(), - }, - ConfigureContextFunc: authctx.ProviderConfigureContext, - } - - if err := provider.InternalValidate(); err != nil { - require.NoError(t, err) - } - - return provider -} - -func configureTestProvider(client *testClient) func(context.Context, *schema.ResourceData) (interface{}, diag.Diagnostics) { - return func(ctx context.Context, data *schema.ResourceData) (interface{}, diag.Diagnostics) { - var diags diag.Diagnostics - - return client, diags - } -} - -func newTestClient() *testClient { - return &testClient{ - resources: map[string]*integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration{}, - } -} - -type testClient struct { - resources map[string]*integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration -} - -func (t *testClient) ManageV1alpha1ClusterIntegrationResourceServiceCreate(request *integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationRequest) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse, error) { - id := generateID(request.Integration.FullName) - if _, ok := t.resources[id]; ok { - return nil, fmt.Errorf("conflict, %q already created", id) - } - - resource := &integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration{ - FullName: request.Integration.FullName, - Meta: &objectmetamodel.VmwareTanzuCoreV1alpha1ObjectMeta{UID: id}, - Spec: request.Integration.Spec, - Status: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationStatus{ - ClusterViewURL: "", - Version: "", - }, - } - - t.resources[id] = resource - - return &integration.VmwareTanzuManageV1alpha1ClusterIntegrationCreateIntegrationResponse{Integration: resource}, nil -} - -func (t *testClient) ManageV1alpha1ClusterIntegrationResourceServiceRead(name *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) (*integration.VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse, error) { - id := generateID(name) - - r, ok := t.resources[id] - if !ok { - return nil, fmt.Errorf("%q not found (have: %+v)", id, t.resources) - } - - return &integration.VmwareTanzuManageV1alpha1ClusterIntegrationGetIntegrationResponse{Integration: r}, nil -} - -func (t *testClient) ManageV1alpha1ClusterIntegrationResourceServiceDelete(name *integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName) error { - id := generateID(name) - if _, ok := t.resources[id]; !ok { - return fmt.Errorf("cannot delete %q: not found", id) - } - - delete(t.resources, id) - - return nil -} - -func must(s string, err error) string { - if err != nil { - return err.Error() - } - - return s -} - -func encode(in string) string { return base64.StdEncoding.EncodeToString([]byte(in)) } - -func decode(in string) string { - v, err := base64.StdEncoding.DecodeString(in) - if err != nil { - return fmt.Sprintf("ERROR: %v", err) - } - - return string(v) -} - -const ( - integrationResourceManifestTemplate = `{{ with . }}{{ $fn := .FullName -}} -resource "tanzu-mission-control_integration" "default" { - {{- with $fn }}{{ with .Name }} - integration_name = "{{ . }}"{{ end }}{{ with .ClusterName }} - cluster_name = "{{ . }}"{{ end }}{{ with .ProvisionerName }} - provisioner_name = "{{ . }}"{{ end }}{{ with .ManagementClusterName }} - management_cluster_name = "{{ . }}"{{ end }}{{ end }}{{ with .Meta }} - meta { {{- with .Description }} - description = "{{ . }}"{{ end }}{{ with .Labels }} - labels = { {{- range $k, $v := . }} - "{{ $k }}": "{{ $v }}"{{ end }} - } {{- end }} - } {{- end }}{{ with .Spec }} - spec { {{ with .Configurations }} - configurations = {{ toJSON . | printf "%q" }}{{ end }} - } {{- end }} -} {{- end }} -` -) diff --git a/internal/resources/cluster/integration/resource_integration_spec.go b/internal/resources/cluster/integration/resource_integration_spec.go deleted file mode 100644 index b64f178a1..000000000 --- a/internal/resources/cluster/integration/resource_integration_spec.go +++ /dev/null @@ -1,130 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "encoding/json" - "fmt" - - "github.com/hashicorp/go-cty/cty" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/common" -) - -var ( - integrationSchema = map[string]*schema.Schema{ - managementClusterNameKey: { - Type: schema.TypeString, - Description: "Name of the management cluster", - Default: attachedValue, - Optional: true, - ForceNew: true, - }, - - provisionerNameKey: { - Type: schema.TypeString, - Description: "Provisioner of the cluster", - Default: attachedValue, - Optional: true, - ForceNew: true, - }, - - clusterNameKey: { - Type: schema.TypeString, - Description: "Name of this cluster", - Required: true, - ForceNew: true, - }, - - integrationNameKey: { - Type: schema.TypeString, - Description: "Name of the Integration; valid options are currently only ['tanzu-service-mesh']", - Required: true, - ForceNew: true, - ValidateDiagFunc: validateIntegrationName, - }, - - common.MetaKey: common.Meta, - - specKey: { - Type: schema.TypeList, - Description: "Specification for the Integration", - Required: true, - ForceNew: true, - MinItems: 1, - MaxItems: 1, - Elem: specResource, - }, - - statusKey: { - Type: schema.TypeMap, - Description: "Status of Integration", - Computed: true, - Elem: computedString, - }, - } - - specResource = &schema.Resource{ - Schema: map[string]*schema.Schema{ - configurationKey: { - Type: schema.TypeString, - Description: "Integration specific configurations in JSON format", - Optional: true, - ForceNew: true, - ValidateDiagFunc: validateConfiguration, - }, - }, - } - - computedString = &schema.Schema{ - Type: schema.TypeString, - Computed: true, - } - // validIntegrationNames are ones allowed by the API. - // | value must be in list [tanzu-observability-saas tanzu-service-mesh]. - validIntegrationNames = []string{ - tanzuObservabilitySaaSValue, - tanzuServiceMeshValue, - } -) - -func validateIntegrationName(i interface{}, p cty.Path) diag.Diagnostics { - var ( - ok bool - v string - ) - - if v, ok = i.(string); !ok { - return diag.Errorf("unexpected type for integration_name: %T (%v)", i, p) - } - - for _, name := range validIntegrationNames { - if name == v { - return nil - } - } - - return diag.Errorf("integration_name must be one of: %v", validIntegrationNames) -} - -func validateConfiguration(i interface{}, p cty.Path) diag.Diagnostics { - var ( - ok bool - v string - m map[string]interface{} - ) - - if v, ok = i.(string); !ok { - return diag.Errorf("unexpected type for configuration: %T (%v)", i, p) - } - - if err := json.Unmarshal([]byte(v), &m); err != nil { - return diag.FromErr(fmt.Errorf("%w: %s", err, v)) - } - - return nil -} diff --git a/internal/resources/cluster/integration/resource_integration_spec_test.go b/internal/resources/cluster/integration/resource_integration_spec_test.go deleted file mode 100644 index a2d6ff3b4..000000000 --- a/internal/resources/cluster/integration/resource_integration_spec_test.go +++ /dev/null @@ -1,64 +0,0 @@ -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "testing" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" -) - -const ( - enableNamespaceExclusionsSpecKey = "enableNamespaceExclusions" - namespaceExclusionsSpecKey = "namespaceExclusions" -) - -func TestFlattenSpec(t *testing.T) { - type testCase struct { - given *integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec - expect string - } - - for tcName, tc := range map[string]testCase{ - "simple": { - given: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec{ - Configurations: map[string]interface{}{}, - }, - expect: `{}`, - }, - "full": { - given: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec{ - Configurations: map[string]interface{}{ - enableNamespaceExclusionsSpecKey: true, - namespaceExclusionsSpecKey: []map[string]interface{}{ - { - "match": "namespace-1", - "type": "EXACT", - }, - { - "match": "kube", - "type": "START_WITH", - }, - }, - }, - }, - expect: `{"enableNamespaceExclusions":true,"namespaceExclusions":[{"match":"namespace-1","type":"EXACT"},{"match":"kube","type":"START_WITH"}]}`, - }, - } { - got, ok := flattenSpec(tc.given).([]map[string]interface{}) - if !ok { - t.Errorf("%s: unexpected type for flattened spec: %T", tcName, got) - } - - conf, ok := got[0][configurationKey].(string) - if !ok { - t.Errorf("%s: missing key %q", tcName, configurationKey) - } - - if conf != tc.expect { - t.Errorf("%s: wrong configuration, got %s, expected %s", tcName, conf, tc.expect) - } - } -} diff --git a/internal/resources/cluster/integration/resource_integration_test.go b/internal/resources/cluster/integration/resource_integration_test.go deleted file mode 100644 index 9518136e0..000000000 --- a/internal/resources/cluster/integration/resource_integration_test.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build integration -// +build integration - -// © Broadcom. All Rights Reserved. -// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. -// SPDX-License-Identifier: MPL-2.0 - -package integration - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/integration" - testhelper "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/testing" -) - -var ( - client = newTestClient() - - testProvider = &schema.Provider{ - ResourcesMap: map[string]*schema.Resource{ - ResourceName: ResourceIntegration(), - }, - ConfigureContextFunc: configureTestProvider(client), - } - - validMinimalModel = &integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration{ - FullName: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName{ - Name: "tanzu-service-mesh", - ClusterName: "test-cluster", - ManagementClusterName: "attached", - ProvisionerName: "attached", - }, - Spec: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec{}, - } - - validFullModel = &integration.VmwareTanzuManageV1alpha1ClusterIntegrationIntegration{ - FullName: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationFullName{ - Name: "tanzu-service-mesh", - ClusterName: "test-cluster-2", - ManagementClusterName: "attached-2", - ProvisionerName: "attached-2", - }, - Spec: &integration.VmwareTanzuManageV1alpha1ClusterIntegrationSpec{ - Configurations: map[string]interface{}{ - enableNamespaceExclusionsSpecKey: true, - namespaceExclusionsSpecKey: []map[string]interface{}{}, - }, - }, - } -) - -func TestResourceIntegration(t *testing.T) { - resource.Test(t, resource.TestCase{ - IsUnitTest: false, - ProviderFactories: testhelper.GetTestProviderFactories(testProvider), - Steps: []resource.TestStep{ - { - Config: must(generateResourceManifest(nil)), - }, - { - Config: must(generateResourceManifest(validMinimalModel)), - ExpectNonEmptyPlan: true, - }, - { - Config: must(generateResourceManifest(validFullModel)), - ExpectNonEmptyPlan: true, - }, - }, - }) -} diff --git a/resource_templates/tsm-integration.tf b/resource_templates/tsm-integration.tf deleted file mode 100644 index ff205d51c..000000000 --- a/resource_templates/tsm-integration.tf +++ /dev/null @@ -1,33 +0,0 @@ -// Tanzu Mission Control TSM Integration -// Operations supported : Create, Read and Delete - -// Create Tanzu Mission Control TSM Integration resource -resource "tanzu-mission-control_integration" "create_tsm-integration" { - management_cluster_name = "" // Default: attached - provisioner_name = "" // Default: attached - cluster_name = "" // Required - integration_name = "" - - spec { - configurations = jsonencode({ - enableNamespaceExclusions = false // Default: false - namespaceExclusions = [ - { - match = "" - type = "" - }, { - match = "" - type = "" - } - ] - }) - } -} - -// Read Tanzu Mission Control TSM integration : fetch details -data "tanzu-mission-control_integration" "read_tsm-integration" { - management_cluster_name = "" // Default: attached - provisioner_name = "" // Default: attached - cluster_name = "" // Required - integration_name = "" -} diff --git a/templates/data-sources/integration.md.tmpl b/templates/data-sources/integration.md.tmpl deleted file mode 100644 index 1d79884ab..000000000 --- a/templates/data-sources/integration.md.tmpl +++ /dev/null @@ -1,20 +0,0 @@ ---- -Title: "Tanzu Service Mesh Integration Resource" -Description: |- - Fetching the details of Integration by Tanzu Service Mesh. ---- - -# Tanzu Service Mesh Integration - -The `Tanzu Service Mesh integration` is available on the Tanzu Mission Control platform. -When the Tanzu Service Mesh service has been enabled on your organization, your Tanzu Mission Control organization administrator can enable the integration for use on clusters that are managed through Tanzu Mission Control. -Then, cluster administrators can add Tanzu Service Mesh to managed clusters and designate which namespaces should belong in the mesh. -`Tanzu Mission Control` takes care of the installation of service mesh components in the cluster, provides health status, and onboards it into Tanzu Service Mesh. - -For reading the Tanzu Service Mesh Integration via the terraform provider, use the following configuration. - -## Example Usage - -{{ tffile "examples/data-sources/integration/data-source.tf" }} - -{{ .SchemaMarkdown | trimspace }} diff --git a/templates/resources/integration.md.tmpl b/templates/resources/integration.md.tmpl deleted file mode 100644 index 174971469..000000000 --- a/templates/resources/integration.md.tmpl +++ /dev/null @@ -1,20 +0,0 @@ ---- -Title: "Tanzu Service Mesh Integration Resource" -Description: |- - Creating the Integration by Tanzu Service Mesh on a cluster. ---- - -# Tanzu Service Mesh Integration - -The `Tanzu Service Mesh integration` is available on the Tanzu Mission Control platform. -When the Tanzu Service Mesh service has been enabled on your organization, your Tanzu Mission Control organization administrator can enable the integration for use on clusters that are managed through Tanzu Mission Control. -Then, cluster administrators can add Tanzu Service Mesh to managed clusters and designate which namespaces should belong in the mesh. -`Tanzu Mission Control` takes care of the installation of service mesh components in the cluster, provides health status, and onboards it into Tanzu Service Mesh. - -For leveraging this feature via the terraform provider, use the following configuration. - -## Example Usage - -{{ tffile "examples/resources/integration/resource.tf" }} - -{{ .SchemaMarkdown | trimspace }}