Skip to content

Commit

Permalink
Make CI config path configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
csandanov committed May 3, 2021
1 parent daa9c6c commit 9210444
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ Available Commands:
version Shows Wodby CLI version
Flags:
--api-key string API key
--api-prefix string API prefix (default "api/v2")
--api-proto string API protocol (default "https")
--dind Docker in docker mode (for init)
-h, --help help for wodby
-v, --verbose Verbose output
--api-key string API key
--api-prefix string API prefix (default "api/v2")
--api-proto string API protocol (default "https")
--ci-config-path string Path to CI config (defaut "/tmp/.wodby-ci.json")
--dind Docker in docker mode (for init)
-h, --help Help for wodby
-v, --verbose Verbose output
Use "wodby [command] --help" for more information about a command.
```
2 changes: 1 addition & 1 deletion cmd/wodby/ci/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var Cmd = &cobra.Command{
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.services = args

v.SetConfigFile(path.Join("/tmp/.wodby-ci.json"))
v.SetConfigFile(path.Join(viper.GetString("ci_config_path")))

err := v.ReadInConfig()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/wodby/ci/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var Cmd = &cobra.Command{
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.services = args

v.SetConfigFile(path.Join("/tmp/.wodby-ci.json"))
v.SetConfigFile(path.Join(viper.GetString("ci_config_path")))

err := v.ReadInConfig()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/wodby/ci/initialize/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var Cmd = &cobra.Command{
return err
}

err = ioutil.WriteFile(path.Join("/tmp/.wodby-ci.json"), content, 0600)
err = ioutil.WriteFile(path.Join(viper.GetString("ci_config_path")), content, 0600)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/wodby/ci/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var Cmd = &cobra.Command{
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.services = args

v.SetConfigFile(path.Join("/tmp/.wodby-ci.json"))
v.SetConfigFile(path.Join(viper.GetString("ci_config_path")))

err := v.ReadInConfig()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/wodby/ci/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type options struct {
env []string
user string
entrypoint string
path string
path string
}

var opts options
Expand All @@ -28,9 +28,9 @@ var v = viper.New()
var Cmd = &cobra.Command{
Use: "run",
Short: "Run container",
Args: cobra.MinimumNArgs(1),
Args: cobra.MinimumNArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
v.SetConfigFile(path.Join( "/tmp/.wodby-ci.json"))
v.SetConfigFile(path.Join(viper.GetString("ci_config_path")))

err := v.ReadInConfig()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/wodby/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func init() {
RootCmd.PersistentFlags().String("api-prefix", "api/v2", "API prefix")
viper.BindPFlag("api_prefix", RootCmd.PersistentFlags().Lookup("api-prefix"))

RootCmd.PersistentFlags().String("ci-config-path", "/tmp/.wodby-ci.json", "CI config path")
viper.BindPFlag("ci_config_path", RootCmd.PersistentFlags().Lookup("ci-config-path"))

RootCmd.PersistentFlags().Bool("verbose", false, "Verbose output")
viper.BindPFlag("verbose", RootCmd.PersistentFlags().Lookup("verbose"))

Expand Down

0 comments on commit 9210444

Please sign in to comment.