From b1f1b5dedd27a938267a1bd529d4eda18fe12175 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 22 Aug 2024 03:59:13 -0400 Subject: [PATCH 1/2] chore: update provider param descriptions (#233) --- internal/provider/framework_provider.go | 14 +++++++------- internal/provider/provider.go | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/provider/framework_provider.go b/internal/provider/framework_provider.go index 067a3e4..a96800e 100644 --- a/internal/provider/framework_provider.go +++ b/internal/provider/framework_provider.go @@ -52,7 +52,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov Attributes: map[string]schema.Attribute{ "sddc_manager_username": schema.StringAttribute{ Optional: true, - Description: "Username to authenticate to SDDC Manager", + Description: "The username to authenticate to the SDDC Manager instance.", Validators: []validator.String{ getSddcManagerConflictsValidator(), stringvalidator.AlsoRequires( @@ -64,7 +64,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov }, "sddc_manager_password": schema.StringAttribute{ Optional: true, - Description: "Password to authenticate to SDDC Manager", + Description: "The password to authenticate to the SDDC Manager instance.", Validators: []validator.String{ getSddcManagerConflictsValidator(), stringvalidator.AlsoRequires( @@ -76,7 +76,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov }, "sddc_manager_host": schema.StringAttribute{ Optional: true, - Description: "Fully qualified domain name or IP address of the SDDC Manager", + Description: "The fully qualified domain name or IP address of the SDDC Manager instance.", Validators: []validator.String{ getSddcManagerConflictsValidator(), stringvalidator.AlsoRequires( @@ -88,7 +88,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov }, "cloud_builder_username": schema.StringAttribute{ Optional: true, - Description: "Username to authenticate to CloudBuilder", + Description: "The username to authenticate to the Cloud Builder instance.", Validators: []validator.String{ getCloudBuilderConflictsValidator(), stringvalidator.AlsoRequires( @@ -100,7 +100,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov }, "cloud_builder_password": schema.StringAttribute{ Optional: true, - Description: "Password to authenticate to CloudBuilder", + Description: "The password to authenticate to the Cloud Builder instance.", Validators: []validator.String{ getCloudBuilderConflictsValidator(), stringvalidator.AlsoRequires( @@ -112,7 +112,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov }, "cloud_builder_host": schema.StringAttribute{ Optional: true, - Description: "Fully qualified domain name or IP address of the CloudBuilder", + Description: "The fully qualified domain name or IP address of the Cloud Builder instance.", Validators: []validator.String{ getCloudBuilderConflictsValidator(), stringvalidator.AlsoRequires( @@ -124,7 +124,7 @@ func (frameworkProvider *FrameworkProvider) Schema(ctx context.Context, req prov }, "allow_unverified_tls": schema.BoolAttribute{ Optional: true, - Description: "If set, VMware VCF client will permit unverifiable TLS certificates.", + Description: "Allow unverified TLS certificates.", }, }, } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 06bdecc..9fd2f21 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -37,7 +37,7 @@ func Provider() *schema.Provider { "sddc_manager_host": { Type: schema.TypeString, Optional: true, - Description: "The fully qualified domain name or IP address of the SDDC Manager instance", + Description: "The fully qualified domain name or IP address of the SDDC Manager instance.", ConflictsWith: []string{"cloud_builder_username", "cloud_builder_password", "cloud_builder_host"}, RequiredWith: []string{"sddc_manager_username", "sddc_manager_password"}, DefaultFunc: schema.EnvDefaultFunc(constants.VcfTestUrl, nil), @@ -110,7 +110,7 @@ func providerConfigure(_ context.Context, data *schema.ResourceData) (interface{ password, isSetPassword := data.GetOk("sddc_manager_password") hostName, isSetHost := data.GetOk("sddc_manager_host") if !isVcfUsernameSet || !isSetPassword || !isSetHost { - return nil, diag.Errorf("SDDC Manager username, password, and host must be provided") + return nil, diag.Errorf("SDDC Manager username, password, and host must be provided.") } var sddcManagerClient = api_client.NewSddcManagerClient(sddcManagerUsername.(string), password.(string), hostName.(string), allowUnverifiedTLS.(bool)) @@ -124,7 +124,7 @@ func providerConfigure(_ context.Context, data *schema.ResourceData) (interface{ password, isSetPassword := data.GetOk("cloud_builder_password") hostName, isSetHost := data.GetOk("cloud_builder_host") if !isCbUsernameSet || !isSetPassword || !isSetHost { - return nil, diag.Errorf("Cloud Builder username, password, and host must be provided") + return nil, diag.Errorf("Cloud Builder username, password, and host must be provided.") } var cloudBuilderClient = api_client.NewCloudBuilderClient(cbUsername.(string), password.(string), hostName.(string), allowUnverifiedTLS.(bool)) From bf1b2717b046ab740dbfc3140a3a1dfee9422fac Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 22 Aug 2024 04:07:24 -0400 Subject: [PATCH 2/2] refactor: update apiClient (#231) --- internal/provider/data_source_cluster.go | 3 +-- internal/provider/data_source_domain.go | 3 +-- internal/provider/resource_ceip_test.go | 3 +-- internal/provider/resource_certificate.go | 3 +-- internal/provider/resource_certificate_authority_test.go | 3 +-- internal/provider/resource_cluster.go | 6 ++---- internal/provider/resource_cluster_test.go | 3 +-- internal/provider/resource_domain_test.go | 3 +-- internal/provider/resource_external_certificate.go | 3 +-- internal/provider/resource_host.go | 6 +++--- internal/provider/resource_host_test.go | 3 +-- internal/provider/resource_user_test.go | 3 +-- 12 files changed, 15 insertions(+), 27 deletions(-) diff --git a/internal/provider/data_source_cluster.go b/internal/provider/data_source_cluster.go index 855c1ff..b034ccf 100644 --- a/internal/provider/data_source_cluster.go +++ b/internal/provider/data_source_cluster.go @@ -77,8 +77,7 @@ func DataSourceCluster() *schema.Resource { } func dataSourceClusterRead(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient clusterId := data.Get("cluster_id").(string) _, err := cluster.ImportCluster(ctx, data, apiClient, clusterId) if err != nil { diff --git a/internal/provider/data_source_domain.go b/internal/provider/data_source_domain.go index ed788f6..4063725 100644 --- a/internal/provider/data_source_domain.go +++ b/internal/provider/data_source_domain.go @@ -84,8 +84,7 @@ func DataSourceDomain() *schema.Resource { } func dataSourceDomainRead(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient domainId := data.Get("domain_id").(string) _, err := domain.ImportDomain(ctx, data, apiClient, domainId, true) diff --git a/internal/provider/resource_ceip_test.go b/internal/provider/resource_ceip_test.go index cde94bb..71d3e5f 100644 --- a/internal/provider/resource_ceip_test.go +++ b/internal/provider/resource_ceip_test.go @@ -37,8 +37,7 @@ func testAccVcfCeip() string { } func testVerifyVcfCeip(enabledState string) error { - vcfClient := testAccProvider.Meta().(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := testAccProvider.Meta().(*api_client.SddcManagerClient).ApiClient ceipResult, err := apiClient.CEIP.GetCEIPStatus(nil) if err != nil { diff --git a/internal/provider/resource_certificate.go b/internal/provider/resource_certificate.go index 48a520c..647ea60 100644 --- a/internal/provider/resource_certificate.go +++ b/internal/provider/resource_certificate.go @@ -110,8 +110,7 @@ func resourceResourceCertificateCreate(ctx context.Context, data *schema.Resourc } func resourceResourceCertificateRead(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient csrID := data.Get("csr_id").(string) csrIdComponents := strings.Split(csrID, ":") diff --git a/internal/provider/resource_certificate_authority_test.go b/internal/provider/resource_certificate_authority_test.go index 2060b11..ac189e3 100644 --- a/internal/provider/resource_certificate_authority_test.go +++ b/internal/provider/resource_certificate_authority_test.go @@ -88,8 +88,7 @@ func testAccVcfCertificateAuthorityOpenSsl() string { } func testVerifyVcfCertificateAuthority(caType string) error { - vcfClient := testAccProvider.Meta().(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := testAccProvider.Meta().(*api_client.SddcManagerClient).ApiClient getCertificateAuthorityParams := &certificates.GetCertificateAuthorityByIDParams{ ID: caType, diff --git a/internal/provider/resource_cluster.go b/internal/provider/resource_cluster.go index 1b59340..f0d26c6 100644 --- a/internal/provider/resource_cluster.go +++ b/internal/provider/resource_cluster.go @@ -55,8 +55,7 @@ func ResourceCluster() *schema.Resource { DeleteContext: resourceClusterDelete, Importer: &schema.ResourceImporter{ StateContext: func(ctx context.Context, data *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient clusterId := data.Id() return cluster.ImportCluster(ctx, data, apiClient, clusterId) }, @@ -262,8 +261,7 @@ func resourceClusterCreate(ctx context.Context, data *schema.ResourceData, meta } func resourceClusterRead(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient getClusterParams := clusters.NewGetClusterParamsWithContext(ctx). WithTimeout(constants.DefaultVcfApiCallTimeout) diff --git a/internal/provider/resource_cluster_test.go b/internal/provider/resource_cluster_test.go index bf88cbc..0fc2679 100644 --- a/internal/provider/resource_cluster_test.go +++ b/internal/provider/resource_cluster_test.go @@ -526,8 +526,7 @@ func getStretchConfig() string { } func testCheckVcfClusterDestroy(state *terraform.State) error { - vcfClient := testAccProvider.Meta().(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := testAccProvider.Meta().(*api_client.SddcManagerClient).ApiClient for _, rs := range state.RootModule().Resources { if rs.Type != "vcf_cluster" { diff --git a/internal/provider/resource_domain_test.go b/internal/provider/resource_domain_test.go index 8ca3085..cc33b6c 100644 --- a/internal/provider/resource_domain_test.go +++ b/internal/provider/resource_domain_test.go @@ -496,8 +496,7 @@ func testGenerateCommissionHostConfigs(numberOfCommissionedHosts int, commission } func testCheckVcfDomainDestroy(state *terraform.State) error { - vcfClient := testAccProvider.Meta().(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := testAccProvider.Meta().(*api_client.SddcManagerClient).ApiClient for _, rs := range state.RootModule().Resources { if rs.Type != "vcf_domain" { diff --git a/internal/provider/resource_external_certificate.go b/internal/provider/resource_external_certificate.go index 788b616..88ff09f 100644 --- a/internal/provider/resource_external_certificate.go +++ b/internal/provider/resource_external_certificate.go @@ -140,8 +140,7 @@ func resourceResourceExternalCertificateCreate(ctx context.Context, data *schema } func resourceResourceExternalCertificateRead(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient csrID := data.Get("csr_id").(string) csrIdComponents := strings.Split(csrID, ":") diff --git a/internal/provider/resource_host.go b/internal/provider/resource_host.go index a9cb47d..db41713 100644 --- a/internal/provider/resource_host.go +++ b/internal/provider/resource_host.go @@ -88,6 +88,7 @@ func ResourceHost() *schema.Resource { func resourceHostCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { vcfClient := meta.(*api_client.SddcManagerClient) apiClient := vcfClient.ApiClient + params := hosts.NewCommissionHostsParamsWithTimeout(constants.DefaultVcfApiCallTimeout) commissionSpec := models.HostCommissionSpec{} @@ -158,8 +159,7 @@ func resourceHostCreate(ctx context.Context, d *schema.ResourceData, meta interf } func resourceHostRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := meta.(*api_client.SddcManagerClient).ApiClient hostId := d.Id() @@ -209,8 +209,8 @@ func resourceHostUpdate(ctx context.Context, d *schema.ResourceData, meta interf } func resourceHostDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + apiClient := meta.(*api_client.SddcManagerClient).ApiClient vcfClient := meta.(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient params := hosts.NewDecommissionHostsParamsWithTimeout(constants.DefaultVcfApiCallTimeout) decommissionSpec := models.HostDecommissionSpec{} diff --git a/internal/provider/resource_host_test.go b/internal/provider/resource_host_test.go index 8678db0..e1147ef 100644 --- a/internal/provider/resource_host_test.go +++ b/internal/provider/resource_host_test.go @@ -140,8 +140,7 @@ func testAccVcfHostConfigNetworkPoolName(hostFqdn, hostSshPassword string) strin } func testCheckVcfHostDestroy(_ *terraform.State) error { - vcfClient := testAccProvider.Meta().(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := testAccProvider.Meta().(*api_client.SddcManagerClient).ApiClient hosts, err := apiClient.Hosts.GetHosts(nil) if err != nil { diff --git a/internal/provider/resource_user_test.go b/internal/provider/resource_user_test.go index 8fa2d0b..aa1b8dc 100644 --- a/internal/provider/resource_user_test.go +++ b/internal/provider/resource_user_test.go @@ -59,8 +59,7 @@ func testAccVcfUserConfig() string { } func testCheckVcfUserDestroy(_ *terraform.State) error { - vcfClient := testAccProvider.Meta().(*api_client.SddcManagerClient) - apiClient := vcfClient.ApiClient + apiClient := testAccProvider.Meta().(*api_client.SddcManagerClient).ApiClient ok, err := apiClient.Users.GetUsers(nil) if err != nil {