mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-08-19 20:26:41 +00:00
* add config merge support * fix indentation * Update cmd/polaris/root.go Co-authored-by: Andy Suderman <andy@fairwinds.com> --------- Co-authored-by: Andy Suderman <andy@fairwinds.com>
51 lines
829 B
Go
51 lines
829 B
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
var defaults = `
|
|
checks:
|
|
deploymentMissingReplicas: warning
|
|
priorityClassNotSet: warning
|
|
tagNotSpecified: danger
|
|
existing:
|
|
sub:
|
|
key: value
|
|
`
|
|
|
|
var overrides = `
|
|
checks:
|
|
pullPolicyNotAlways: ignore
|
|
tagNotSpecified: overrides
|
|
existing:
|
|
sub:
|
|
key1: value1
|
|
new: value
|
|
new:
|
|
key: value
|
|
`
|
|
|
|
func TestMergeYaml(t *testing.T) {
|
|
mergedContent, err := mergeYaml([]byte(defaults), []byte(overrides))
|
|
assert.NoError(t, err)
|
|
|
|
expectedYAML := `checks:
|
|
deploymentMissingReplicas: warning
|
|
priorityClassNotSet: warning
|
|
pullPolicyNotAlways: ignore
|
|
tagNotSpecified: overrides
|
|
existing:
|
|
new: value
|
|
sub:
|
|
key: value
|
|
key1: value1
|
|
new:
|
|
key: value
|
|
`
|
|
|
|
assert.Equal(t, expectedYAML, string(mergedContent))
|
|
}
|