Skip to content

Commit

Permalink
Merge pull request #58 from pluralsh/marcin/prod-2636-add-url-to-serv…
Browse files Browse the repository at this point in the history
…ice-deployment-helm-schema-in-terraform

feat: Add Helm URL to service resource
  • Loading branch information
michaeljguarino authored Sep 17, 2024
2 parents fc28347 + 0065dcc commit 9e3d4ab
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 27 deletions.
3 changes: 2 additions & 1 deletion docs/resources/service_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
- `version` (String) Chart version to use.

<a id="nestedatt--helm--repository"></a>
### Nested Schema for `helm.repository`
Expand Down
34 changes: 34 additions & 0 deletions docs/resources/shared_secret.md
Original file line number Diff line number Diff line change
@@ -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 generated by tfplugindocs -->
## 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))

<a id="nestedatt--notification_bindings"></a>
### Nested Schema for `notification_bindings`

Optional:

- `group_id` (String)
- `id` (String)
- `user_id` (String)
43 changes: 19 additions & 24 deletions example/service/helm/main.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -12,34 +21,24 @@ 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
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
version = "0.0.2"
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 = {
Expand All @@ -51,8 +50,4 @@ resource "plural_service_deployment" "cd-test" {
}
}
}

depends_on = [
data.plural_cluster.byok_workload_cluster,
]
}
2 changes: 2 additions & 0 deletions internal/model/service_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
}
}

Expand Down
9 changes: 7 additions & 2 deletions internal/resource/service_deployment_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 to use.",
MarkdownDescription: "Helm repository URL to use.",
},
},
Validators: []validator.Object{
Expand Down

0 comments on commit 9e3d4ab

Please sign in to comment.