package main import ( "fmt" "io" ) // printAppRegion is spec §11's one line after "created app …": nothing on // a single-region deployment, C13a when an older console ignored --region, // C13b when a console with the switch off did, else C9 to C12 by source. // // C13b is decided by the source, not by comparing codes: a console that // applied --region answers source "chosen", so any other source after an // explicit --region means it was ignored. Comparing codes misses --region // against a switch-off console, which answers the home itself. // // An empty region_source with a region present means the console could not // read the stored region back (it then answers the home with no source). That // says nothing about whether --region was applied, so it prints nothing: not // C13b, and not a C9 to C12 line that would name a source nobody knows. // // onFleet is true when the create named a fleet (--place fleet/). The // fleet governs where its instances run, so C13b ("--region was not applied", // "this app's instances start in ") would be wrong: it prints nothing. func printAppRegion(w io.Writer, res apiCreateAppResult, asked string, onFleet bool) { switch { case res.Region == "" && res.RegionSource == "": if asked != "" { fmt.Fprintln(w, regionNotRecordedOldConsole) } case res.RegionSource == "": // Region read-back failed on the console. Say nothing. case asked != "" && res.RegionSource != "chosen" && onFleet: // The fleet decides placement. Say nothing. case asked != "" && res.RegionSource != "chosen": fmt.Fprintln(w, regionNotAppliedSwitchOff(res.RegionName)) case res.RegionsAvailable >= 2: fmt.Fprintln(w, regionCreatedLine(res.RegionName, res.RegionSource)) } }