From a1158b5840498e34fc2a980a468cdb5fef6a2ddf Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Mon, 16 Sep 2024 12:05:07 +0200 Subject: [PATCH 1/4] add helm url --- docs/resources/service_deployment.md | 3 +- docs/resources/shared_secret.md | 34 +++++++++++++++++++ internal/model/service_deployment.go | 2 ++ .../resource/service_deployment_schema.go | 9 +++-- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 docs/resources/shared_secret.md diff --git a/docs/resources/service_deployment.md b/docs/resources/service_deployment.md index 3181c59f..5bd00a37 100644 --- a/docs/resources/service_deployment.md +++ b/docs/resources/service_deployment.md @@ -83,9 +83,10 @@ Optional: - `chart` (String) The name of the chart to use. - `repository` (Attributes) Resource reference to the flux Helm repository used by this chart. (see [below for nested schema](#nestedatt--helm--repository)) +- `url` (String) Helm repository URL use. - `values` (String) Helm values file to use with this service. - `values_files` (Set of String) List of relative paths to values files to use form Helm applies. -- `version` (String) Chart version to use +- `version` (String) Chart version to use. ### Nested Schema for `helm.repository` diff --git a/docs/resources/shared_secret.md b/docs/resources/shared_secret.md new file mode 100644 index 00000000..98d63cbe --- /dev/null +++ b/docs/resources/shared_secret.md @@ -0,0 +1,34 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "plural_shared_secret Resource - terraform-provider-plural" +subcategory: "" +description: |- + A one-time-viewable secret shared with a list of eligible users. +--- + +# plural_shared_secret (Resource) + +A one-time-viewable secret shared with a list of eligible users. + + + + +## Schema + +### Required + +- `name` (String) The name of this shared secret. +- `secret` (String, Sensitive) Content of this shared secret. + +### Optional + +- `notification_bindings` (Attributes Set) The users/groups you want this secret to be delivered to. (see [below for nested schema](#nestedatt--notification_bindings)) + + +### Nested Schema for `notification_bindings` + +Optional: + +- `group_id` (String) +- `id` (String) +- `user_id` (String) diff --git a/internal/model/service_deployment.go b/internal/model/service_deployment.go index 046bb844..c4d17799 100644 --- a/internal/model/service_deployment.go +++ b/internal/model/service_deployment.go @@ -291,6 +291,7 @@ type ServiceDeploymentHelm struct { Values types.String `tfsdk:"values"` ValuesFiles types.Set `tfsdk:"values_files"` Version types.String `tfsdk:"version"` + URL types.String `tfsdk:"url"` } func (this *ServiceDeploymentHelm) Attributes() *gqlclient.HelmConfigAttributes { @@ -309,6 +310,7 @@ func (this *ServiceDeploymentHelm) Attributes() *gqlclient.HelmConfigAttributes Chart: this.Chart.ValueStringPointer(), Version: this.Version.ValueStringPointer(), Repository: this.Repository.Attributes(), + URL: this.URL.ValueStringPointer(), } } diff --git a/internal/resource/service_deployment_schema.go b/internal/resource/service_deployment_schema.go index b5e7c08b..e532996b 100644 --- a/internal/resource/service_deployment_schema.go +++ b/internal/resource/service_deployment_schema.go @@ -291,8 +291,13 @@ func (r *ServiceDeploymentResource) schemaHelm() schema.SingleNestedAttribute { }, "version": schema.StringAttribute{ Optional: true, - Description: "Chart version to use", - MarkdownDescription: "Chart version to use", + Description: "Chart version to use.", + MarkdownDescription: "Chart version to use.", + }, + "url": schema.StringAttribute{ + Optional: true, + Description: "Helm repository URL use.", + MarkdownDescription: "Helm repository URL use.", }, }, Validators: []validator.Object{ From 0e9a879f752444e4989ed390a544f65b97a213b8 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Mon, 16 Sep 2024 12:35:28 +0200 Subject: [PATCH 2/4] update example --- example/service/helm/main.tf | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/example/service/helm/main.tf b/example/service/helm/main.tf index 5901fd2e..c4fa4386 100644 --- a/example/service/helm/main.tf +++ b/example/service/helm/main.tf @@ -1,9 +1,18 @@ +terraform { + required_providers { + plural = { + source = "pluralsh/plural" + version = "0.2.1" + } + } +} + provider "plural" { use_cli = true } -data "plural_cluster" "byok_workload_cluster" { - handle = "gcp-workload-cluster" +data "plural_cluster" "cluster" { + handle = "mgmt" } resource "plural_service_deployment" "cd-test" { @@ -12,7 +21,7 @@ resource "plural_service_deployment" "cd-test" { namespace = "tf-cd-helm-test" cluster = { - handle = data.plural_cluster.byok_workload_cluster.handle + handle = data.plural_cluster.cluster.handle } # Requires flux-source-controller addon to be installed and flux repo CRD for podinfo to exist @@ -51,8 +60,4 @@ resource "plural_service_deployment" "cd-test" { } } } - - depends_on = [ - data.plural_cluster.byok_workload_cluster, - ] } From 60c22dbcea93dde3116cb9f02ad32b9acf264ed5 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Mon, 16 Sep 2024 12:55:10 +0200 Subject: [PATCH 3/4] fix example --- example/service/helm/main.tf | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/example/service/helm/main.tf b/example/service/helm/main.tf index c4fa4386..47e0ee63 100644 --- a/example/service/helm/main.tf +++ b/example/service/helm/main.tf @@ -24,14 +24,10 @@ resource "plural_service_deployment" "cd-test" { handle = data.plural_cluster.cluster.handle } - # Requires flux-source-controller addon to be installed and flux repo CRD for podinfo to exist helm = { - chart = "podinfo" - repository = { - name = "podinfo" - namespace = "default" - } - version = "6.5.3" + chart = "grafana" + version = "8.x.x" + url = "https://grafana.github.io/helm-charts" } # Optional @@ -39,16 +35,10 @@ resource "plural_service_deployment" "cd-test" { docs_path = "doc" protect = false - configuration = [ - { - name : "host" - value : "tf-cd-test.gcp.plural.sh" - }, - { - name : "tag" - value : "sha-4d01e86" - } - ] + configuration = { + "host" = "tf-cd-test.gcp.plural.sh", + "tag" = "sha-4d01e86" + } sync_config = { namespace_metadata = { From 0065dcc059946922d133d309b75a1663f7bfa315 Mon Sep 17 00:00:00 2001 From: michaeljguarino Date: Mon, 16 Sep 2024 20:31:18 -0400 Subject: [PATCH 4/4] fix docs --- docs/resources/service_deployment.md | 2 +- internal/resource/service_deployment_schema.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/resources/service_deployment.md b/docs/resources/service_deployment.md index 5bd00a37..13bf0472 100644 --- a/docs/resources/service_deployment.md +++ b/docs/resources/service_deployment.md @@ -83,7 +83,7 @@ Optional: - `chart` (String) The name of the chart to use. - `repository` (Attributes) Resource reference to the flux Helm repository used by this chart. (see [below for nested schema](#nestedatt--helm--repository)) -- `url` (String) Helm repository URL use. +- `url` (String) Helm repository URL to use. - `values` (String) Helm values file to use with this service. - `values_files` (Set of String) List of relative paths to values files to use form Helm applies. - `version` (String) Chart version to use. diff --git a/internal/resource/service_deployment_schema.go b/internal/resource/service_deployment_schema.go index e532996b..c5f48ce9 100644 --- a/internal/resource/service_deployment_schema.go +++ b/internal/resource/service_deployment_schema.go @@ -296,8 +296,8 @@ func (r *ServiceDeploymentResource) schemaHelm() schema.SingleNestedAttribute { }, "url": schema.StringAttribute{ Optional: true, - Description: "Helm repository URL use.", - MarkdownDescription: "Helm repository URL use.", + Description: "Helm repository URL to use.", + MarkdownDescription: "Helm repository URL to use.", }, }, Validators: []validator.Object{