Skip to content

Add --json/-j to most get/list commands - #1026

Merged
alexellis merged 5 commits into
masterfrom
json_flag
Jun 16, 2026
Merged

Add --json/-j to most get/list commands#1026
alexellis merged 5 commits into
masterfrom
json_flag

Bump GHA actions versions

8c6a3e3
Select commit
Loading
Failed to load commit list.
reviewfn / succeeded Jun 16, 2026 in 3m 21s

AI Code Review Results

AI Pull Request Overview

Disclaimer: This review was generated by automated AI and may contain errors. Do not trust its outputs without human verification.

Summary

  • Adds --json/-j output to several function, secret, store, template, namespace, log, and version commands.
  • Adds tests for selected JSON output and TLS warning behavior.
  • Updates Docker GitHub Actions versions and the Docker build image version.
  • Adds AGENTS.md with repository guidance for agent-based contributors.
  • Most JSON paths are straightforward marshal-and-print conversions over existing response structs.
  • The namespace JSON path still has stdout contamination and command coverage gaps.

Approval rating (1-10)

7/10. The feature is useful, but namespace JSON output needs fixes before it is reliable across supported namespace-listing entry points.

Summary per file

Summary per file
File path Summary
.github/workflows/build.yaml Bumps Docker setup and build action versions.
.github/workflows/publish.yaml Bumps Docker setup, login, and build action versions.
AGENTS.md Adds agent contribution guidance for the repository.
Dockerfile Bumps builder image from Go 1.25 to Go 1.26.
commands/describe.go Adds JSON output for function descriptions.
commands/generate.go Reindents Cobra examples.
commands/json_output_test.go Adds tests for JSON stdout and TLS warning behavior.
commands/list.go Adds JSON output for function lists.
commands/logs.go Adds --json alias for JSON log formatting.
commands/namespaces_list.go Adds JSON output for namespace list.
commands/plugin_get.go Reindents Cobra examples.
commands/publish.go Reindents Cobra examples.
commands/ready.go Reindents Cobra examples.
commands/secret_generate.go Adds gen alias and omits newline when piped.
commands/secret_list.go Adds JSON output for secret lists.
commands/secret_remove.go Reindents Cobra examples.
commands/secret_unseal.go Adds JSON output for unsealed secrets.
commands/secret_update.go Reindents Cobra examples.
commands/store_describe.go Adds JSON output for store function details.
commands/store_list.go Adds JSON output for store function lists.
commands/template_store_describe.go Adds JSON output for template details.
commands/template_store_list.go Adds JSON output for template lists.
commands/version.go Adds structured JSON version output.

Overall Assessment

The implementation mostly follows the existing command structure and keeps the text output paths intact. The main issue is that namespace JSON support is incomplete: namespace list --json can still emit non-JSON text before the JSON payload, and the older top-level namespaces listing command does not accept the new flag. I could not run the Go tests because the go binary is not installed in this environment.

Detailed Review

Detailed Review

Findings

Medium: namespace list --json can emit auth lookup text before the JSON payload

commands/namespaces_list.go:44-54 calls GetDefaultSDKClient() before printing JSON. That helper currently writes Failed to lookup auth config: ... to stdout when no CLI auth config exists, even if the user supplies --token. With this PR, a common first-run command such as faas-cli namespace list --json --token "$TOKEN" can produce stdout like:

Failed to lookup auth config: ...
[
  "openfaas-fn"
]

That breaks the primary contract of --json, because stdout is no longer parseable JSON. The new tests cover TLS warning suppression for some JSON commands, but this namespace path has a different stdout contaminant.

Route auth lookup warnings to stderr, suppress expected missing-config errors when a token is provided, or make GetDefaultSDKClient() return the warning so runNamespaces can avoid writing any non-JSON stdout when jsonOutput is set.

Medium: The existing top-level namespaces list command does not get --json

commands/namespaces_list.go:14-17 registers the new JSON flag only on namespaceListCmd, while the same file still exposes the older top-level namespaces command at commands/namespaces_list.go:20-30 and routes it through the same runNamespaces function. As a result, faas-cli namespace list --json works, but faas-cli namespaces --json fails with an unknown flag even though both commands list namespaces.

This is inconsistent with the PR goal of adding structured output to get/list commands and leaves an existing namespace-listing entry point behind. Add the same --json flag to namespacesCmd, or make namespaces an alias/subcommand path that shares the flag behavior.

AI agent details.

Agent processing time: 3m3.027s
Environment preparation time: 12.018s
Total time from webhook: 3m26.851s