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

Add support for config file #1195

Merged
merged 1 commit into from
Aug 21, 2023

Conversation

tangledbytes
Copy link
Member

@tangledbytes tangledbytes commented Aug 10, 2023

Explain the changes

This PR adds support for config file. The following things are supported right now:

  1. All the persistent/global flags can be specified in the config file instead of passing as a flag.
  2. resources field is supported in the config file which allows overriding the default resources allocated to NooBaa components. This field can be used in conjunction with pre-existing flags like --dev and --mini in which case the values from the config file will override the values of the flag.

The config file can be placed at /etc/noobaa/noobaa.cfg.yaml, ~/.noobaa/noobaa.cfg.yaml or at ./noobaa.cfg.yaml.

Example config file

# This will override the namespace of installation
namespace: noobaa-test

# This will override the operator image
operator-image: noobaa/noobaa-operator:5.15.0

# This will override the show-secrets which defaults to false
show-secrets: true

# This is equivalent to using `--dev`
dev: true

# This is a special field which is unavailable in the CLI via flags
resources:
  core:
    memoryMB: 512
  db:
    cpuMilli: 500
    memoryMB: 1024
  endpoints:
    cpuMilli: 500
    memoryMB: 1024
    minCount: 1
    maxCount: 3 
  • Doc added/updated
  • Tests added

@tangledbytes tangledbytes requested review from dannyzaken, liranmauda, a team and jackyalbo and removed request for a team August 10, 2023 12:38
@tangledbytes tangledbytes marked this pull request as draft August 11, 2023 07:04
@tangledbytes tangledbytes force-pushed the utkarsh/add/config-file branch 2 times, most recently from ff81870 to 6972dac Compare August 11, 2023 09:14
@tangledbytes tangledbytes marked this pull request as ready for review August 11, 2023 10:16
Copy link
Contributor

@liranmauda liranmauda left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment/question

Comment on lines +170 to +172
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
logrus.Warn("failed to read config:", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't figure out when this can happen.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this can happen when say the config file is not valid (valid as in not adhering to yaml spec) yaml. In such cases we would want just log that there was some issue in reading the file.

Signed-off-by: Utkarsh Srivastava <[email protected]>

fix golangci lint issue

Signed-off-by: Utkarsh Srivastava <[email protected]>

rename config file to noobaa.cfg.yaml

Signed-off-by: Utkarsh Srivastava <[email protected]>

prevent falsy flag additions

Signed-off-by: Utkarsh Srivastava <[email protected]>

add noobaa config to git ignore

Signed-off-by: Utkarsh Srivastava <[email protected]>
@tangledbytes tangledbytes merged commit b97390d into noobaa:master Aug 21, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants