Skip to content

Commit

Permalink
fix(update-collection-v3): retain metadata.metrics and metadata.logs …
Browse files Browse the repository at this point in the history
…keys
  • Loading branch information
Mikołaj Świątek committed Jan 26, 2023
1 parent 24aba42 commit 87703d8
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/go/cmd/update-collection-v3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
metadata:
metrics:
config:
keymetrics: valuemetrics
logs:
config:
merge:
keylogs: valuelogs
metrics:
config:
keymetrics: valuemetrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
metadata:
logs:
statefulset:
keylogs: valuelogs
metrics:
statefulset:
keymetrics: valuemetrics
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
metadata:
logs:
statefulset:
keylogs: valuelogs
metrics:
statefulset:
keymetrics: valuemetrics

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
metadata:
metrics:
statefulset:
keymetrics: valuemetrics
logs:
statefulset:
keylogs: valuelogs
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
metadata:
metrics:
statefulset:
keymetrics: valuemetrics
logs:
statefulset:
keylogs: valuelogs
4 changes: 4 additions & 0 deletions src/go/cmd/update-collection-v3/testdata/simple.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ metadata:
logs:
config:
keylogs: valuelogs
statefulset:
stsLogsKey: stsLogsValue
metrics:
config:
keymetrics: valuemetrics
statefulset:
stsMetricsKey: stsMetricsValue
otelevents:
config:
override:
Expand Down
4 changes: 4 additions & 0 deletions src/go/cmd/update-collection-v3/testdata/simple.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 87703d8

Please sign in to comment.