diff --git a/internal/cli/iam/projects/create.go b/internal/cli/iam/projects/create.go index 197ae8a036..c6acf5b8b2 100644 --- a/internal/cli/iam/projects/create.go +++ b/internal/cli/iam/projects/create.go @@ -24,7 +24,7 @@ import ( "github.com/spf13/cobra" ) -var createTemplate = "Project '{{.ID}}' created.\n" +const atlasCreateTemplate = "Project '{{.ID}}' created.\n" type CreateOpts struct { cli.GlobalOpts @@ -49,9 +49,6 @@ func (opts *CreateOpts) Run() error { if err != nil { return err } - if config.Service() != config.CloudService { - createTemplate += "Agent API Key: '{{.AgentAPIKey}}'\n" - } return opts.Print(r) } @@ -59,13 +56,16 @@ func (opts *CreateOpts) Run() error { // mongocli iam project(s) create [--orgId orgId]. func CreateBuilder() *cobra.Command { opts := &CreateOpts{} - opts.Template = createTemplate + opts.Template = atlasCreateTemplate cmd := &cobra.Command{ Use: "create ", Short: "Create a project.", Args: require.ExactArgs(1), PreRunE: func(cmd *cobra.Command, args []string) error { opts.OutWriter = cmd.OutOrStdout() + if config.Service() != config.CloudService { + opts.Template += "Agent API Key: '{{.AgentAPIKey}}'\n" + } return opts.init() }, RunE: func(cmd *cobra.Command, args []string) error {