From 2ddc791a010e430330f823fba9ee57b28615540a Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 21 Aug 2026 10:00:02 +0100 Subject: [PATCH] Add verbose runner output Add a verbose flag to the runners command and request the expanded controller table so users can see each agent's operating system. Document the flag and cover its API query contract. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- README.md | 3 +++ cmd/runners.go | 10 +++++++++- cmd/upgrade.go | 2 +- pkg/client.go | 6 +++++- pkg/client_runners_test.go | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 pkg/client_runners_test.go diff --git a/README.md b/README.md index 71d8a76..1acedc3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ actuated-cli jobs actuated-samples ```bash actuated-cli runners actuated-samples + +# Include the operating system reported by each agent +actuated-cli runners --verbose actuated-samples ``` ## View SSH sessions available: diff --git a/cmd/runners.go b/cmd/runners.go index f434650..3c9a0d5 100644 --- a/cmd/runners.go +++ b/cmd/runners.go @@ -22,6 +22,9 @@ func makeRunners() *cobra.Command { # List runners for all customers actuated-cli runners --staff OWNER + # Include the operating system in the table + actuated-cli runners --verbose OWNER + # List runners in JSON format actuated-cli runners --json OWNER `, @@ -30,6 +33,7 @@ func makeRunners() *cobra.Command { cmd.RunE = runRunnersE cmd.Flags().Bool("images", false, "Show the image being used for the rootfs and Kernel") + cmd.Flags().BoolP("verbose", "v", false, "Show additional runner details") cmd.Flags().BoolP("json", "j", false, "Request output in JSON format") return cmd @@ -56,6 +60,10 @@ func runRunnersE(cmd *cobra.Command, args []string) error { if err != nil { return err } + verbose, err := cmd.Flags().GetBool("verbose") + if err != nil { + return err + } requestJson, err := cmd.Flags().GetBool("json") if err != nil { @@ -68,7 +76,7 @@ func runRunnersE(cmd *cobra.Command, args []string) error { c := pkg.NewClient(http.DefaultClient, os.Getenv("ACTUATED_URL")) - res, status, err := c.ListRunners(pat, owner, staff, images, requestJson) + res, status, err := c.ListRunners(pat, owner, staff, images, verbose, requestJson) if err != nil { return err } diff --git a/cmd/upgrade.go b/cmd/upgrade.go index 4376444..0ec14be 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -86,7 +86,7 @@ func runUpgradeE(cmd *cobra.Command, args []string) error { var upgradeHosts []Host if allHosts { includeImages := false - hosts, httpStatus, err := c.ListRunners(pat, owner, staff, includeImages, true) + hosts, httpStatus, err := c.ListRunners(pat, owner, staff, includeImages, false, true) if err != nil { return err } diff --git a/pkg/client.go b/pkg/client.go index 703d618..4fc4eeb 100644 --- a/pkg/client.go +++ b/pkg/client.go @@ -133,7 +133,7 @@ func (c *Client) GetBuildIncreases(patStr string, owner string, startDate time.T return string(body), res.StatusCode, nil } -func (c *Client) ListRunners(patStr string, owner string, staff, images, json bool) (string, int, error) { +func (c *Client) ListRunners(patStr string, owner string, staff, images, verbose, json bool) (string, int, error) { u, _ := url.Parse(c.baseURL) u.Path = "/api/v1/runners" @@ -147,6 +147,10 @@ func (c *Client) ListRunners(patStr string, owner string, staff, images, json bo q.Set("images", "1") } + if verbose { + q.Set("verbose", "1") + } + if len(owner) > 0 { q.Set("owner", owner) log.Printf("Requesting runners for owner %s", owner) diff --git a/pkg/client_runners_test.go b/pkg/client_runners_test.go new file mode 100644 index 0000000..35774cb --- /dev/null +++ b/pkg/client_runners_test.go @@ -0,0 +1,36 @@ +package pkg + +import ( + "io" + "net/http" + "net/http/httptest" + "testing" +) + +func TestListRunnersRequestsVerboseOutput(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if got, want := r.URL.Path, "/api/v1/runners"; got != want { + t.Fatalf("want path %q, got %q", want, got) + } + if got, want := r.URL.Query().Get("owner"), "alexellis"; got != want { + t.Fatalf("want owner %q, got %q", want, got) + } + if got, want := r.URL.Query().Get("verbose"), "1"; got != want { + t.Fatalf("want verbose %q, got %q", want, got) + } + if got := r.Header.Get("Accept"); got != "" { + t.Fatalf("want plain-text Accept header, got %q", got) + } + io.WriteString(w, "table") + })) + defer server.Close() + + client := NewClient(server.Client(), server.URL) + body, status, err := client.ListRunners("token", "alexellis", false, false, true, false) + if err != nil { + t.Fatal(err) + } + if status != http.StatusOK || body != "table" { + t.Fatalf("want 200 and table, got %d and %q", status, body) + } +}