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

Deploy multiple #32

Merged
merged 10 commits into from
Jan 30, 2019
20 changes: 10 additions & 10 deletions cli/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ func RunECreate(cmd *cobra.Command, args []string) error {
func getCreateCmdConfig(cmd *cobra.Command) ([]connectors.CreateConnectorRequest, error) {
var configs []connectors.CreateConnectorRequest

if cmd.Flag("file").Changed {
fileInfo, err := os.Stat(file)
if cmd.Flag("input").Changed {
fileInfo, err := os.Stat(input)
if err != nil {
return nil, errors.Wrapf(err, "error while trying to find file or folder: %v", file)
return nil, errors.Wrapf(err, "error while trying to find input or folder: %v", input)
fsilberstein marked this conversation as resolved.
Show resolved Hide resolved
}
if fileInfo.IsDir() {
configs, err = getConfigFromFolder(file)
configs, err = getConfigFromFolder(input)
if err != nil {
return nil, err
}
} else {
config, err := getConfigFromFile(file)
config, err := getConfigFromFile(input)
if err != nil {
return nil, err
}
Expand All @@ -82,7 +82,7 @@ func getCreateCmdConfig(cmd *cobra.Command) ([]connectors.CreateConnectorRequest
}
configs = append(configs, config)
} else {
return nil, errors.New("neither file nor string was supplied")
return nil, errors.New("neither input nor string was supplied")
}
return configs, nil
}
Expand All @@ -95,12 +95,12 @@ func getConfigFromFolder(folderPath string) ([]connectors.CreateConnectorRequest
}
for _, fileInfo := range configFiles {
if fileInfo.IsDir() {
log.Printf("found unexpected subfolder in folder: %s. This command will not search through it.", file)
log.Printf("found unexpected subfolder in folder: %s. This command will not search through it.", input)
continue
}
config, err := getConfigFromFile(path.Join(folderPath, fileInfo.Name()))
if err != nil {
log.Printf("found unexpected not config file in folder: %s", file)
log.Printf("found unexpected not config file in folder: %s", input)
} else {
configs = append(configs, config)
}
Expand All @@ -122,8 +122,8 @@ func getConfigFromFile(filePath string) (connectors.CreateConnectorRequest, erro
func init() {
RootCmd.AddCommand(createCmd)

createCmd.PersistentFlags().StringVarP(&file, "file", "f", "", "path to the config file")
createCmd.MarkFlagFilename("file")
createCmd.PersistentFlags().StringVarP(&input, "input", "i", "", "path to the config file")
createCmd.MarkFlagFilename("input")
createCmd.PersistentFlags().StringVarP(&configString, "string", "s", "", "JSON configuration string")
createCmd.PersistentFlags().BoolVarP(&sync, "sync", "y", false, "execute synchronously")

Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func RunEDeploy(cmd *cobra.Command, args []string) error {
func init() {
RootCmd.AddCommand(deployCmd)

deployCmd.PersistentFlags().StringVarP(&file, "file", "f", "", "path to the config file or folder")
deployCmd.MarkFlagFilename("file")
deployCmd.PersistentFlags().StringVarP(&input, "input", "i", "", "path to the config file or folder")
deployCmd.MarkFlagFilename("input")
deployCmd.PersistentFlags().StringVarP(&configString, "string", "s", "", "JSON configuration string")
}
2 changes: 1 addition & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
var (
url string
connector string
file string
input string
configString string
sync bool
status bool
Expand Down
8 changes: 4 additions & 4 deletions cli/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func RunEUpdate(cmd *cobra.Command, args []string) error {
func getUpdateCmdConfig(cmd *cobra.Command) (map[string]interface{}, error) {
config := map[string]interface{}{}

if cmd.Flag("file").Changed {
if cmd.Flag("input").Changed {
fileReader, err := os.Open(update.file)
if err != nil {
return config, err
Expand All @@ -78,16 +78,16 @@ func getUpdateCmdConfig(cmd *cobra.Command) (map[string]interface{}, error) {
return config, err
}
} else {
return config, errors.New("neither file nor string was supplied")
return config, errors.New("neither input nor string was supplied")
}
return config, nil
}

func init() {
RootCmd.AddCommand(updateCmd)

updateCmd.PersistentFlags().StringVarP(&update.file, "file", "f", "", "path to the config file")
updateCmd.MarkFlagFilename("file")
updateCmd.PersistentFlags().StringVarP(&update.file, "input", "i", "", "path to the config file")
updateCmd.MarkFlagFilename("input")
updateCmd.PersistentFlags().StringVarP(&update.configString, "string", "s", "", "JSON configuration string")
updateCmd.PersistentFlags().StringVarP(&update.connector, "connector", "n", "", "name of the target connector")
updateCmd.MarkFlagRequired("connector")
Expand Down