From 520f16600ec4f078b997879d26cc857f961f222a Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 10:33:38 +0200 Subject: [PATCH 01/10] bump console client version --- go.mod | 4 ++-- go.sum | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 5c9b0d5..7d0170e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/mitchellh/go-homedir v1.1.0 - github.com/pluralsh/console-client-go v0.0.96 + github.com/pluralsh/console-client-go v0.1.16 github.com/pluralsh/plural-cli v0.8.5-0.20240216094552-efc34ee6de37 github.com/pluralsh/polly v0.1.7 github.com/samber/lo v1.38.1 @@ -21,6 +21,7 @@ require ( helm.sh/helm/v3 v3.11.2 k8s.io/apimachinery v0.26.4 k8s.io/client-go v0.26.4 + sigs.k8s.io/yaml v1.3.0 ) require ( @@ -353,7 +354,6 @@ require ( sigs.k8s.io/kustomize/api v0.13.2 // indirect sigs.k8s.io/kustomize/kyaml v0.14.3 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect ) replace ( diff --git a/go.sum b/go.sum index c25ee90..f66519a 100644 --- a/go.sum +++ b/go.sum @@ -856,14 +856,12 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pluralsh/console-client-go v0.0.96 h1:ZllMRmbmCiO3mvPNaLf5MeaniI5MHbuYnDUgnjkLiCM= -github.com/pluralsh/console-client-go v0.0.96/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo= +github.com/pluralsh/console-client-go v0.1.16 h1:f+d4ah3r+dAJ6hSMFsAmTlps4IsmExCzkCOwUpSYkbs= +github.com/pluralsh/console-client-go v0.1.16/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo= github.com/pluralsh/gqlclient v1.11.0 h1:FfXW7FiEJLHOfTAa7NxDb8jb3aMZNIpCAcG+bg8uHYA= github.com/pluralsh/gqlclient v1.11.0/go.mod h1:qSXKUlio1F2DRPy8el4oFYsmpKbkUYspgPB87T4it5I= github.com/pluralsh/plural-cli v0.8.5-0.20240216094552-efc34ee6de37 h1:DBnaKvKmbTbKwbkrh/2gJBwyHYfaXdxeT3UGh+94K4g= github.com/pluralsh/plural-cli v0.8.5-0.20240216094552-efc34ee6de37/go.mod h1:ZjvgOn9wE5vQXkImmoQknKKP0/68Ph6Hj19fUE1WdDU= -github.com/pluralsh/polly v0.1.4 h1:Kz90peCgvsfF3ERt8cujr5TR9z4wUlqQE60Eg09ZItY= -github.com/pluralsh/polly v0.1.4/go.mod h1:Yo1/jcW+4xwhWG+ZJikZy4J4HJkMNPZ7sq5auL2c/tY= github.com/pluralsh/polly v0.1.7 h1:MUuTb6rCUV1doisaFGC+iz+33ZPU4FZHOb/kFwSDkjw= github.com/pluralsh/polly v0.1.7/go.mod h1:Yo1/jcW+4xwhWG+ZJikZy4J4HJkMNPZ7sq5auL2c/tY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= From 5b66eb1d7f6baebc32a1893d65ff8d31251c4a40 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 11:51:21 +0200 Subject: [PATCH 02/10] add metadata field --- docs/resources/cluster.md | 1 + example/gcp/main.tf | 16 +++++++++++++++- internal/resource/cluster_model.go | 11 +++++++++++ internal/resource/cluster_schema.go | 6 ++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index c1ecf97..1c18f97 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -17,6 +17,7 @@ A representation of a cluster you can deploy to. ### Required +- `metadata` (String) Arbitrary JSON metadata to store user-specific state of this cluster (e.g. IAM roles for add-ons). - `name` (String) Human-readable name of this cluster, that also translates to cloud resource name. ### Optional diff --git a/example/gcp/main.tf b/example/gcp/main.tf index 7ffae10..fbad407 100644 --- a/example/gcp/main.tf +++ b/example/gcp/main.tf @@ -28,6 +28,20 @@ resource "plural_cluster" "gcp_workload_cluster" { tags = { "managed-by" = "terraform-provider-plural" } - + metadata = jsonencode({ + test1 = "string" + test2 = false + test3 = jsonencode({ + abc = false + }) + }) +# Alternative method: +# metadata = < Date: Wed, 17 Apr 2024 12:14:07 +0200 Subject: [PATCH 03/10] update data source too --- docs/data-sources/cluster.md | 1 + example/byok/main.tf | 15 +++++++++++++++ example/gcp/main.tf | 15 --------------- internal/datasource/cluster.go | 4 ++++ internal/datasource/cluster_model.go | 10 ++++++++++ internal/resource/cluster_model.go | 2 +- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index 4f04f48..1e1e1ee 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -25,6 +25,7 @@ A representation of a cluster you can deploy to. - `cloud` (String) The cloud provider used to create this cluster. - `desired_version` (String) Desired Kubernetes version for this cluster. - `inserted_at` (String) Creation date of this cluster. +- `metadata` (String) Arbitrary JSON metadata to store user-specific state of this cluster (e.g. IAM roles for add-ons). - `name` (String) Human-readable name of this cluster, that also translates to cloud resource name. - `node_pools` (Attributes Map) Map of node pool specs managed by this cluster, where the key is name of the node pool and value contains the spec. (see [below for nested schema](#nestedatt--node_pools)) - `protect` (Boolean) If set to `true` then this cluster cannot be deleted. diff --git a/example/byok/main.tf b/example/byok/main.tf index c5d02c0..088e823 100644 --- a/example/byok/main.tf +++ b/example/byok/main.tf @@ -19,6 +19,21 @@ resource "plural_cluster" "byok_workload_cluster" { # Required, can be sourced from environment variables # export PLURAL_KUBE_CONFIG_PATH to read from local file } + metadata = jsonencode({ + test1 = "string" + test2 = false + test3 = jsonencode({ + abc = false + }) + }) + # Alternative method + # metadata = < Date: Wed, 17 Apr 2024 12:28:42 +0200 Subject: [PATCH 04/10] update examples --- example/byok/main.tf | 4 ---- example/cluster_data/main.tf | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 example/cluster_data/main.tf diff --git a/example/byok/main.tf b/example/byok/main.tf index 088e823..33dcb08 100644 --- a/example/byok/main.tf +++ b/example/byok/main.tf @@ -38,7 +38,3 @@ resource "plural_cluster" "byok_workload_cluster" { "managed-by" = "terraform-provider-plural" } } - -#data "plural_cluster" "byok_workload_cluster" { -# handle = "wctf" -#} diff --git a/example/cluster_data/main.tf b/example/cluster_data/main.tf new file mode 100644 index 0000000..01c6f19 --- /dev/null +++ b/example/cluster_data/main.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + plural = { + source = "pluralsh/plural" + version = "0.0.1" + } + } +} + +provider "plural" { + use_cli = true +} + +data "plural_cluster" "cluster" { + handle = "mgmt" +} \ No newline at end of file From c969dff8bf20908bbf5e4afa0bda9ffff55d81b7 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 13:40:14 +0200 Subject: [PATCH 05/10] update schema --- example/byok/main.tf | 13 ++----------- internal/resource/cluster_schema.go | 3 ++- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/example/byok/main.tf b/example/byok/main.tf index 33dcb08..87e08e0 100644 --- a/example/byok/main.tf +++ b/example/byok/main.tf @@ -11,9 +11,8 @@ provider "plural" { use_cli = true } -resource "plural_cluster" "byok_workload_cluster" { - name = "workload-cluster-tf" - handle = "wctf" +resource "plural_cluster" "byok" { + name = "byok-tf" protect = "false" kubeconfig = { # Required, can be sourced from environment variables @@ -26,14 +25,6 @@ resource "plural_cluster" "byok_workload_cluster" { abc = false }) }) - # Alternative method - # metadata = < Date: Wed, 17 Apr 2024 15:10:24 +0200 Subject: [PATCH 06/10] handle desired version for byok clusters --- example/byok/main.tf | 4 ++-- internal/resource/cluster_model.go | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/example/byok/main.tf b/example/byok/main.tf index 87e08e0..b98979d 100644 --- a/example/byok/main.tf +++ b/example/byok/main.tf @@ -12,14 +12,14 @@ provider "plural" { } resource "plural_cluster" "byok" { - name = "byok-tf" + name = "byok" protect = "false" kubeconfig = { # Required, can be sourced from environment variables # export PLURAL_KUBE_CONFIG_PATH to read from local file } metadata = jsonencode({ - test1 = "string" + test1 = "test" test2 = false test3 = jsonencode({ abc = false diff --git a/internal/resource/cluster_model.go b/internal/resource/cluster_model.go index 7fff587..2823126 100644 --- a/internal/resource/cluster_model.go +++ b/internal/resource/cluster_model.go @@ -103,7 +103,7 @@ func (c *cluster) From(cl *console.ClusterFragment, ctx context.Context, d diag. c.InsertedAt = types.StringPointerValue(cl.InsertedAt) c.Name = types.StringValue(cl.Name) c.Handle = types.StringPointerValue(cl.Handle) - c.DesiredVersion = types.StringPointerValue(cl.Version) + c.DesiredVersion = c.ClusterVersionFrom(cl.Version, cl.CurrentVersion) c.Protect = types.BoolPointerValue(cl.Protect) c.Tags = common.ClusterTagsFrom(cl.Tags, d) c.ProviderId = common.ClusterProviderIdFrom(cl.Provider) @@ -116,13 +116,25 @@ func (c *cluster) FromCreate(cc *console.CreateCluster, ctx context.Context, d d c.InsertedAt = types.StringPointerValue(cc.CreateCluster.InsertedAt) c.Name = types.StringValue(cc.CreateCluster.Name) c.Handle = types.StringPointerValue(cc.CreateCluster.Handle) - c.DesiredVersion = types.StringPointerValue(cc.CreateCluster.Version) + c.DesiredVersion = c.ClusterVersionFrom(cc.CreateCluster.Version, cc.CreateCluster.CurrentVersion) c.Protect = types.BoolPointerValue(cc.CreateCluster.Protect) c.Tags = common.ClusterTagsFrom(cc.CreateCluster.Tags, d) c.ProviderId = common.ClusterProviderIdFrom(cc.CreateCluster.Provider) c.NodePools = common.ClusterNodePoolsFrom(cc.CreateCluster.NodePools, c.NodePools, ctx, d) } +func (c *cluster) ClusterVersionFrom(version, currentVersion *string) types.String { + if version != nil && len(*version) > 0 { + return types.StringPointerValue(version) + } + + if currentVersion != nil && len(*currentVersion) > 0 { + return types.StringPointerValue(currentVersion) + } + + return types.StringValue("unknown") +} + func (c *cluster) HasKubeconfig() bool { return c.Kubeconfig != nil || (c.CloudSettings != nil && c.CloudSettings.BYOK != nil && c.CloudSettings.BYOK.Kubeconfig != nil) } From d18b6e45304aabb659f98d4966538bf208e15123 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 15:36:01 +0200 Subject: [PATCH 07/10] update azure example --- example/azure/main.tf | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/example/azure/main.tf b/example/azure/main.tf index dd6bff1..9d7df86 100644 --- a/example/azure/main.tf +++ b/example/azure/main.tf @@ -11,21 +11,21 @@ provider "plural" { use_cli = true } -resource "plural_provider" "azure_provider" { - name = "azure" - cloud = "azure" - cloud_settings = { - azure = { - # subscription_id = "" # Required, can be sourced from PLURAL_AZURE_SUBSCRIPTION_ID - # tenant_id = "" # Required, can be sourced from PLURAL_AZURE_TENANT_ID - # client_id = "" # Required, can be sourced from PLURAL_AZURE_CLIENT_ID - # client_secret = "" # Required, can be sourced from PLURAL_AZURE_CLIENT_SECRET - } - } -} +#resource "plural_provider" "azure_provider" { +# name = "azure" +# cloud = "azure" +# cloud_settings = { +# azure = { +# # subscription_id = "" # Required, can be sourced from PLURAL_AZURE_SUBSCRIPTION_ID +# # tenant_id = "" # Required, can be sourced from PLURAL_AZURE_TENANT_ID +# # client_id = "" # Required, can be sourced from PLURAL_AZURE_CLIENT_ID +# # client_secret = "" # Required, can be sourced from PLURAL_AZURE_CLIENT_SECRET +# } +# } +#} data "plural_provider" "azure_provider" { - cloud = "aws" + cloud = "azure" } resource "plural_cluster" "azure_cluster" { @@ -43,6 +43,13 @@ resource "plural_cluster" "azure_cluster" { location = "eastus" } } + metadata = jsonencode({ + test1 = "test" + test2 = false + test3 = jsonencode({ + abc = false + }) + }) tags = { "managed-by" = "terraform-provider-plural" } From 43b517add954d188b94fe3f431ee3693fd8addba Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 15:44:36 +0200 Subject: [PATCH 08/10] update docs --- docs/resources/cluster.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 1c18f97..d74266f 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -17,7 +17,6 @@ A representation of a cluster you can deploy to. ### Required -- `metadata` (String) Arbitrary JSON metadata to store user-specific state of this cluster (e.g. IAM roles for add-ons). - `name` (String) Human-readable name of this cluster, that also translates to cloud resource name. ### Optional @@ -28,6 +27,7 @@ A representation of a cluster you can deploy to. - `handle` (String) A short, unique human-readable name used to identify this cluster. Does not necessarily map to the cloud resource name. - `helm_values` (String) Additional helm values you'd like to use in deployment agent helm installs. This is useful for BYOK clusters that need to use custom images or other constructs. - `kubeconfig` (Attributes) (see [below for nested schema](#nestedatt--kubeconfig)) +- `metadata` (String) Arbitrary JSON metadata to store user-specific state of this cluster (e.g. IAM roles for add-ons). - `node_pools` (Attributes Map) **Experimental, not ready for production use.** Map of node pool specs managed by this cluster, where the key is name of the node pool and value contains the spec. Leave empty for bring your own cluster. (see [below for nested schema](#nestedatt--node_pools)) - `protect` (Boolean) If set to `true` then this cluster cannot be deleted. - `provider_id` (String) Provider used to create this cluster. Leave empty for bring your own cluster. From 123351fe4a50f11125abd508af00e16a8ca7d6bc Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 16:18:42 +0200 Subject: [PATCH 09/10] add repo url --- docs/resources/cluster.md | 3 ++- internal/resource/cluster.go | 2 +- internal/resource/cluster_model.go | 1 + internal/resource/cluster_operator_handler.go | 10 ++++++++-- internal/resource/cluster_schema.go | 12 ++++++++++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index d74266f..f8fe6b6 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -25,7 +25,8 @@ A representation of a cluster you can deploy to. - `cloud` (String) The cloud provider used to create this cluster. - `cloud_settings` (Attributes) Cloud-specific settings for this cluster. (see [below for nested schema](#nestedatt--cloud_settings)) - `handle` (String) A short, unique human-readable name used to identify this cluster. Does not necessarily map to the cloud resource name. -- `helm_values` (String) Additional helm values you'd like to use in deployment agent helm installs. This is useful for BYOK clusters that need to use custom images or other constructs. +- `helm_repo_url` (String) Helm repository URL you'd like to use in deployment agent Helm install. +- `helm_values` (String) Additional Helm values you'd like to use in deployment agent Helm installs. This is useful for BYOK clusters that need to use custom images or other constructs. - `kubeconfig` (Attributes) (see [below for nested schema](#nestedatt--kubeconfig)) - `metadata` (String) Arbitrary JSON metadata to store user-specific state of this cluster (e.g. IAM roles for add-ons). - `node_pools` (Attributes Map) **Experimental, not ready for production use.** Map of node pool specs managed by this cluster, where the key is name of the node pool and value contains the spec. Leave empty for bring your own cluster. (see [below for nested schema](#nestedatt--node_pools)) diff --git a/internal/resource/cluster.go b/internal/resource/cluster.go index a65277a..b03e9ca 100644 --- a/internal/resource/cluster.go +++ b/internal/resource/cluster.go @@ -71,7 +71,7 @@ func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest return } - handler, err := NewOperatorHandler(ctx, data.GetKubeconfig(), data.HelmValues.ValueStringPointer(), r.consoleUrl) + handler, err := NewOperatorHandler(ctx, data.GetKubeconfig(), data.HelmRepoUrl.String(), data.HelmValues.ValueStringPointer(), r.consoleUrl) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to init operator handler, got error: %s", err)) return diff --git a/internal/resource/cluster_model.go b/internal/resource/cluster_model.go index 2823126..4eff890 100644 --- a/internal/resource/cluster_model.go +++ b/internal/resource/cluster_model.go @@ -28,6 +28,7 @@ type cluster struct { Bindings *common.ClusterBindings `tfsdk:"bindings"` NodePools types.Map `tfsdk:"node_pools"` CloudSettings *ClusterCloudSettings `tfsdk:"cloud_settings"` + HelmRepoUrl types.String `tfsdk:"helm_repo_url"` HelmValues types.String `tfsdk:"helm_values"` Kubeconfig *Kubeconfig `tfsdk:"kubeconfig"` } diff --git a/internal/resource/cluster_operator_handler.go b/internal/resource/cluster_operator_handler.go index bc3c33d..fdb8b36 100644 --- a/internal/resource/cluster_operator_handler.go +++ b/internal/resource/cluster_operator_handler.go @@ -20,11 +20,16 @@ import ( type OperatorHandler struct { ctx context.Context + // kubeconfig is a model.Kubeconfig data model read from terraform kubeconfig *Kubeconfig + // url is an url to the Console API, i.e. https://console.mycluster.onplural.sh url string + // repoUrl is an URL of the deployment agent chart. + repoUrl string + // additional values used on install vals map[string]interface{} @@ -67,7 +72,7 @@ func (oh *OperatorHandler) init() error { } func (oh *OperatorHandler) initRepo() error { - return helm.AddRepo(console.ReleaseName, console.RepoUrl) + return helm.AddRepo(console.ReleaseName, oh.repoUrl) } func (oh *OperatorHandler) initChart() error { @@ -171,7 +176,7 @@ func (oh *OperatorHandler) Uninstall() error { return err } -func NewOperatorHandler(ctx context.Context, kubeconfig *Kubeconfig, values *string, consoleUrl string) (*OperatorHandler, error) { +func NewOperatorHandler(ctx context.Context, kubeconfig *Kubeconfig, repoUrl string, values *string, consoleUrl string) (*OperatorHandler, error) { vals := map[string]interface{}{} if values != nil { if err := yaml.Unmarshal([]byte(*values), &vals); err != nil { @@ -182,6 +187,7 @@ func NewOperatorHandler(ctx context.Context, kubeconfig *Kubeconfig, values *str handler := &OperatorHandler{ ctx: ctx, kubeconfig: kubeconfig, + repoUrl: repoUrl, url: consoleUrl, vals: vals, } diff --git a/internal/resource/cluster_schema.go b/internal/resource/cluster_schema.go index 97645b5..1c93eb4 100644 --- a/internal/resource/cluster_schema.go +++ b/internal/resource/cluster_schema.go @@ -2,6 +2,7 @@ package resource import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/pluralsh/plural-cli/pkg/console" "terraform-provider-plural/internal/common" "terraform-provider-plural/internal/defaults" @@ -114,9 +115,16 @@ func (r *clusterResource) schema() schema.Schema { }, PlanModifiers: []planmodifier.Object{objectplanmodifier.RequiresReplace()}, }, + "helm_repo_url": schema.StringAttribute{ + Description: "Helm repository URL you'd like to use in deployment agent Helm install.", + MarkdownDescription: "Helm repository URL you'd like to use in deployment agent Helm install.", + Optional: true, + Computed: true, + Default: stringdefault.StaticString(console.RepoUrl), + }, "helm_values": schema.StringAttribute{ - Description: "Additional helm values you'd like to use in deployment agent helm installs. This is useful for BYOK clusters that need to use custom images or other constructs.", - MarkdownDescription: "Additional helm values you'd like to use in deployment agent helm installs. This is useful for BYOK clusters that need to use custom images or other constructs.", + Description: "Additional Helm values you'd like to use in deployment agent Helm installs. This is useful for BYOK clusters that need to use custom images or other constructs.", + MarkdownDescription: "Additional Helm values you'd like to use in deployment agent Helm installs. This is useful for BYOK clusters that need to use custom images or other constructs.", Optional: true, }, "kubeconfig": r.kubeconfigSchema(false), From 93f792cf33b935f4a03eabcae9dc63d605c0bea1 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 17 Apr 2024 16:45:52 +0200 Subject: [PATCH 10/10] some fixes --- example/byok/main.tf | 1 + internal/resource/cluster.go | 2 +- internal/resource/cluster_schema.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/example/byok/main.tf b/example/byok/main.tf index b98979d..5cd75a7 100644 --- a/example/byok/main.tf +++ b/example/byok/main.tf @@ -25,6 +25,7 @@ resource "plural_cluster" "byok" { abc = false }) }) + helm_repo_url = "https://pluralsh.github.io/deployment-operator" tags = { "managed-by" = "terraform-provider-plural" } diff --git a/internal/resource/cluster.go b/internal/resource/cluster.go index b03e9ca..26ce893 100644 --- a/internal/resource/cluster.go +++ b/internal/resource/cluster.go @@ -71,7 +71,7 @@ func (r *clusterResource) Create(ctx context.Context, req resource.CreateRequest return } - handler, err := NewOperatorHandler(ctx, data.GetKubeconfig(), data.HelmRepoUrl.String(), data.HelmValues.ValueStringPointer(), r.consoleUrl) + handler, err := NewOperatorHandler(ctx, data.GetKubeconfig(), data.HelmRepoUrl.ValueString(), data.HelmValues.ValueStringPointer(), r.consoleUrl) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to init operator handler, got error: %s", err)) return diff --git a/internal/resource/cluster_schema.go b/internal/resource/cluster_schema.go index 1c93eb4..dae73df 100644 --- a/internal/resource/cluster_schema.go +++ b/internal/resource/cluster_schema.go @@ -121,6 +121,7 @@ func (r *clusterResource) schema() schema.Schema { Optional: true, Computed: true, Default: stringdefault.StaticString(console.RepoUrl), + PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()}, }, "helm_values": schema.StringAttribute{ Description: "Additional Helm values you'd like to use in deployment agent Helm installs. This is useful for BYOK clusters that need to use custom images or other constructs.",