-
Notifications
You must be signed in to change notification settings - Fork 0
added helm resource #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
added helm resource #471
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,117 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| intent: helm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flavor: k8s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: '0.2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Adds Helm module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| clouds: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - aws | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - azure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - gcp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - kubernetes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| iac: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| validated_files: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - variables.tf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prometheus_details: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: '@outputs/prometheus' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resource_type: configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resource_name: prometheus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kubernetes_details: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: '@outputs/kubernetes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resource_type: kubernetes_cluster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| resource_name: default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providers: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - kubernetes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - helm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - kubernetes-alpha | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Helm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Specification of the Helm chart intent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| properties: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| helm: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Helm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Configuration for the Helm chart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| properties: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chart: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Chart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Name of the Helm chart package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter name of the helm chart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*[a-zA-Z0-9]$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-error-message: Invalid format. Only alphabets, numbers and hypens are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| allowed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repository: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: URL or relative path for the helm repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter URL or relative path of the repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: '[a-zA-Z0-9:/._-]+' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-error-message: Invalid input format. The URL or relative path should | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contain only valid regex `[a-zA-Z0-9:/._-]+` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Version for the helm chart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter the valid chart version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Namespace to deploy the Helm chart in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pattern: ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-error-message: Invalid namespace format. The namespace must be DNS-compliant, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| containing only letters, numbers, and hyphens, and must not start or end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with a hyphen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| wait: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Wait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Whether to wait for the Helm chart deployment to complete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repository_username: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Repository Username | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Username to authenticate to private helm repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter repository username | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repository_password: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Repository Password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: Password to authenticate to private helm repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter repository password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-mask-content: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - chart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-order: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - chart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - namespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - repository_username | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - repository_password | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - wait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: Values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: The values to be passed on to the chart in the form of a YAML object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-yaml-editor: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| x-ui-placeholder: Enter values in YAML format | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| required: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - helm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sample: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $schema: https://facets-cloud.github.io/facets-schemas/schemas/helm/helm.schema.json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kind: helm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| flavor: k8s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled: true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metadata: {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: '0.2' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| helm: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repository: https://helm.datadoghq.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chart: datadog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| wait: false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| values: null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+101
to
+117
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Schema requires You mark Option A (allow nulls): - values:
- type: object
+ values:
+ type:
+ - object
+ - 'null'
@@
- required:
- - helm
- - values
+ required:
+ - helmOption B (if you want to require non-null values): update sample and 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| locals { | ||
|
|
||
| variables = lookup(var.instance.spec, "env", []) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont have this, variables, static_variables, dynamic_variables_raw etc |
||
| # filter out static variables | ||
| static_variables = toset([for x in local.variables : x if x["type"] == "static"]) | ||
| # filter out static variables | ||
| dynamic_variables_raw = toset([for x in local.variables : x if x["type"] == "secret"]) | ||
| # replace the value | ||
| dynamic_variables = toset([ | ||
| for x in local.dynamic_variables_raw : { | ||
| name = x["name"], | ||
| default = lookup(var.environment.secrets, x["attribute"], "Invalid Secret Reference") | ||
| } | ||
| ]) | ||
| all_variables = setunion(local.static_variables, local.dynamic_variables) | ||
|
Comment on lines
+3
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard nested attribute access and avoid set unions across heterogeneous object shapes. Directly accessing Apply this refactor to harden locals: locals {
-
- variables = lookup(var.instance.spec, "env", [])
- # filter out static variables
- static_variables = toset([for x in local.variables : x if x["type"] == "static"])
- # filter out static variables
- dynamic_variables_raw = toset([for x in local.variables : x if x["type"] == "secret"])
- # replace the value
- dynamic_variables = toset([
- for x in local.dynamic_variables_raw : {
- name = x["name"],
- default = lookup(var.environment.secrets, x["attribute"], "Invalid Secret Reference")
- }
- ])
- all_variables = setunion(local.static_variables, local.dynamic_variables)
+ spec = try(var.instance.spec, {})
+ helm_spec = try(local.spec.helm, {})
+ variables = try(local.spec.env, [])
+
+ # Filter static variables
+ static_variables = [for x in local.variables : x if try(x.type, null) == "static"]
+
+ # Filter secret-backed variables
+ dynamic_variables_raw = [for x in local.variables : x if try(x.type, null) == "secret"]
+
+ # Resolve secret defaults safely (environment.secrets may be absent)
+ dynamic_variables = [
+ for x in local.dynamic_variables_raw : {
+ name = x.name
+ default = lookup(lookup(var.environment, "secrets", {}), x.attribute, "Invalid Secret Reference")
+ }
+ ]
+
+ # Combine without forcing a set of mixed object shapes
+ all_variables = concat(local.static_variables, local.dynamic_variables)
}
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| resource "helm_release" "external_helm_charts" { | ||
| provider = "helm3" | ||
| chart = var.instance.spec["helm"]["chart"] | ||
| name = var.instance_name | ||
| namespace = lookup(var.instance.spec["helm"], "namespace", var.environment.namespace) | ||
| timeout = lookup(var.instance.spec["helm"], "timeout", 300) | ||
| create_namespace = true | ||
| wait = lookup(var.instance.spec["helm"], "wait", true) | ||
| repository = lookup(var.instance.spec["helm"], "repository", "") | ||
| version = lookup(var.instance.spec["helm"], "version", "") | ||
| recreate_pods = lookup(var.instance.spec["helm"], "recreate_pods", false) | ||
| repository_username = lookup(var.instance.spec["helm"], "repository_username", null) | ||
| repository_password = lookup(var.instance.spec["helm"], "repository_password", null) | ||
| values = lookup(var.instance.spec, "values", null) != null ? [yamlencode(lookup(var.instance.spec, "values", {}))] : null | ||
| cleanup_on_fail = true | ||
| } | ||
|
Comment on lines
+19
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFix provider reference and make Helm spec access safe.
resource "helm_release" "external_helm_charts" {
- provider = "helm3"
- chart = var.instance.spec["helm"]["chart"]
- name = var.instance_name
- namespace = lookup(var.instance.spec["helm"], "namespace", var.environment.namespace)
- timeout = lookup(var.instance.spec["helm"], "timeout", 300)
- create_namespace = true
- wait = lookup(var.instance.spec["helm"], "wait", true)
- repository = lookup(var.instance.spec["helm"], "repository", "")
- version = lookup(var.instance.spec["helm"], "version", "")
- recreate_pods = lookup(var.instance.spec["helm"], "recreate_pods", false)
- repository_username = lookup(var.instance.spec["helm"], "repository_username", null)
- repository_password = lookup(var.instance.spec["helm"], "repository_password", null)
- values = lookup(var.instance.spec, "values", null) != null ? [yamlencode(lookup(var.instance.spec, "values", {}))] : null
- cleanup_on_fail = true
+ # provider = helm # (optional) let root module pass provider; uncomment and set alias if needed
+ chart = local.helm_spec.chart
+ name = var.instance_name
+ namespace = lookup(local.helm_spec, "namespace", lookup(var.environment, "namespace", "default"))
+ timeout = lookup(local.helm_spec, "timeout", 300)
+ create_namespace = true
+ wait = lookup(local.helm_spec, "wait", true)
+ repository = lookup(local.helm_spec, "repository", "")
+ version = lookup(local.helm_spec, "version", "")
+ recreate_pods = lookup(local.helm_spec, "recreate_pods", false)
+ repository_username = lookup(local.helm_spec, "repository_username", null)
+ repository_password = lookup(local.helm_spec, "repository_password", null)
+ values = try(local.spec.values, null) != null ? [yamlencode(local.spec.values)] : null
+ cleanup_on_fail = true
}
🏁 Script executed: #!/bin/bash
set -e
# Inspect for locals block within the helm module
echo ">>> Checking for locals blocks in modules/helm/k8s/0.2/main.tf"
rg -n 'locals' -C3 modules/helm/k8s/0.2/main.tf || echo "No locals block found in this file"
# Search for any references to helm_spec throughout the repo
echo ">>> Searching for 'helm_spec' references across the repository"
rg -n 'helm_spec' -C3 . || echo "No occurrences of 'helm_spec' found"Length of output: 544 Fix missing The suggested diff references • Add a locals {
# pull the Helm-specific settings, or use an empty object if absent
helm_spec = lookup(var.instance.spec, "helm", {})
# pull any top-level values, or default to empty map
spec_values = lookup(var.instance.spec, "values", {})
}• In the values = length(local.spec_values) > 0 ? [yamlencode(local.spec_values)] : null• Remove the hard-coded
Revised snippet for the resource: resource "helm_release" "external_helm_charts" {
- provider = "helm3"
- chart = var.instance.spec["helm"]["chart"]
+ # provider = helm.v3 # uncomment if using an aliased provider
+ chart = local.helm_spec.chart
name = var.instance_name
namespace = lookup(local.helm_spec, "namespace", lookup(var.environment, "namespace", "default"))
timeout = lookup(local.helm_spec, "timeout", 300)
create_namespace = true
wait = lookup(local.helm_spec, "wait", true)
repository = lookup(local.helm_spec, "repository", "")
version = lookup(local.helm_spec, "version", "")
recreate_pods = lookup(local.helm_spec, "recreate_pods", false)
repository_username = lookup(local.helm_spec, "repository_username", null)
repository_password = lookup(local.helm_spec, "repository_password", null)
- values = lookup(var.instance.spec, "values", null) != null ? [yamlencode(lookup(var.instance.spec, "values", {}))] : null
+ values = length(local.spec_values) > 0 ? [yamlencode(local.spec_values)] : null
cleanup_on_fail = true
}🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||||||||||||||||||||
| locals { | ||||||||||||||||||||||||
| output_attributes = { | ||||||||||||||||||||||||
| release_name = helm_release.external_helm_charts.name | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| output_interfaces = {} | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| output "metadata" { | ||||||||||||||||||||||||
| value = helm_release.external_helm_charts.metadata | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+8
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Helm provider’s -output "metadata" {
- value = helm_release.external_helm_charts.metadata
-}
+output "metadata" {
+ value = {
+ name = helm_release.external_helm_charts.name
+ namespace = helm_release.external_helm_charts.namespace
+ chart = helm_release.external_helm_charts.chart
+ version = helm_release.external_helm_charts.version
+ }
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| output "status" { | ||||||||||||||||||||||||
| value = helm_release.external_helm_charts.status | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| variable "instance" { | ||
| type = any | ||
| default = {} | ||
| } | ||
|
|
||
| variable "instance_name" { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ask mcp to validate the variables.tf file |
||
| type = string | ||
| default = "test_instance" | ||
| } | ||
|
|
||
| variable "environment" { | ||
| type = any | ||
| default = { | ||
| namespace = "default" | ||
| } | ||
| } | ||
|
Comment on lines
+11
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default
variable "environment" {
type = any
default = {
namespace = "default"
+ secrets = {}
}
}🤖 Prompt for AI Agents |
||
|
|
||
| variable "inputs" { | ||
| type = any | ||
| default = {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||||||||||||||||||||
| terraform { | ||||||||||||||||||||||||
| required_providers { | ||||||||||||||||||||||||
| helm3 = { | ||||||||||||||||||||||||
| source = "hashicorp/helm3" | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+3
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the official Helm provider source and local name; Terraform’s official Helm provider is Apply this diff to align with the official provider: required_providers {
- helm3 = {
- source = "hashicorp/helm3"
- }
+ helm = {
+ source = "hashicorp/helm"
+ }
kubernetes = {
source = "hashicorp/kubernetes"
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| kubernetes = { | ||||||||||||||||||||||||
| source = "hashicorp/kubernetes" | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| required_version = ">= 0.13" | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Namespace regex allows uppercase and violates k8s DNS-1123 label rules.
Kubernetes namespaces must be lowercase alphanumeric plus hyphen, start/end with alphanumeric, max 63 chars. Update the pattern accordingly.
🤖 Prompt for AI Agents