Skip to content

feat: bind config with cobra flags to override the conf#274

Merged
deryrahman merged 5 commits into
mainfrom
feat-config-flags-overriding
Apr 8, 2022
Merged

feat: bind config with cobra flags to override the conf#274
deryrahman merged 5 commits into
mainfrom
feat-config-flags-overriding

Conversation

@deryrahman
Copy link
Copy Markdown
Member

@deryrahman deryrahman commented Apr 6, 2022

  • overriding the config via flags provided by cobra
  • mapping the flag with - delimiter instead of . delimiter (--project-name instead of --project.name)
  • change flag names for each command that needs config overriding

TODO next (can be done in separate PR):

  • bump salt version to support pflags
  • rename --project to --project-name on entrypoint.sh for each plugins

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 6, 2022

Pull Request Test Coverage Report for Build 2113048272

  • 12 of 20 (60.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 74.645%

Changes Missing Coverage Covered Lines Changed/Added Lines %
config/loader.go 12 20 60.0%
Totals Coverage Status
Change from base Build 2112995892: -0.04%
Covered Lines: 5882
Relevant Lines: 7880

💛 - Coveralls

@deryrahman deryrahman self-assigned this Apr 6, 2022
@deryrahman
Copy link
Copy Markdown
Member Author

@sravankorumilli by default, salt is flattening the config keys with dot . delimiter, eg in server config (config.sample.yaml), we will have serve.port serve.host etc as their flags naming. eg. ./optimus serve --serve.port=8000

Instead of dot ., it's better to have dash - delimiter, so it will be ./optimus serve --serve-port=8000

I’m proposing the changes for salt config to have ability to replace the flag name delimiter, like we have on EnvKeyReplacer

wdyt?

@deryrahman deryrahman marked this pull request as ready for review April 6, 2022 08:00
@deryrahman
Copy link
Copy Markdown
Member Author

deryrahman commented Apr 6, 2022

add feature to salt package for overriding config via flags raystack/salt#30

@deryrahman
Copy link
Copy Markdown
Member Author

fix #257 and #271

Copy link
Copy Markdown
Contributor

@sravankorumilli sravankorumilli left a comment

Choose a reason for hiding this comment

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

What is the scope of this PR? Is it handled everywhere?


cmd.Flags().StringVarP(&projectName, "project", "p", projectName, "Name of the optimus project") // TODO: fix overriding conf via args
cmd.Flags().StringVar(&optimusHost, "host", optimusHost, "Optimus service endpoint url") // TODO: fix overriding conf via args
cmd.Flags().StringP("project-name", "p", defaultProjectName, "Name of the optimus project")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this change needs a corresponding change in the entrypoint.sh where ever it is referred when the optimus binary is upgraded in the plugins.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

noted, after we bump the optimus version, we can later update the flag name in endpoint.sh for each plugins

@deryrahman
Copy link
Copy Markdown
Member Author

deryrahman commented Apr 7, 2022

What is the scope of this PR? Is it handled everywhere?

All command that use flags to override the config should be impacted @sravankorumilli

@deryrahman deryrahman mentioned this pull request Apr 8, 2022
@deryrahman deryrahman force-pushed the feat-config-flags-overriding branch from c87fc04 to ae989a3 Compare April 8, 2022 04:18
@deryrahman deryrahman merged commit 4bfeffe into main Apr 8, 2022
@deryrahman deryrahman deleted the feat-config-flags-overriding branch April 8, 2022 06:09
@deryrahman
Copy link
Copy Markdown
Member Author

summarizing our discussions:

1. need to define which configs that are able to override and which are not
2. `--project` means to select the project, not to override the configs. Treat it as `kubectx`
3. action items: 
    - bump the plugins with `--project-name`
    - revisit it to provide `--project` for backward compatible or not

@ravisuhag @sravankorumilli

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.

Optimus provide a mechanism to register a project & namespace through cli

3 participants