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

Zarf config file support using Viper #781

Merged
merged 34 commits into from
Oct 5, 2022
Merged

Zarf config file support using Viper #781

merged 34 commits into from
Oct 5, 2022

Conversation

jeff-mccoy
Copy link
Contributor

@jeff-mccoy jeff-mccoy commented Sep 26, 2022

This PR adds support for using Viper to support declarative automation for the Zarf CLI. As more flags are added to Zarf, it can become more imperative at runtime, Viper allows Zarf to remain fully declarative operations supported by automation.

src/cmd/package.go Outdated Show resolved Hide resolved
src/cmd/package.go Outdated Show resolved Hide resolved
@jeff-mccoy
Copy link
Contributor Author

So ran into a really interesting thing that I don't think we thought about before... when we bind multiple flags to a single variable, each binding overwrites the default state with the very last binding to it. Ran into this because config.CommonOptions.SetVariables default (which was provided by Viper) was being overridden by the empty default also provided by Viper later on. 🤦

@jeff-mccoy
Copy link
Contributor Author

Fortunately, the only place we use this that it would actually cause problems is for config.CommonOptions.SetVariables

@jeff-mccoy
Copy link
Contributor Author

zarf prep gc:

architecture = ''
log_level = 'info'
no_log_file = false
no_progress = false
tmp_dir = ''

[init]
components = ''
storage_class = ''

[init.git]
pull_password = ''
pull_username = ''
push_password = ''
push_username = 'zarf-git-user'
url = ''

[init.registry]
nodeport = 0
pull_password = ''
pull_username = ''
push_password = ''
push_username = 'zarf-push'
secret = ''
url = ''

[package]
[package.create]
insecure = false
output_directory = ''
skip_sbom = false
zarf_cache = '.zarf-image-cache'

[package.create.set]

[package.deploy]
components = ''
insecure = false
sget = ''
shasum = ''

[package.deploy.set]

@jeff-mccoy jeff-mccoy marked this pull request as ready for review October 4, 2022 08:04
@jeff-mccoy jeff-mccoy changed the title let viper load defaults to pass into flags Zarf config file support using Viper Oct 4, 2022
@jeff-mccoy jeff-mccoy requested a review from Racer159 October 4, 2022 19:43
examples/config-file/zarf.yaml Outdated Show resolved Hide resolved
src/cmd/package.go Outdated Show resolved Hide resolved
src/cmd/prepare.go Outdated Show resolved Hide resolved
src/cmd/prepare.go Outdated Show resolved Hide resolved
src/internal/message/message.go Show resolved Hide resolved
Copy link
Contributor

@Racer159 Racer159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jeff-mccoy jeff-mccoy merged commit ef799f5 into master Oct 5, 2022
@bdfinst bdfinst deleted the add-viper branch January 12, 2023 22:33
Noxsios pushed a commit that referenced this pull request Mar 8, 2023
This PR adds support for using [Viper](https://github.com/spf13/viper)
to support declarative automation for the Zarf CLI. As more flags are
added to Zarf, it can become more imperative at runtime, Viper allows
Zarf to remain fully declarative operations supported by automation.

Co-authored-by: Wayne Starr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants