carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3import (
4 "fmt"
5 "io"
6)
7
8// printAppRegion is spec §11's one line after "created app …": nothing on
9// a single-region deployment, C13a when an older console ignored --region,
10// C13b when a console with the switch off did, else C9 to C12 by source.
11//
12// C13b is decided by the source, not by comparing codes: a console that
13// applied --region answers source "chosen", so any other source after an
14// explicit --region means it was ignored. Comparing codes misses --region
15// <the home> against a switch-off console, which answers the home itself.
16//
17// An empty region_source with a region present means the console could not
18// read the stored region back (it then answers the home with no source). That
19// says nothing about whether --region was applied, so it prints nothing: not
20// C13b, and not a C9 to C12 line that would name a source nobody knows.
21//
22// onFleet is true when the create named a fleet (--place fleet/<name>). The
23// fleet governs where its instances run, so C13b ("--region was not applied",
24// "this app's instances start in <home>") would be wrong: it prints nothing.
25func printAppRegion(w io.Writer, res apiCreateAppResult, asked string, onFleet bool) {
26 switch {
27 case res.Region == "" && res.RegionSource == "":
28 if asked != "" {
29 fmt.Fprintln(w, regionNotRecordedOldConsole)
30 }
31 case res.RegionSource == "":
32 // Region read-back failed on the console. Say nothing.
33 case asked != "" && res.RegionSource != "chosen" && onFleet:
34 // The fleet decides placement. Say nothing.
35 case asked != "" && res.RegionSource != "chosen":
36 fmt.Fprintln(w, regionNotAppliedSwitchOff(res.RegionName))
37 case res.RegionsAvailable >= 2:
38 fmt.Fprintln(w, regionCreatedLine(res.RegionName, res.RegionSource))
39 }
40}
41