Skip to content

Commit

Permalink
chore(setup): define Terraform providers via json
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Jun 17, 2024
1 parent 8c3d202 commit 3a1a14d
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 162 deletions.
26 changes: 0 additions & 26 deletions deploy/helm/sumologic/conf/setup/providers.tf

This file was deleted.

5 changes: 5 additions & 0 deletions deploy/helm/sumologic/conf/setup/providers.tf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- $kubernetesProvider := deepCopy .Values.sumologic.cluster -}}
{{- $sumoProvider := dict -}}
{{- $providers := dict "sumologic" $sumoProvider "kubernetes" $kubernetesProvider -}}
{{- $terraformData := dict "provider" $providers -}}
{{- toPrettyJson $terraformData | nindent 2 }}
23 changes: 0 additions & 23 deletions deploy/helm/sumologic/templates/_helpers/_setup.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,29 +147,6 @@ Example usage:
{{ $endpoint }}
{{- end -}}

{{/*
Add or skip quotation denending on the value
Examples:
- "${test}" will be printed as `test`
- "test" will be printed as `"test"`
Example Usage:
{{ include "terraform.sources.config-map-variable" "${file(\"/var/test\")}" }}

*/}}
{{- define "terraform.print_value" -}}
{{- if and (kindIs "string" .) -}}
{{- if (regexMatch "^\\$\\{[^\\$]*\\}$" .) -}}
{{ regexReplaceAll "^\\$\\{(.*)\\}$" . "${1}" }}
{{- else -}}
{{ printf "\"%s\"" . }}
{{- end -}}
{{- else -}}
{{ printf "\"%s\"" (toString .) }}
{{- end -}}
{{- end -}}

{{/*
Check if component (source/events/logs/traces etc.) is enabled or not
Expand Down
18 changes: 10 additions & 8 deletions tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
18 changes: 10 additions & 8 deletions tests/helm/testdata/goldenfile/terraform/custom.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
18 changes: 10 additions & 8 deletions tests/helm/testdata/goldenfile/terraform/default.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
18 changes: 10 additions & 8 deletions tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,15 +435,17 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
extrapolation = "${file("/var/run/secrets/kubernetes.io/serviceaccount/token")}/${test}"
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"extrapolation": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}/${test}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
18 changes: 10 additions & 8 deletions tests/helm/testdata/goldenfile/terraform/traces.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,16 @@ data:
echo "You can (re)install them manually with:"
echo "https://github.com/SumoLogic/terraform-sumologic-sumo-logic-monitor/tree/main/monitor_packages/kubernetes"
fi
providers.tf: |-
provider "sumologic" {}
provider "kubernetes" {
cluster_ca_certificate = file("/var/run/secrets/kubernetes.io/serviceaccount/ca.crt")
host = "https://kubernetes.default.svc"
token = file("/var/run/secrets/kubernetes.io/serviceaccount/token")
providers.tf.json: |
{
"provider": {
"kubernetes": {
"cluster_ca_certificate": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt\")}",
"host": "https://kubernetes.default.svc",
"token": "${file(\"/var/run/secrets/kubernetes.io/serviceaccount/token\")}"
},
"sumologic": {}
}
}
resources.tf: |
resource "sumologic_collector" "collector" {
Expand Down
Loading

0 comments on commit 3a1a14d

Please sign in to comment.