| 1 | package main |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | // The nearest-region CLI strings (spec §19 and this plan's additions), as |
| 6 | // approved in the nearest-region copy record. Change none of them without a |
| 7 | // new copy review. |
| 8 | |
| 9 | // regionCreatedLine is C9 to C12, by source word; anything else reads as the |
| 10 | // default. |
| 11 | func regionCreatedLine(place, source string) string { |
| 12 | switch source { |
| 13 | case "timezone": |
| 14 | return fmt.Sprintf("Region: %s (from your timezone). Use --region to choose another.", place) |
| 15 | case "ip": |
| 16 | return fmt.Sprintf("Region: %s (from your network location). Use --region to choose another.", place) |
| 17 | case "chosen": |
| 18 | return fmt.Sprintf("Region: %s.", place) |
| 19 | } |
| 20 | return fmt.Sprintf("Region: %s (the platform default). Use --region to choose another.", place) |
| 21 | } |
| 22 | |
| 23 | // regionNotRecordedOldConsole is C13a. |
| 24 | const regionNotRecordedOldConsole = "This console does not record an app region yet, so --region was not applied." |
| 25 | |
| 26 | // regionNotAppliedSwitchOff is C13b. |
| 27 | func regionNotAppliedSwitchOff(place string) string { |
| 28 | return fmt.Sprintf("This console is not assigning app regions yet, so --region was not applied. This app's instances start in %s.", place) |
| 29 | } |
| 30 | |
| 31 | // instanceCreatedSuffix is C14: the parenthesis content of |
| 32 | // "created instance {host} (...)". |
| 33 | func instanceCreatedSuffix(channel, place string) string { |
| 34 | return fmt.Sprintf("channel %s, %s", channel, place) |
| 35 | } |
| 36 | |
| 37 | // deployRegionMismatch is C15, or C15.nohome when the console has no named |
| 38 | // home region to put in the place. |
| 39 | func deployRegionMismatch(app, place string) string { |
| 40 | if place == "" { |
| 41 | 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) |
| 42 | } |
| 43 | 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) |
| 44 | } |
| 45 | |
| 46 | // deployRegionUnreadable is C15b: deploy stops when it cannot read the app's |
| 47 | // region. |
| 48 | func deployRegionUnreadable(app string, err error) string { |
| 49 | return fmt.Sprintf("could not read %s's region (%v), so deploy stopped before shipping anything. Try again, or run without --region.", app, err) |
| 50 | } |
| 51 | |
| 52 | // deployRegionUnknown is C15c: the console answered, but could not read the |
| 53 | // app's region. |
| 54 | func deployRegionUnknown(app string) string { |
| 55 | return fmt.Sprintf("the console could not read %s's region, so deploy stopped before shipping anything. Try again, or run without --region.", app) |
| 56 | } |
| 57 | |
| 58 | // canaryRegionMismatch is C25, or C25.nohome when the console has no named |
| 59 | // home region to put in the place. |
| 60 | func canaryRegionMismatch(host, place string) string { |
| 61 | if place == "" { |
| 62 | 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) |
| 63 | } |
| 64 | 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) |
| 65 | } |
| 66 | |
| 67 | // canaryRegionOnFleet is C30. |
| 68 | func canaryRegionOnFleet(app, fleet string) string { |
| 69 | 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) |
| 70 | } |
| 71 | |
| 72 | // canaryFleetUnknown is C30b: an older console cannot say whether a fleet |
| 73 | // governs. |
| 74 | func canaryFleetUnknown(app string) string { |
| 75 | 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) |
| 76 | } |
| 77 | |
| 78 | // canaryRegionUnconfirmed is C30c: the canary's own record could not be read, |
| 79 | // so whether it already runs elsewhere is unknown. |
| 80 | func canaryRegionUnconfirmed(name string) string { |
| 81 | return fmt.Sprintf("could not confirm where canary %s runs, so nothing was changed. Try again, or run the command without --region.", name) |
| 82 | } |
| 83 | |
| 84 | // C22a to C22d: flag help. |
| 85 | const ( |
| 86 | flagRegionAppsCreate = "region this app's instances start in (default: the region nearest you)" |
| 87 | flagRegionDeploy = "region for the app this deploy creates (default: the region nearest you)" |
| 88 | flagRegionCanary = "region for the canary instance (default: the app's region)" |
| 89 | flagRegionInstancesCreate = "region for this instance (default: the app's region, subject to the manifest's allow-list)" |
| 90 | ) |
| 91 | |