Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-domain-name-to-data-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthirtyam authored Aug 22, 2024
2 parents ba9e5d5 + bf1b271 commit 164d668
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 35 deletions.
3 changes: 1 addition & 2 deletions internal/provider/data_source_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions internal/provider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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.",
},
},
}
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_ceip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ":")
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_certificate_authority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions internal/provider/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_external_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ":")
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/resource_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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{}
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/resource_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 164d668

Please sign in to comment.