defenseunicorns / defenseunicorns/uds-cli

uds config variable check only on deploy

Open
#641 0 comments 0 reactions 0 assignees View on GitHub
tech-debt
Dominant language
Go
Stars
54
Forks
21
Avg merge
2d 15h
Merged PRs (30d)
45

Description

follow on to #618

Currently config validation is being done in the root init function which gets called before any command code.

The config code is going through variables and making sure they are uppercase, but this should only be done when running a `deploy` command. It is not needed for the other commands.

``` // ensure the DeployOpts.Variables pkg vars are uppercase
for pkgName, pkgVar := range bundleCfg.DeployOpts.Variables {
for varName, varValue := range pkgVar {
// delete the lowercase var and replace with uppercase
delete(bundleCfg.DeployOpts.Variables[pkgName], varName)
bundleCfg.DeployOpts.Variables[pkgName][strings.ToUpper(varName)] = varValue
}
}

// ensure the DeployOpts.SharedVariables vars are uppercase
for varName, varValue := range bundleCfg.DeployOpts.SharedVariables {
// delete the lowercase var and replace with uppercase
delete(bundleCfg.DeployOpts.SharedVariables, varName)
bundleCfg.DeployOpts.SharedVariables[strings.ToUpper(varName)] = varValue
}
```

Possible solution:
- calling the loadViperConfig function in the preRun for every command and refactoring the loadViperConfig function to take in the `cmd` that is being called. That `cmd` can then be used to to check if those for loops need to run.

Contributor guide

Open the contributing guide

Research direction

Start by reading the root init function and loadViperConfig, then trace each command's preRun path. Confirm that uppercase conversion for DeployOpts.Variables and DeployOpts.SharedVariables runs only for deploy, while other commands continue without that validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.