diff --git a/src/go/cmd/update-collection-v3/main.go b/src/go/cmd/update-collection-v3/main.go index b3894c94..6317ad2b 100644 --- a/src/go/cmd/update-collection-v3/main.go +++ b/src/go/cmd/update-collection-v3/main.go @@ -17,7 +17,7 @@ import ( kubeprometheusstackrepository "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/kube-prometheus-stack-repository" kubestatemetricscollectors "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/kube-state-metrics-collectors" "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/logformat" - "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/logsmetadataconfig" + logsmetadataconfig "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/logs-metadata-config" metricsmetadataconfig "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/metrics-metadata-config" metricsserverupgrade "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/metrics-server-upgrade" otellogsconfigmerge "github.com/SumoLogic/sumologic-kubernetes-collection/tools/cmd/update-collection-v3/migrations/otellogs-config-merge" diff --git a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/migrate.go b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/migrate.go similarity index 90% rename from src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/migrate.go rename to src/go/cmd/update-collection-v3/migrations/logs-metadata-config/migrate.go index 04a37ee6..cc952d3e 100644 --- a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/migrate.go +++ b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/migrate.go @@ -9,7 +9,7 @@ import ( type InputValues struct { Metadata struct { - Logs LogsMetadataInput `yaml:"logs,omitempty"` + Logs LogsMetadataInput `yaml:"logs,omitempty"` Rest map[string]interface{} `yaml:",inline"` } `yaml:"metadata,omitempty"` Rest map[string]interface{} `yaml:",inline"` @@ -22,7 +22,7 @@ type LogsMetadataInput struct { type OutputValues struct { Metadata struct { - Logs LogsMetadataOutput `yaml:"logs,omitempty"` + Logs LogsMetadataOutput `yaml:"logs,omitempty"` Rest map[string]interface{} `yaml:",inline"` } `yaml:"metadata,omitempty"` Rest map[string]interface{} `yaml:",inline"` @@ -36,7 +36,6 @@ type LogsMetadataOutput struct { Rest map[string]interface{} `yaml:",inline"` } - func Migrate(inputYaml string) (outputYaml string, err error) { inputValues, err := parseValues(inputYaml) if err != nil { @@ -66,6 +65,7 @@ func migrate(inputValues *InputValues) (OutputValues, error) { Rest: inputValues.Rest, } outputValues.Metadata.Rest = inputValues.Metadata.Rest + outputValues.Metadata.Logs.Rest = inputValues.Metadata.Logs.Rest outputValues.Metadata.Logs.Config.Merge = inputValues.Metadata.Logs.Config return outputValues, nil } diff --git a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/basic.input.yaml b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/basic.input.yaml similarity index 100% rename from src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/basic.input.yaml rename to src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/basic.input.yaml diff --git a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/basic.output.yaml b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/basic.output.yaml similarity index 100% rename from src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/basic.output.yaml rename to src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/basic.output.yaml index 2ca9aa97..fa73c1a1 100644 --- a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/basic.output.yaml +++ b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/basic.output.yaml @@ -1,8 +1,8 @@ metadata: - metrics: - config: - keymetrics: valuemetrics logs: config: merge: keylogs: valuelogs + metrics: + config: + keymetrics: valuemetrics diff --git a/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/nochange.input.yaml b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/nochange.input.yaml new file mode 100644 index 00000000..6b02ab48 --- /dev/null +++ b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/nochange.input.yaml @@ -0,0 +1,7 @@ +metadata: + logs: + statefulset: + keylogs: valuelogs + metrics: + statefulset: + keymetrics: valuemetrics diff --git a/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/nochange.output.yaml b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/nochange.output.yaml new file mode 100644 index 00000000..6b02ab48 --- /dev/null +++ b/src/go/cmd/update-collection-v3/migrations/logs-metadata-config/testdata/nochange.output.yaml @@ -0,0 +1,7 @@ +metadata: + logs: + statefulset: + keylogs: valuelogs + metrics: + statefulset: + keymetrics: valuemetrics diff --git a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/nochange.input.yaml b/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/nochange.input.yaml deleted file mode 100644 index 0967ef42..00000000 --- a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/nochange.input.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/nochange.output.yaml b/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/nochange.output.yaml deleted file mode 100644 index 0967ef42..00000000 --- a/src/go/cmd/update-collection-v3/migrations/logsmetadataconfig/testdata/nochange.output.yaml +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/migrate.go b/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/migrate.go index 29015072..76c4c34e 100644 --- a/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/migrate.go +++ b/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/migrate.go @@ -65,6 +65,7 @@ func migrate(inputValues *InputValues) (OutputValues, error) { Rest: inputValues.Rest, } outputValues.Metadata.Rest = inputValues.Metadata.Rest + outputValues.Metadata.Metrics.Rest = inputValues.Metadata.Metrics.Rest outputValues.Metadata.Metrics.Config.Merge = inputValues.Metadata.Metrics.Config return outputValues, nil } diff --git a/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.input.yaml b/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.input.yaml index 0967ef42..3ba152dd 100644 --- a/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.input.yaml +++ b/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.input.yaml @@ -1 +1,7 @@ -{} +metadata: + metrics: + statefulset: + keymetrics: valuemetrics + logs: + statefulset: + keylogs: valuelogs diff --git a/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.output.yaml b/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.output.yaml index 0967ef42..3ba152dd 100644 --- a/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.output.yaml +++ b/src/go/cmd/update-collection-v3/migrations/metrics-metadata-config/testdata/nochange.output.yaml @@ -1 +1,7 @@ -{} +metadata: + metrics: + statefulset: + keymetrics: valuemetrics + logs: + statefulset: + keylogs: valuelogs diff --git a/src/go/cmd/update-collection-v3/testdata/simple.input.yaml b/src/go/cmd/update-collection-v3/testdata/simple.input.yaml index e29c0d99..baac874f 100644 --- a/src/go/cmd/update-collection-v3/testdata/simple.input.yaml +++ b/src/go/cmd/update-collection-v3/testdata/simple.input.yaml @@ -23,9 +23,13 @@ metadata: logs: config: keylogs: valuelogs + statefulset: + stsLogsKey: stsLogsValue metrics: config: keymetrics: valuemetrics + statefulset: + stsMetricsKey: stsMetricsValue otelevents: config: override: diff --git a/src/go/cmd/update-collection-v3/testdata/simple.output.yaml b/src/go/cmd/update-collection-v3/testdata/simple.output.yaml index 0c52a4ef..ab024700 100644 --- a/src/go/cmd/update-collection-v3/testdata/simple.output.yaml +++ b/src/go/cmd/update-collection-v3/testdata/simple.output.yaml @@ -18,12 +18,16 @@ metadata: config: merge: keylogs: valuelogs + statefulset: + stsLogsKey: stsLogsValue autoscaling: enabled: true metrics: config: merge: keymetrics: valuemetrics + statefulset: + stsMetricsKey: stsMetricsValue autoscaling: enabled: true otelevents: