Skip to content

Commit

Permalink
Add images to runners output
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Dec 1, 2023
1 parent 68d4e58 commit cac787c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cmd/runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ func makeRunners() *cobra.Command {

cmd.RunE = runRunnersE

cmd.Flags().Bool("images", false, "Show the image being used for the rootfs and Kernel")
cmd.Flags().Bool("json", false, "Request output in JSON format")

return cmd
}

func runRunnersE(cmd *cobra.Command, args []string) error {

images, err := cmd.Flags().GetBool("images")
if err != nil {
return err
}

var owner string
if len(args) == 1 {
owner = strings.TrimSpace(args[0])
Expand All @@ -62,7 +68,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, requestJson)
res, status, err := c.ListRunners(pat, owner, staff, images, requestJson)

if err != nil {
return err
Expand Down
3 changes: 2 additions & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func runUpgradeE(cmd *cobra.Command, args []string) error {

var upgradeHosts []Host
if allHosts {
hosts, httpStatus, err := c.ListRunners(pat, owner, staff, true)
includeImages := false
hosts, httpStatus, err := c.ListRunners(pat, owner, staff, includeImages, true)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *Client) ListJobs(patStr string, owner string, staff bool, json bool) (s
return string(body), res.StatusCode, nil
}

func (c *Client) ListRunners(patStr string, owner string, staff bool, json bool) (string, int, error) {
func (c *Client) ListRunners(patStr string, owner string, staff, images, json bool) (string, int, error) {

u, _ := url.Parse(c.baseURL)
u.Path = "/api/v1/runners"
Expand All @@ -86,6 +86,10 @@ func (c *Client) ListRunners(patStr string, owner string, staff bool, json bool)
q.Set("staff", "1")
}

if images {
q.Set("image", "1")
}

if len(owner) > 0 {
q.Set("owner", owner)
log.Printf("Requesting runners for owner %s", owner)
Expand Down

0 comments on commit cac787c

Please sign in to comment.