From 5d5a296f43874e0e9886bb943395954e0a364925 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= <mail+sumo@mikolajswiatek.com> Date: Wed, 12 Jun 2024 16:33:49 +0200 Subject: [PATCH 1/2] chore(setup): get namespace from downward API --- deploy/helm/sumologic/conf/cleanup/cleanup.sh | 1 + deploy/helm/sumologic/conf/setup/setup.sh | 1 + deploy/helm/sumologic/conf/setup/variables.tf | 1 - deploy/helm/sumologic/templates/cleanup/job.yaml | 4 ++++ deploy/helm/sumologic/templates/setup/job.yaml | 4 ++++ tests/helm/testdata/goldenfile/cleanup/basic.output.yaml | 4 ++++ .../goldenfile/cleanup/sumologic-mock-no-secret.output.yaml | 4 ++++ .../testdata/goldenfile/cleanup/sumologic-mock.output.yaml | 4 ++++ tests/helm/testdata/goldenfile/setup/basic.output.yaml | 4 ++++ .../goldenfile/setup/sumologic-mock-no-secret.output.yaml | 4 ++++ .../helm/testdata/goldenfile/setup/sumologic-mock.output.yaml | 4 ++++ .../helm/testdata/goldenfile/terraform/all_fields.output.yaml | 2 +- .../goldenfile/terraform/collector_fields.output.yaml | 2 +- .../goldenfile/terraform/conditional_sources.output.yaml | 2 +- tests/helm/testdata/goldenfile/terraform/custom.output.yaml | 2 +- tests/helm/testdata/goldenfile/terraform/default.output.yaml | 2 +- .../goldenfile/terraform/disable_default_metrics.output.yaml | 2 +- .../goldenfile/terraform/disabled_dashboards.output.yaml | 2 +- .../goldenfile/terraform/disabled_monitors.output.yaml | 2 +- .../testdata/goldenfile/terraform/logs_fields.output.yaml | 2 +- .../terraform/monitors_with_email_notifications.output.yaml | 2 +- .../terraform/monitors_with_single_email.output.yaml | 2 +- .../goldenfile/terraform/strip_extrapolation.output.yaml | 2 +- tests/helm/testdata/goldenfile/terraform/traces.output.yaml | 2 +- .../goldenfile/terraform/tracing-metrics-disabled.output.yaml | 2 +- 25 files changed, 48 insertions(+), 15 deletions(-) diff --git a/deploy/helm/sumologic/conf/cleanup/cleanup.sh b/deploy/helm/sumologic/conf/cleanup/cleanup.sh index 1c707c352..3e2434db0 100755 --- a/deploy/helm/sumologic/conf/cleanup/cleanup.sh +++ b/deploy/helm/sumologic/conf/cleanup/cleanup.sh @@ -14,6 +14,7 @@ readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" +export TF_VAR_namespace_name="${NAMESPACE:?}" cp /etc/terraform/* /terraform/ cd /terraform || exit 1 diff --git a/deploy/helm/sumologic/conf/setup/setup.sh b/deploy/helm/sumologic/conf/setup/setup.sh index b8e7a0974..ad22889ba 100755 --- a/deploy/helm/sumologic/conf/setup/setup.sh +++ b/deploy/helm/sumologic/conf/setup/setup.sh @@ -7,6 +7,7 @@ readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" +export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE diff --git a/deploy/helm/sumologic/conf/setup/variables.tf b/deploy/helm/sumologic/conf/setup/variables.tf index e29737816..3b9497c1d 100644 --- a/deploy/helm/sumologic/conf/setup/variables.tf +++ b/deploy/helm/sumologic/conf/setup/variables.tf @@ -4,7 +4,6 @@ variable "collector_name" { variable "namespace_name" { type = string - default = "{{ template "sumologic.namespace" . }}" } variable "create_fields" { diff --git a/deploy/helm/sumologic/templates/cleanup/job.yaml b/deploy/helm/sumologic/templates/cleanup/job.yaml index 9beea2ff5..05ad87757 100644 --- a/deploy/helm/sumologic/templates/cleanup/job.yaml +++ b/deploy/helm/sumologic/templates/cleanup/job.yaml @@ -52,6 +52,10 @@ spec: - secretRef: name: {{ .Values.sumologic.envFromSecret | default (include "sumologic.metadata.name.setup.secret" .)}} env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL {{- if eq (include "sumologic-mock.local-mode-enabled" .) "true" }} value: http://{{ template "sumologic-mock.hostname" . }}:{{ template "sumologic-mock.port" . }}/terraform/api/ diff --git a/deploy/helm/sumologic/templates/setup/job.yaml b/deploy/helm/sumologic/templates/setup/job.yaml index 5e1dc6af5..6ff8cbdc6 100644 --- a/deploy/helm/sumologic/templates/setup/job.yaml +++ b/deploy/helm/sumologic/templates/setup/job.yaml @@ -67,6 +67,10 @@ spec: - secretRef: name: {{ .Values.sumologic.envFromSecret | default (include "sumologic.metadata.name.setup.secret" .)}} env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL {{- if eq (include "sumologic-mock.local-mode-enabled" .) "true" }} value: http://{{ template "sumologic-mock.hostname" . }}:{{ template "sumologic-mock.port" . }}/terraform/api/ diff --git a/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml b/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml index 759000631..447da37ae 100644 --- a/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml +++ b/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml @@ -51,6 +51,10 @@ spec: - secretRef: name: RELEASE-NAME-sumologic-setup env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL value: - name: SUMOLOGIC_COLLECTOR_NAME diff --git a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml index c87508300..874635f7f 100644 --- a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml +++ b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml @@ -51,6 +51,10 @@ spec: - secretRef: name: RELEASE-NAME-sumologic-setup env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL value: http://RELEASE-NAME-sumologic-mock.sumologic.svc.cluster.local.:3000/terraform/api/ - name: SUMOLOGIC_COLLECTOR_NAME diff --git a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml index 4af56df1a..79a8c4f98 100644 --- a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml +++ b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml @@ -51,6 +51,10 @@ spec: - secretRef: name: RELEASE-NAME-sumologic-setup env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL value: http://RELEASE-NAME-sumologic-mock.sumologic.svc.cluster.local.:3000/terraform/api/ - name: SUMOLOGIC_COLLECTOR_NAME diff --git a/tests/helm/testdata/goldenfile/setup/basic.output.yaml b/tests/helm/testdata/goldenfile/setup/basic.output.yaml index 568ca282a..aec6c0de3 100644 --- a/tests/helm/testdata/goldenfile/setup/basic.output.yaml +++ b/tests/helm/testdata/goldenfile/setup/basic.output.yaml @@ -55,6 +55,10 @@ spec: - secretRef: name: RELEASE-NAME-sumologic-setup env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL value: - name: SUMOLOGIC_COLLECTOR_NAME diff --git a/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml b/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml index 7d559670f..a64161bee 100644 --- a/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml +++ b/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml @@ -55,6 +55,10 @@ spec: - secretRef: name: RELEASE-NAME-sumologic-setup env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL value: http://RELEASE-NAME-sumologic-mock.sumologic.svc.cluster.local.:3000/terraform/api/ - name: SUMOLOGIC_COLLECTOR_NAME diff --git a/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml b/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml index 7d559670f..a64161bee 100644 --- a/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml +++ b/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml @@ -55,6 +55,10 @@ spec: - secretRef: name: RELEASE-NAME-sumologic-setup env: + - name: NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace - name: SUMOLOGIC_BASE_URL value: http://RELEASE-NAME-sumologic-mock.sumologic.svc.cluster.local.:3000/terraform/api/ - name: SUMOLOGIC_COLLECTOR_NAME diff --git a/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml b/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml index a9a5cdb1d..02846d5e7 100644 --- a/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -836,7 +837,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml b/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml index 290815e6c..ff4acdb83 100644 --- a/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -739,7 +740,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml b/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml index df7445b91..d02a9e42a 100644 --- a/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -535,7 +536,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/custom.output.yaml b/tests/helm/testdata/goldenfile/terraform/custom.output.yaml index df7445b91..d02a9e42a 100644 --- a/tests/helm/testdata/goldenfile/terraform/custom.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/custom.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -535,7 +536,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/default.output.yaml b/tests/helm/testdata/goldenfile/terraform/default.output.yaml index 0382da981..0215f1219 100644 --- a/tests/helm/testdata/goldenfile/terraform/default.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/default.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -736,7 +737,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml b/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml index 286743398..cefc7ae2a 100644 --- a/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -726,7 +727,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml b/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml index b703cef4b..c1fdc4afb 100644 --- a/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -738,7 +739,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml b/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml index 629b3cb2f..ceebbadf6 100644 --- a/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -738,7 +739,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml b/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml index 8e75ae360..c4beed39a 100644 --- a/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -738,7 +739,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml b/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml index ccbc7288d..7249d2b22 100644 --- a/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml @@ -364,6 +364,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -742,7 +743,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml b/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml index 7ec2f8c92..b03cafda6 100644 --- a/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml @@ -364,6 +364,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -742,7 +743,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml b/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml index 2e4ac756f..d497973f5 100644 --- a/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml @@ -359,6 +359,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -737,7 +738,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/traces.output.yaml b/tests/helm/testdata/goldenfile/terraform/traces.output.yaml index 6ca58e2f4..82620b3a0 100644 --- a/tests/helm/testdata/goldenfile/terraform/traces.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/traces.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -576,7 +577,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { diff --git a/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml b/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml index 0382da981..0215f1219 100644 --- a/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml @@ -358,6 +358,7 @@ data: # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" + export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -736,7 +737,6 @@ data: variable "namespace_name" { type = string - default = "sumologic" } variable "create_fields" { From 8703f2a94cf1ef8082aefe485dd9b4f0c8227c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= <mail+sumo@mikolajswiatek.com> Date: Thu, 13 Jun 2024 11:35:00 +0200 Subject: [PATCH 2/2] chore(setup): pass secret name as variable --- deploy/helm/sumologic/conf/cleanup/cleanup.sh | 4 +++- deploy/helm/sumologic/conf/setup/resources.tf | 2 +- deploy/helm/sumologic/conf/setup/setup.sh | 7 +++++-- deploy/helm/sumologic/conf/setup/variables.tf | 4 ++++ deploy/helm/sumologic/templates/_helpers/_setup.tpl | 12 ------------ deploy/helm/sumologic/templates/cleanup/job.yaml | 2 ++ deploy/helm/sumologic/templates/setup/job.yaml | 2 ++ .../testdata/goldenfile/cleanup/basic.output.yaml | 2 ++ .../cleanup/sumologic-mock-no-secret.output.yaml | 2 ++ .../goldenfile/cleanup/sumologic-mock.output.yaml | 2 ++ .../testdata/goldenfile/setup/basic.output.yaml | 2 ++ .../setup/sumologic-mock-no-secret.output.yaml | 2 ++ .../goldenfile/setup/sumologic-mock.output.yaml | 2 ++ .../goldenfile/terraform/all_fields.output.yaml | 13 ++++++++++--- .../terraform/collector_fields.output.yaml | 13 ++++++++++--- .../terraform/conditional_sources.output.yaml | 13 ++++++++++--- .../goldenfile/terraform/custom.output.yaml | 13 ++++++++++--- .../goldenfile/terraform/default.output.yaml | 13 ++++++++++--- .../terraform/disable_default_metrics.output.yaml | 13 ++++++++++--- .../terraform/disabled_dashboards.output.yaml | 13 ++++++++++--- .../terraform/disabled_monitors.output.yaml | 13 ++++++++++--- .../goldenfile/terraform/logs_fields.output.yaml | 13 ++++++++++--- .../monitors_with_email_notifications.output.yaml | 13 ++++++++++--- .../monitors_with_single_email.output.yaml | 13 ++++++++++--- .../terraform/strip_extrapolation.output.yaml | 13 ++++++++++--- .../goldenfile/terraform/traces.output.yaml | 13 ++++++++++--- .../terraform/tracing-metrics-disabled.output.yaml | 13 ++++++++++--- 27 files changed, 169 insertions(+), 58 deletions(-) diff --git a/deploy/helm/sumologic/conf/cleanup/cleanup.sh b/deploy/helm/sumologic/conf/cleanup/cleanup.sh index 3e2434db0..9d88d45ef 100755 --- a/deploy/helm/sumologic/conf/cleanup/cleanup.sh +++ b/deploy/helm/sumologic/conf/cleanup/cleanup.sh @@ -10,6 +10,8 @@ export HTTPS_PROXY="${HTTPS_PROXY:=""}" export NO_PROXY="${NO_PROXY:=""}" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" +readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" +readonly NAMESPACE="${NAMESPACE:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" @@ -26,7 +28,7 @@ terraform init -input=false -get=false || terraform init -input=false -upgrade # shellcheck disable=SC1083 terraform import sumologic_collector.collector "${SUMOLOGIC_COLLECTOR_NAME}" # shellcheck disable=SC1083 -terraform import kubernetes_secret.sumologic_collection_secret {{ template "terraform.secret.fullname" . }} +terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" terraform destroy -auto-approve diff --git a/deploy/helm/sumologic/conf/setup/resources.tf b/deploy/helm/sumologic/conf/setup/resources.tf index bbae01df0..6fb7e790b 100644 --- a/deploy/helm/sumologic/conf/setup/resources.tf +++ b/deploy/helm/sumologic/conf/setup/resources.tf @@ -6,7 +6,7 @@ resource "sumologic_collector" "collector" { resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "{{ template "terraform.secret.name" }}" + name = var.secret_name namespace = var.namespace_name } diff --git a/deploy/helm/sumologic/conf/setup/setup.sh b/deploy/helm/sumologic/conf/setup/setup.sh index ad22889ba..a3eeb4685 100755 --- a/deploy/helm/sumologic/conf/setup/setup.sh +++ b/deploy/helm/sumologic/conf/setup/setup.sh @@ -3,11 +3,14 @@ readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" +readonly NAMESPACE="${NAMESPACE:?}" +readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" +export TF_VAR_namespace_name="${NAMESPACE}" +export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" -export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -149,7 +152,7 @@ terraform import sumologic_http_source.{{ template "terraform.sources.name" (dic fi # Kubernetes Secret -terraform import kubernetes_secret.sumologic_collection_secret {{ template "terraform.secret.fullname" . }} +terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ diff --git a/deploy/helm/sumologic/conf/setup/variables.tf b/deploy/helm/sumologic/conf/setup/variables.tf index 3b9497c1d..d0d048512 100644 --- a/deploy/helm/sumologic/conf/setup/variables.tf +++ b/deploy/helm/sumologic/conf/setup/variables.tf @@ -6,6 +6,10 @@ variable "namespace_name" { type = string } +variable "secret_name" { + type = string +} + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/deploy/helm/sumologic/templates/_helpers/_setup.tpl b/deploy/helm/sumologic/templates/_helpers/_setup.tpl index b676d3d12..f0e4ee1da 100644 --- a/deploy/helm/sumologic/templates/_helpers/_setup.tpl +++ b/deploy/helm/sumologic/templates/_helpers/_setup.tpl @@ -10,18 +10,6 @@ Example usage: {{ printf "%s" "sumologic" }} {{- end -}} -{{/* -Returns the name of Kubernetes secret prefixed with release namespace. - -Example usage: - -{{ include "terraform.secret.fullname" }} - -*/}} -{{- define "terraform.secret.fullname" -}} -{{ template "sumologic.namespace" . }}/{{ template "terraform.secret.name" . }} -{{- end -}} - {{/* Convert source name to Terraform metric name: * converts all `-` to `_` diff --git a/deploy/helm/sumologic/templates/cleanup/job.yaml b/deploy/helm/sumologic/templates/cleanup/job.yaml index 05ad87757..d4168d21f 100644 --- a/deploy/helm/sumologic/templates/cleanup/job.yaml +++ b/deploy/helm/sumologic/templates/cleanup/job.yaml @@ -66,6 +66,8 @@ spec: value: {{ include "terraform.collector.name" . }} - name: CHART_VERSION value: "{{ .Chart.Version }}" + - name: SUMOLOGIC_SECRET_NAME + value: "{{ template "terraform.secret.name" }}" {{- include "proxy-env-variables" . | nindent 10 }} securityContext: runAsUser: 999 diff --git a/deploy/helm/sumologic/templates/setup/job.yaml b/deploy/helm/sumologic/templates/setup/job.yaml index 6ff8cbdc6..ef87e46b3 100644 --- a/deploy/helm/sumologic/templates/setup/job.yaml +++ b/deploy/helm/sumologic/templates/setup/job.yaml @@ -79,6 +79,8 @@ spec: {{- end }} - name: SUMOLOGIC_COLLECTOR_NAME value: {{ include "terraform.collector.name" . }} + - name: SUMOLOGIC_SECRET_NAME + value: "{{ template "terraform.secret.name" }}" - name: CHART_VERSION value: "{{ .Chart.Version }}" {{- include "proxy-env-variables" . | nindent 8 -}} diff --git a/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml b/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml index 447da37ae..1b9c41e4e 100644 --- a/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml +++ b/tests/helm/testdata/goldenfile/cleanup/basic.output.yaml @@ -61,6 +61,8 @@ spec: value: kubernetes - name: CHART_VERSION value: "%CURRENT_CHART_VERSION%" + - name: SUMOLOGIC_SECRET_NAME + value: "sumologic" - name: NO_PROXY value: kubernetes.default.svc diff --git a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml index 874635f7f..d7efd0bc8 100644 --- a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml +++ b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock-no-secret.output.yaml @@ -61,6 +61,8 @@ spec: value: kubernetes - name: CHART_VERSION value: "%CURRENT_CHART_VERSION%" + - name: SUMOLOGIC_SECRET_NAME + value: "sumologic" - name: NO_PROXY value: kubernetes.default.svc diff --git a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml index 79a8c4f98..f04419b47 100644 --- a/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml +++ b/tests/helm/testdata/goldenfile/cleanup/sumologic-mock.output.yaml @@ -61,6 +61,8 @@ spec: value: kubernetes - name: CHART_VERSION value: "%CURRENT_CHART_VERSION%" + - name: SUMOLOGIC_SECRET_NAME + value: "sumologic" - name: NO_PROXY value: kubernetes.default.svc diff --git a/tests/helm/testdata/goldenfile/setup/basic.output.yaml b/tests/helm/testdata/goldenfile/setup/basic.output.yaml index aec6c0de3..67067c6f5 100644 --- a/tests/helm/testdata/goldenfile/setup/basic.output.yaml +++ b/tests/helm/testdata/goldenfile/setup/basic.output.yaml @@ -63,6 +63,8 @@ spec: value: - name: SUMOLOGIC_COLLECTOR_NAME value: kubernetes + - name: SUMOLOGIC_SECRET_NAME + value: "sumologic" - name: CHART_VERSION value: "%CURRENT_CHART_VERSION%" diff --git a/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml b/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml index a64161bee..ae2f28ac3 100644 --- a/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml +++ b/tests/helm/testdata/goldenfile/setup/sumologic-mock-no-secret.output.yaml @@ -63,6 +63,8 @@ spec: value: http://RELEASE-NAME-sumologic-mock.sumologic.svc.cluster.local.:3000/terraform/api/ - name: SUMOLOGIC_COLLECTOR_NAME value: kubernetes + - name: SUMOLOGIC_SECRET_NAME + value: "sumologic" - name: CHART_VERSION value: "%CURRENT_CHART_VERSION%" diff --git a/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml b/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml index a64161bee..ae2f28ac3 100644 --- a/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml +++ b/tests/helm/testdata/goldenfile/setup/sumologic-mock.output.yaml @@ -63,6 +63,8 @@ spec: value: http://RELEASE-NAME-sumologic-mock.sumologic.svc.cluster.local.:3000/terraform/api/ - name: SUMOLOGIC_COLLECTOR_NAME value: kubernetes + - name: SUMOLOGIC_SECRET_NAME + value: "sumologic" - name: CHART_VERSION value: "%CURRENT_CHART_VERSION%" diff --git a/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml b/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml index 02846d5e7..7954d7615 100644 --- a/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -499,7 +502,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -839,6 +842,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml b/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml index ff4acdb83..b57792f82 100644 --- a/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/collector_fields.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -498,7 +501,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -742,6 +745,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml b/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml index d02a9e42a..9b96591ee 100644 --- a/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/conditional_sources.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -483,7 +486,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -538,6 +541,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/custom.output.yaml b/tests/helm/testdata/goldenfile/terraform/custom.output.yaml index d02a9e42a..9b96591ee 100644 --- a/tests/helm/testdata/goldenfile/terraform/custom.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/custom.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -483,7 +486,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -538,6 +541,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/default.output.yaml b/tests/helm/testdata/goldenfile/terraform/default.output.yaml index 0215f1219..de0e7d0f6 100644 --- a/tests/helm/testdata/goldenfile/terraform/default.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/default.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -498,7 +501,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -739,6 +742,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml b/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml index cefc7ae2a..4259207f9 100644 --- a/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/disable_default_metrics.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -497,7 +500,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -729,6 +732,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml b/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml index c1fdc4afb..513e4037a 100644 --- a/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/disabled_dashboards.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -498,7 +501,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -741,6 +744,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml b/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml index ceebbadf6..957afcf69 100644 --- a/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/disabled_monitors.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -498,7 +501,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -741,6 +744,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml b/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml index c4beed39a..d4a4a39ea 100644 --- a/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -498,7 +501,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -741,6 +744,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml b/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml index 7249d2b22..148a51c2c 100644 --- a/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/monitors_with_email_notifications.output.yaml @@ -344,7 +344,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -360,11 +360,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -504,7 +507,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -745,6 +748,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml b/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml index b03cafda6..d1018ec4e 100644 --- a/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/monitors_with_single_email.output.yaml @@ -344,7 +344,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -360,11 +360,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -504,7 +507,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -745,6 +748,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml b/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml index d497973f5..e5fa04e9d 100644 --- a/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/strip_extrapolation.output.yaml @@ -339,7 +339,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -355,11 +355,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -499,7 +502,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -740,6 +743,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/traces.output.yaml b/tests/helm/testdata/goldenfile/terraform/traces.output.yaml index 82620b3a0..907ac2443 100644 --- a/tests/helm/testdata/goldenfile/terraform/traces.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/traces.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -486,7 +489,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -579,6 +582,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool diff --git a/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml b/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml index 0215f1219..de0e7d0f6 100644 --- a/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml +++ b/tests/helm/testdata/goldenfile/terraform/tracing-metrics-disabled.output.yaml @@ -338,7 +338,7 @@ data: resource "kubernetes_secret" "sumologic_collection_secret" { metadata { - name = "sumologic" + name = var.secret_name namespace = var.namespace_name } @@ -354,11 +354,14 @@ data: readonly DEBUG_MODE=${DEBUG_MODE:="false"} readonly DEBUG_MODE_ENABLED_FLAG="true" readonly SUMOLOGIC_COLLECTOR_NAME="${SUMOLOGIC_COLLECTOR_NAME:?}" + readonly NAMESPACE="${NAMESPACE:?}" + readonly SUMOLOGIC_SECRET_NAME="${SUMOLOGIC_SECRET_NAME:?}" # Set variables for terraform export TF_VAR_collector_name="${SUMOLOGIC_COLLECTOR_NAME}" + export TF_VAR_namespace_name="${NAMESPACE}" + export TF_VAR_secret_name="${SUMOLOGIC_SECRET_NAME}" export TF_VAR_chart_version="${CHART_VERSION:?}" - export TF_VAR_namespace_name="${NAMESPACE:?}" # Let's compare the variables ignoring the case with help of ${VARIABLE,,} which makes the string lowercased # so that we don't have to deal with True vs true vs TRUE @@ -498,7 +501,7 @@ data: fi # Kubernetes Secret - terraform import kubernetes_secret.sumologic_collection_secret sumologic/sumologic + terraform import kubernetes_secret.sumologic_collection_secret "${NAMESPACE}/${SUMOLOGIC_SECRET_NAME}" # Apply planned changes TF_LOG_PROVIDER=DEBUG terraform apply \ @@ -739,6 +742,10 @@ data: type = string } + variable "secret_name" { + type = string + } + variable "create_fields" { description = "If set, Terraform will attempt to create fields at Sumo Logic" type = bool