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

Load user config from $HOME/.openvdc #64

Merged
merged 5 commits into from
Jan 10, 2017
Merged

Load user config from $HOME/.openvdc #64

merged 5 commits into from
Jan 10, 2017

Conversation

unakatsuo
Copy link
Contributor

@unakatsuo unakatsuo commented Jan 7, 2017

openvdc CLI has several common flags, that spf13/cobra says PersistentFlags. They had to be passed to the CLI everytime in order to specify the server address to connect. They should be able to save as the user local configuration file.

github.com/spf13/viper provides the feature to load configuration from multiple sources and to get merged value in loading priority.

Discussions:

  1. spf13/viper supports multiple formats, json, yaml, toml and hcl. which is/are better to support? Or which format should be rejected.
    • My opinion is .toml and then .json or .yaml. .hcl can be ignored.
  2. Might be out of scope this PR, openvdc-scheduler should it use the same framework?

TODO:

  • non-default config file can be set with --config flag.
  • Binds --server and --master flags to viper namespace.
  • Install default configuration file config.toml if not exist.
  • On windows, openvdc help shows correct user home location.

@unakatsuo
Copy link
Contributor Author

PS > .\openvdc help
Usage:
  openvdc [command]

Available Commands:
  console     Connect to an instance
  create      Create an instance from resource
  destroy     Destroy an instance
  list        List instances
  log         Print logs of an instance
  register    Register new resource.
  run         Run an instance
  show        Show a resource
  start       Start an instance
  stop        Stop a running instance
  template    Operations for resource template
  unregister  Unregister a resource
  version     Show version

Flags:
      --config string   Load config file from the path (default "C:\Users\katsuo\.openvdc\config.toml")
      --master string   Mesos Master node address (default "127.0.0.1:5050")
      --server string   gRPC API server address (default "127.0.0.1:5000")
  -t, --toggle          Help message for toggle

Use "openvdc [command] --help" for more information about a command.

@Metallion
Copy link
Contributor

👍 CI failure is due to a known issue in the integration test building code unrelated to this PR and is currently being worked on in another branch. Unit tests were green.

@Metallion Metallion merged commit 66d1ba5 into master Jan 10, 2017
@Metallion Metallion deleted the user-config branch January 10, 2017 09:22
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.

None yet

2 participants