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

Adding support to pass config variable in the publish cmd as a flag. More info b/330606878 #295

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading