Skip to content
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
12 changes: 10 additions & 2 deletions cli/cmd/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command {
Org: ch.Org,
}

if ch.Interactive && orgRole == "" {
hasFlags := cmd.Flags().Changed("org-role") || cmd.Flags().Changed("project-role") || cmd.Flags().Changed("project") || cmd.Flags().Changed("attributes")

if ch.Interactive && !hasFlags {
ok, err := cmdutil.YesNoPrompt("Do you want to assign an organization role to the service?", false)
if err != nil {
return err
Expand All @@ -51,7 +53,7 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command {
}
}

if ch.Interactive && projectRole == "" && !cmd.Flags().Changed("org-role") {
if ch.Interactive && !hasFlags {
ok, err := cmdutil.YesNoPrompt("Do you want to assign a project role to the service?", false)
if err != nil {
return err
Expand All @@ -72,6 +74,12 @@ func CreateCmd(ch *cmdutil.Helper) *cobra.Command {
}
}

if projectRole != "" && projectName == "" {
return fmt.Errorf("--project must be specified when --project-role is set")
}
if projectRole == "" && projectName != "" {
return fmt.Errorf("--project-role must be specified when --project is set")
}
if orgRole == "" && projectRole == "" {
return fmt.Errorf("either --org-role or --project-role must be specified")
}
Expand Down
Loading