diff --git a/src/cmd/cli/command/compose.go b/src/cmd/cli/command/compose.go index 140000862..a98bc68f6 100644 --- a/src/cmd/cli/command/compose.go +++ b/src/cmd/cli/command/compose.go @@ -229,19 +229,22 @@ func handleExistingDeployments(existingDeployments []*defangv1.Deployment, accou return nil } -func confirmDeploymentToNewLocation(projectName string, existingDeployments []*defangv1.Deployment) error { - if global.NonInteractive { - term.Warnf("Project appears to be already deployed elsewhere. Use `defang deployments --project-name=%q` to view all deployments.", projectName) - return nil - } - term.Warn("This project has already deployed elsewhere:") - help := "" +func printExistingDeployments(existingDeployments []*defangv1.Deployment) { + term.Info("This project has already deployed to the following locations:") + deploymentStrings := make([]string, 0, len(existingDeployments)) for _, dep := range existingDeployments { var providerId cliClient.ProviderID providerId.SetValue(dep.Provider) - help += fmt.Sprintf("\n - %v", cliClient.AccountInfo{Provider: providerId, AccountID: dep.ProviderAccountId, Region: dep.Region}) + deploymentStrings = append(deploymentStrings, fmt.Sprintf(" - %v", cliClient.AccountInfo{Provider: providerId, AccountID: dep.ProviderAccountId, Region: dep.Region})) } - term.Println(help) + // sort and remove duplicates + slices.Sort(deploymentStrings) + deploymentStrings = slices.Compact(deploymentStrings) + term.Println(strings.Join(deploymentStrings, "\n")) +} + +func confirmDeploymentToNewLocation(projectName string, existingDeployments []*defangv1.Deployment) error { + printExistingDeployments(existingDeployments) var confirm bool if err := survey.AskOne(&survey.Confirm{ Message: "Are you sure you want to continue?", diff --git a/src/pkg/cli/client/account_info.go b/src/pkg/cli/client/account_info.go index 02da769fd..acd14f0e3 100644 --- a/src/pkg/cli/client/account_info.go +++ b/src/pkg/cli/client/account_info.go @@ -12,7 +12,7 @@ type AccountInfo struct { func (a AccountInfo) String() string { str := fmt.Sprintf("%s account %q", a.Provider.Name(), a.AccountID) if a.Region != "" { - str += " in region %s" + a.Region + str += " in " + a.Region } return str }