From d344dfaf1cca7a500ff5e8024651b274b3f8b971 Mon Sep 17 00:00:00 2001 From: Ales Stimec Date: Tue, 17 Dec 2024 14:58:17 +0100 Subject: [PATCH] fix: fixed wording in internal/provider/resource_kubernetes_cloud.go Co-authored-by: Kian Parvin <46668016+kian99@users.noreply.github.com> --- docs/resources/kubernetes_cloud.md | 4 ++-- internal/provider/resource_kubernetes_cloud.go | 12 ++++-------- internal/provider/resource_kubernetes_cloud_test.go | 12 +++++------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docs/resources/kubernetes_cloud.md b/docs/resources/kubernetes_cloud.md index 4612851f..4d4829d1 100644 --- a/docs/resources/kubernetes_cloud.md +++ b/docs/resources/kubernetes_cloud.md @@ -37,8 +37,8 @@ resource "juju_model" "my-model" { ### Optional - `kubernetes_config` (String, Sensitive) The kubernetes config file path for the cloud. Cloud credentials will be added to the Juju controller for you. -- `parent_cloud_name` (String) The parent cloud name in case adding k8s cluster from existed cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller. -- `parent_cloud_region` (String) The parent cloud region name in case adding k8s cluster from existed cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller. +- `parent_cloud_name` (String) The parent cloud name, for adding a k8s cluster from an existing cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller. +- `parent_cloud_region` (String) The parent cloud region name, for adding a k8s cluster from an existing cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller. ### Read-Only diff --git a/internal/provider/resource_kubernetes_cloud.go b/internal/provider/resource_kubernetes_cloud.go index 1f49cb32..7de37ccb 100644 --- a/internal/provider/resource_kubernetes_cloud.go +++ b/internal/provider/resource_kubernetes_cloud.go @@ -100,11 +100,11 @@ func (r *kubernetesCloudResource) Schema(_ context.Context, req resource.SchemaR Sensitive: true, }, "parent_cloud_name": schema.StringAttribute{ - Description: "The parent cloud name in case adding k8s cluster from existed cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller.", + Description: "The parent cloud name, for adding a k8s cluster from an existing cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller.", Optional: true, }, "parent_cloud_region": schema.StringAttribute{ - Description: "The parent cloud region name in case adding k8s cluster from existed cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller.", + Description: "The parent cloud region name, for adding a k8s cluster from an existing cloud. Changing this value will cause the cloud to be destroyed and recreated by terraform. *Note* that this value must be set when running against a JAAS controller.", Optional: true, }, "id": schema.StringAttribute{ @@ -273,7 +273,7 @@ func (v *kuberenetesCloudJAASValidator) Description(ctx context.Context) string // MarkdownDescription implements the MarkdownDescription method of the resource.ConfigValidator interface. func (v *kuberenetesCloudJAASValidator) MarkdownDescription(_ context.Context) string { - return "Enforces that this resource can only be used with JAAS" + return "Enforces that the parent_cloud_name is specified when applying to a JAAS controller." } // ValidateResource implements the ValidateResource method of the resource.ConfigValidator interface. @@ -293,11 +293,7 @@ func (v *kuberenetesCloudJAASValidator) ValidateResource(ctx context.Context, re } if data.ParentCloudName.ValueString() == "" { - resp.Diagnostics.AddError("Plan Error", "parent_cloud_name must be specified when applying to a JAAS controller") - } - - if data.ParentCloudRegion.ValueString() == "" { - resp.Diagnostics.AddError("Plan Error", "parent_cloud_region must be specified when applying to a JAAS controller") + resp.Diagnostics.AddError("Plan Error", "Field `parent_cloud_name` must be specified when applying to a JAAS controller.") } } diff --git a/internal/provider/resource_kubernetes_cloud_test.go b/internal/provider/resource_kubernetes_cloud_test.go index e82d96aa..e908e20f 100644 --- a/internal/provider/resource_kubernetes_cloud_test.go +++ b/internal/provider/resource_kubernetes_cloud_test.go @@ -59,12 +59,10 @@ func TestAcc_ResourceKubernetesCloudWithJAASIncompleteConfig(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: frameworkProviderFactories, - Steps: []resource.TestStep{ - { - Config: testAccResourceKubernetesCloudWithoutParentCloud(cloudName, cloudConfig), - ExpectError: regexp.MustCompile("parent_cloud_region must be specified when applying to a JAAS controller"), - }, - }, + Steps: []resource.TestStep{{ + Config: testAccResourceKubernetesCloudWithoutParentCloudName(cloudName, cloudConfig), + ExpectError: regexp.MustCompile("Field `parent_cloud_name` must be specified when applying to a JAAS.*"), + }}, }) } @@ -87,7 +85,7 @@ resource "juju_kubernetes_cloud" "{{.CloudName}}" { }) } -func testAccResourceKubernetesCloudWithoutParentCloud(cloudName string, config string) string { +func testAccResourceKubernetesCloudWithoutParentCloudName(cloudName string, config string) string { return internaltesting.GetStringFromTemplateWithData( "testAccResourceSecret", `