Skip to content

Commit

Permalink
OCM-12922 | fix: Fixing manual-mode + log event output
Browse files Browse the repository at this point in the history
  • Loading branch information
den-rgb authored and openshift-cherrypick-robot committed Dec 4, 2024
1 parent d26a65a commit 270b606
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
16 changes: 8 additions & 8 deletions cmd/create/network/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,31 @@ func NetworkRunner(userOptions *opts.NetworkUserOptions) rosa.CommandRunner {
if err != nil {
return err
}

service := helper.NewNetworkService()

mode, err := interactive.GetMode()
if err != nil {
return err
}

defaultTemplateUsed := templateCommand == defaultTemplate
switch mode {
case interactive.ModeManual:
r.Reporter.Infof(helper.ManualModeHelperMessage(parsedParams, templateFile, parsedTags))
r.Reporter.Infof(helper.ManualModeHelperMessage(parsedParams, parsedTags))
r.OCMClient.LogEvent("ROSANetworkStackManual",
map[string]string{
ocm.Account: r.Creator.AccountID,
ocm.Organization: orgID,
"template": templateFile,
ocm.Account: r.Creator.AccountID,
ocm.Organization: orgID,
"default-template": fmt.Sprintf("%t", defaultTemplateUsed),
},
)
return nil
default:
r.OCMClient.LogEvent("ROSANetworkStack",
map[string]string{
ocm.Account: r.Creator.AccountID,
ocm.Organization: orgID,
"template": templateFile,
ocm.Account: r.Creator.AccountID,
ocm.Organization: orgID,
"default-template": fmt.Sprintf("%t", defaultTemplateUsed),
},
)
return service.CreateStack(&templateFile, &templateBody, parsedParams, parsedTags)
Expand Down
8 changes: 4 additions & 4 deletions pkg/network/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ func deleteHelperMessage(logger *logrus.Logger, params map[string]string, err er
params["Name"], params["Region"])
}

func ManualModeHelperMessage(params map[string]string,
templateFile string, tags map[string]string) string {
func ManualModeHelperMessage(params map[string]string, tags map[string]string) string {
return fmt.Sprintf("Run the following command to create the stack manually:\n"+
"aws cloudformation create-stack --stack-name %s --template-body file://%s --param %s --tags %s --region %s",
params["Name"], templateFile, formatParams(params), formatTags(tags), params["Region"])
"aws cloudformation create-stack --stack-name %s --template-body file://<template-file-path>"+
" --param %s --tags %s --region %s",
params["Name"], formatParams(params), formatTags(tags), params["Region"])
}
5 changes: 2 additions & 3 deletions pkg/network/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,15 @@ var _ = Describe("Helper Functions", func() {
"Name": "test-stack",
"Region": "us-west-1",
}
templateFile := "test-template.yaml"
tags := map[string]string{
"TagKey1": "TagValue1",
"TagKey2": "TagValue2",
}
expectedMessage := "Run the following command to create the stack manually:\n" +
"aws cloudformation create-stack --stack-name test-stack --template-body file://test-template.yaml " +
"aws cloudformation create-stack --stack-name test-stack --template-body file://<template-file-path> " +
"--param ParameterKey=Name,ParameterValue=test-stack ParameterKey=Region,ParameterValue=us-west-1 " +
" --tags Key=TagKey1,Value=TagValue1 Key=TagKey2,Value=TagValue2 --region us-west-1"
Expect(ManualModeHelperMessage(params, templateFile, tags)).To(Equal(expectedMessage))
Expect(ManualModeHelperMessage(params, tags)).To(Equal(expectedMessage))
})
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (s *network) CreateStack(templateFile *string, templateBody *[]byte,
})
if err != nil {
deleteHelperMessage(logger, params, err)
helperMsg := ManualModeHelperMessage(params, template, tags)
helperMsg := ManualModeHelperMessage(params, tags)
logger.Infof(helperMsg)
return fmt.Errorf("failed to wait for stack creation, %v", err)
}
Expand Down

0 comments on commit 270b606

Please sign in to comment.