Skip to content

Commit

Permalink
chore(setup): get namespace from downward API
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Jun 17, 2024
1 parent ad0af09 commit ca1bce7
Show file tree
Hide file tree
Showing 25 changed files with 48 additions and 15 deletions.
1 change: 1 addition & 0 deletions deploy/helm/sumologic/conf/cleanup/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/sumologic/conf/setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion deploy/helm/sumologic/conf/setup/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ variable "collector_name" {

variable "namespace_name" {
type = string
default = "{{ template "sumologic.namespace" . }}"
}

variable "create_fields" {
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/sumologic/templates/cleanup/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/sumologic/templates/setup/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions tests/helm/testdata/goldenfile/cleanup/basic.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/helm/testdata/goldenfile/setup/basic.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -836,7 +837,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -739,7 +740,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -535,7 +536,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -535,7 +536,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -736,7 +737,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -726,7 +727,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -738,7 +739,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -738,7 +739,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -738,7 +739,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -742,7 +743,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -742,7 +743,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -737,7 +738,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -576,7 +577,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -736,7 +737,6 @@ data:
variable "namespace_name" {
type = string
default = "sumologic"
}
variable "create_fields" {
Expand Down

0 comments on commit ca1bce7

Please sign in to comment.