package main import "fmt" // The nearest-region CLI strings (spec ยง19 and this plan's additions), as // approved in the nearest-region copy record. Change none of them without a // new copy review. // regionCreatedLine is C9 to C12, by source word; anything else reads as the // default. func regionCreatedLine(place, source string) string { switch source { case "timezone": return fmt.Sprintf("Region: %s (from your timezone). Use --region to choose another.", place) case "ip": return fmt.Sprintf("Region: %s (from your network location). Use --region to choose another.", place) case "chosen": return fmt.Sprintf("Region: %s.", place) } return fmt.Sprintf("Region: %s (the platform default). Use --region to choose another.", place) } // regionNotRecordedOldConsole is C13a. const regionNotRecordedOldConsole = "This console does not record an app region yet, so --region was not applied." // regionNotAppliedSwitchOff is C13b. func regionNotAppliedSwitchOff(place string) string { return fmt.Sprintf("This console is not assigning app regions yet, so --region was not applied. This app's instances start in %s.", place) } // instanceCreatedSuffix is C14: the parenthesis content of // "created instance {host} (...)". func instanceCreatedSuffix(channel, place string) string { return fmt.Sprintf("channel %s, %s", channel, place) } // deployRegionMismatch is C15, or C15.nohome when the console has no named // home region to put in the place. func deployRegionMismatch(app, place string) string { if place == "" { return fmt.Sprintf("%s already runs in the home region. --region only applies when deploy creates an app. To place one instance elsewhere, use carlos instances create --region.", app) } return fmt.Sprintf("%s already runs in %s. --region only applies when deploy creates an app. To place one instance elsewhere, use carlos instances create --region.", app, place) } // deployRegionUnreadable is C15b: deploy stops when it cannot read the app's // region. func deployRegionUnreadable(app string, err error) string { return fmt.Sprintf("could not read %s's region (%v), so deploy stopped before shipping anything. Try again, or run without --region.", app, err) } // deployRegionUnknown is C15c: the console answered, but could not read the // app's region. func deployRegionUnknown(app string) string { return fmt.Sprintf("the console could not read %s's region, so deploy stopped before shipping anything. Try again, or run without --region.", app) } // canaryRegionMismatch is C25, or C25.nohome when the console has no named // home region to put in the place. func canaryRegionMismatch(host, place string) string { if place == "" { return fmt.Sprintf("canary %s already runs in the home region. --region applies only when canary creates the host. Run carlos canary rm first to start it somewhere else.", host) } return fmt.Sprintf("canary %s already runs in %s. --region applies only when canary creates the host. Run carlos canary rm first to start it somewhere else.", host, place) } // canaryRegionOnFleet is C30. func canaryRegionOnFleet(app, fleet string) string { return fmt.Sprintf("%s runs on your fleet %s, which decides where every instance runs, so --region does not apply. Run the command without --region.", app, fleet) } // canaryFleetUnknown is C30b: an older console cannot say whether a fleet // governs. func canaryFleetUnknown(app string) string { return fmt.Sprintf("this console can't say where %s's instances run, so --region can't be checked. Update the console, or run the command without --region.", app) } // canaryRegionUnconfirmed is C30c: the canary's own record could not be read, // so whether it already runs elsewhere is unknown. func canaryRegionUnconfirmed(name string) string { return fmt.Sprintf("could not confirm where canary %s runs, so nothing was changed. Try again, or run the command without --region.", name) } // C22a to C22d: flag help. const ( flagRegionAppsCreate = "region this app's instances start in (default: the region nearest you)" flagRegionDeploy = "region for the app this deploy creates (default: the region nearest you)" flagRegionCanary = "region for the canary instance (default: the app's region)" flagRegionInstancesCreate = "region for this instance (default: the app's region, subject to the manifest's allow-list)" )