Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: uds config validation #618

Merged
merged 18 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cmd/uds.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func loadViperConfig() error {

// read relevant config into DeployOpts.Variables
// need to use goyaml because Viper doesn't preserve case: https://github.com/spf13/viper/issues/1014
err = goyaml.Unmarshal(configFile, &bundleCfg.DeployOpts)
err = goyaml.UnmarshalWithOptions(configFile, &bundleCfg.DeployOpts, goyaml.Strict())
if err != nil {
return err
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/bundles/07-helm-overrides/uds-config-invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
options:
log_level: debug
decleaver marked this conversation as resolved.
Show resolved Hide resolved

# helm-overrides is an invalid top level key. Missing `variables` parent key.
decleaver marked this conversation as resolved.
Show resolved Hide resolved
helm-overrides:
ui_color: "orange"
14 changes: 14 additions & 0 deletions src/test/e2e/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,17 @@ func TestBundleTmpDir(t *testing.T) {
err = os.RemoveAll("./customtmp")
require.NoError(t, err)
}

func TestInvalidConfig(t *testing.T) {
os.Setenv("UDS_CONFIG", filepath.Join("src/test/bundles/07-helm-overrides", "uds-config-invalid.yaml"))
deployZarfInit(t)
zarfPkgPath := "src/test/packages/helm"
e2e.HelmDepUpdate(t, fmt.Sprintf("%s/unicorn-podinfo", zarfPkgPath))
e2e.CreateZarfPkg(t, zarfPkgPath, false)
bundleDir := "src/test/bundles/07-helm-overrides"
createLocal(t, bundleDir, e2e.Arch)
bundlePath := filepath.Join(bundleDir, fmt.Sprintf("uds-bundle-helm-overrides-%s-0.0.1.tar.zst", e2e.Arch))
_, stderr := deployWithError(t, bundlePath)
require.Contains(t, stderr, "unknown field")
os.Unsetenv("UDS_CONFIG")
}
6 changes: 6 additions & 0 deletions src/test/e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@
return stdout, stderr
}

func deployWithError(t *testing.T, tarballPath string) (stdout string, stderr string) {

Check warning on line 115 in src/test/e2e/commands_test.go

View workflow job for this annotation

GitHub Actions / validate

parameter 't' seems to be unused, consider removing or renaming it as _
decleaver marked this conversation as resolved.