Skip to content

Commit

Permalink
chore(setup): store source configs as json
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Jun 17, 2024
1 parent ae27b22 commit 8c3d202
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 185 deletions.
18 changes: 1 addition & 17 deletions deploy/helm/sumologic/conf/setup/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,7 @@ resource "kubernetes_secret" "sumologic_collection_secret" {
}

data = {
{{- $ctx := .Values }}
{{- range $type, $sources := .Values.sumologic.collector.sources }}
{{- if eq (include "terraform.sources.component_enabled" (dict "Values" $ctx "Type" $type)) "true" }}
{{- range $key, $source := $sources }}
{{- if eq (include "terraform.sources.to_create" (dict "Context" $ctx "Type" $type "Name" $key)) "true" }}
{{ include "terraform.sources.data" (dict "Endpoint" (include "terraform.sources.config-map-variable" (dict "Type" $type "Context" $ctx "Name" $key)) "Name" (include "terraform.sources.name" (dict "Name" $key "Type" $type))) }}
{{- end }}
{{- end }}
{{- else if and (eq $type "metrics") $ctx.sumologic.traces.enabled }}
{{- /*
If traces are enabled and metrics are disabled, create default metrics source anyway
*/}}
{{- if hasKey $sources "default" }}
{{ include "terraform.sources.data" (dict "Endpoint" (include "terraform.sources.config-map-variable" (dict "Type" $type "Context" $ctx "Name" "default")) "Name" (include "terraform.sources.name" (dict "Name" "default" "Type" $type))) }}
{{- end }}
{{- end }}
{{- end }}
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}

type = "Opaque"
Expand Down
17 changes: 1 addition & 16 deletions tests/helm/testdata/goldenfile/terraform/all_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,22 +459,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-test_source_metrics_source = sumologic_http_source.test_source_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ data:
}
data = {
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ data:
}
data = {
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
16 changes: 1 addition & 15 deletions tests/helm/testdata/goldenfile/terraform/default.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,21 +459,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,20 +459,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,21 +459,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,21 +459,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
16 changes: 1 addition & 15 deletions tests/helm/testdata/goldenfile/terraform/logs_fields.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -485,21 +485,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,21 +465,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,21 +465,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,21 +460,7 @@ data:
}
data = {
endpoint-events = sumologic_http_source.default_events_source.url
endpoint-events-otlp = sumologic_http_source.default_otlp_events_source.url
endpoint-logs = sumologic_http_source.default_logs_source.url
endpoint-logs-otlp = sumologic_http_source.default_otlp_logs_source.url
endpoint-metrics-apiserver = sumologic_http_source.apiserver_metrics_source.url
endpoint-control_plane_metrics_source = sumologic_http_source.control_plane_metrics_source.url
endpoint-metrics-kube-controller-manager = sumologic_http_source.controller_metrics_source.url
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-metrics-otlp = sumologic_http_source.default_otlp_metrics_source.url
endpoint-metrics-kubelet = sumologic_http_source.kubelet_metrics_source.url
endpoint-metrics-node-exporter = sumologic_http_source.node_metrics_source.url
endpoint-metrics-kube-scheduler = sumologic_http_source.scheduler_metrics_source.url
endpoint-metrics-kube-state = sumologic_http_source.state_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
4 changes: 1 addition & 3 deletions tests/helm/testdata/goldenfile/terraform/traces.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,7 @@ data:
}
data = {
endpoint-metrics = sumologic_http_source.default_metrics_source.url
endpoint-traces = sumologic_http_source.default_traces_source.url
endpoint-traces-otlp = sumologic_http_source.default_otlp_traces_source.url
for name, config in local.source_configs : config["config-name"] => lookup(local.sources, name).url
}
type = "Opaque"
Expand Down
Loading

0 comments on commit 8c3d202

Please sign in to comment.