Skip to content

Commit

Permalink
Merge pull request #295 from deepgoel17/b/330606878
Browse files Browse the repository at this point in the history
Adding support to pass config variable in the publish cmd as a flag. More info b/330606878
  • Loading branch information
srinandan authored Oct 28, 2024
2 parents 0fa1e65 + 0369ab1 commit 3939d18
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions internal/cmd/integrations/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,23 @@ var PublishVerCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) (err error) {
version := cmd.Flag("ver").Value.String()
name := cmd.Flag("name").Value.String()
configVarsJson := cmd.Flag("config-vars-json").Value.String()
configVarsFile := cmd.Flag("config-vars").Value.String()
var contents []byte

if configVarsFile != "" {
if _, err := os.Stat(configVarsFile); os.IsNotExist(err) {
return err
}
if configVarsJson == "" {
if configVarsFile != "" {
if _, err := os.Stat(configVarsFile); os.IsNotExist(err) {
return err
}

contents, err = os.ReadFile(configVarsFile)
if err != nil {
return err
contents, err = os.ReadFile(configVarsFile)
if err != nil {
return err
}
}
} else {
contents = []byte(configVarsJson)
}

if version != "" {
Expand All @@ -70,7 +75,7 @@ var PublishVerCmd = &cobra.Command{
}

func init() {
var name, version, configVars string
var name, version, configVars, configVarsJson string

PublishVerCmd.Flags().StringVarP(&name, "name", "n",
"", "Integration flow name")
Expand All @@ -82,6 +87,8 @@ func init() {
"", "Integration flow snapshot number")
PublishVerCmd.Flags().StringVarP(&configVars, "config-vars", "",
"", "Path to file containing config variables")
PublishVerCmd.Flags().StringVarP(&configVarsJson, "config-vars-json", "cf",
"", "Json string containing the config variables if both Json string and file is present Json string will only be used.")

_ = PublishVerCmd.MarkFlagRequired("name")
}
Expand Down

0 comments on commit 3939d18

Please sign in to comment.