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 "context"
5 "flag"
6 "fmt"
7 "log"
8 "net/http"
9 "os"
10)
11
12// runSystemSeedsFloorVerb is `carlos system seeds-floor publish`
13// (seeded-instances spec §3.3, §10 step 2).
14func runSystemSeedsFloorVerb(rest []string) {
15 if len(rest) == 0 || rest[0] != "publish" {
16 systemUsage()
17 os.Exit(2)
18 }
19 fs := flag.NewFlagSet("system seeds-floor publish", flag.ExitOnError)
20 consoleFlag := consoleOption(fs, "console origin (default: the only logged-in one)")
21 minRelease := fs.String("min-release", "", "the first release whose boxes can place a seed, such as v0.27.0")
22 fs.Parse(rest[1:])
23 if *minRelease == "" || fs.NArg() != 0 {
24 fs.Usage()
25 os.Exit(2)
26 }
27 sess := requireDeployAPISession(*consoleFlag)
28 printUsing(stdout, sess)
29 status, body, err := sess.postJSON(context.Background(), "/api/cli/system/seeds-floor", map[string]string{"min_release": *minRelease})
30 if err != nil {
31 log.Fatalf("carlos system seeds-floor publish: %v", err)
32 }
33 if status != http.StatusOK {
34 log.Fatalf("carlos system seeds-floor publish: %v", apiErrorFromBody(status, body))
35 }
36 fmt.Fprintln(stdout, fmt.Sprintf("published the seeds floor at %s. Every box arms it within the hour.", *minRelease))
37}
38