Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 12 additions & 9 deletions src/cmd/cli/command/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?",
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/client/account_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading