Skip to content

Commit

Permalink
OCM-12486 | fix: Fixed network command to be able to run custom templ…
Browse files Browse the repository at this point in the history
…ates
  • Loading branch information
den-rgb committed Nov 13, 2024
1 parent b1a0b95 commit 9247d9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/create/network/cloudformation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package network
const CloudFormationTemplateFile = `
AWSTemplateFormatVersion: '2010-09-09'
Description: CloudFormation template to create a ROSA Quickstart default VPC.
This CloudFormation template may not work with rosa CLI versions later than 1.2.47.
This CloudFormation template may not work with rosa CLI versions later than v1.2.48.
Please ensure that you are using the compatible CLI version before deploying this template.
Parameters:
Expand Down
13 changes: 11 additions & 2 deletions cmd/create/network/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ func NetworkRunner(userOptions *opts.NetworkUserOptions) rosa.CommandRunner {
parsedParams["Region"] = r.AWSClient.GetRegion()
}

extractTemplateCommand(r, argv, options.args,
err = extractTemplateCommand(r, argv, options.args,
&templateCommand, &templateFile)
if err != nil {
return err
}

service := helper.NewNetworkService()

Expand Down Expand Up @@ -136,7 +139,7 @@ func NetworkRunner(userOptions *opts.NetworkUserOptions) rosa.CommandRunner {
}

func extractTemplateCommand(r *rosa.Runtime, argv []string, options *opts.NetworkUserOptions,
templateCommand *string, templateFile *string) {
templateCommand *string, templateFile *string) error {
if len(argv) == 0 {
r.Reporter.Infof("No template name provided in the command. "+
"Defaulting to %s. Please note that a corresponding directory with this name"+
Expand All @@ -157,5 +160,11 @@ func extractTemplateCommand(r *rosa.Runtime, argv []string, options *opts.Networ
} else {
templateDir := options.TemplateDir
*templateFile = helper.SelectTemplate(templateDir, *templateCommand)
templateBody, err := os.ReadFile(*templateFile)
if err != nil {
return fmt.Errorf("failed to read template file: %w", err)
}
*templateFile = string(templateBody)
}
return nil
}

0 comments on commit 9247d9c

Please sign in to comment.