8000 Add JSON/YAML output options to namespace list by codyjlandstrom · Pull Request #4719 · okteto/okteto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add JSON/YAML output options to namespace list #4719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

codyjlandstrom
Copy link
Contributor

Summary

  • support --output flag for okteto namespace list
  • implement JSON and YAML output modes
  • add unit tests for new functions

Testing

  • make test (fails: cannot download modules)

ifbyol added 3 commits May 21, 2025 18:02
…in output, and fixed unit tests

Signed-off-by: Nacho Fuertes <nacho@okteto.com>
Signed-off-by: Nacho Fuertes <nacho@okteto.com>
Signed-off-by: Nacho Fuertes <nacho@okteto.com>
@ifbyol
Copy link
Member
ifbyol commented May 21, 2025

Tests done:

Sample of plain output

Namespace   Status
ifbyol *    Active
jlopezbarb  Sleeping

Sample with JSON output:

[
 {
  "namespace": "ifbyol",
  "status": "Active",
  "current": true
 },
 {
  "namespace": "jlopezbarb",
  "status": "Sleeping",
  "current": false
 }
]

Sample with YAML output:

- namespace: ifbyol
  status: Active
  current: true
- namespace: jlopezbarb
  status: Sleeping
  current: false

Output when wrong output option is specified (the same that happens with namespace list command):

X Output format is not accepted. Value must be one of: ['json', 'yaml']

@ifbyol ifbyol requested a review from Copilot May 22, 2025 08:07
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for JSON/YAML output modes to the okteto namespace list command, including flag parsing, output formatting, and corresponding unit tests.

  • Introduces a new --output flag with validation for json and yaml
  • Implements displayListNamespaces and getNamespaceOutput to render in table, JSON, or YAML
  • Adds unit tests for output validation and formatted output cases

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
cmd/namespace/list.go Add --output flag, validate formats, implement JSON/YAML/table output functions
cmd/namespace/list_test.go Update existing test for new signature and add tests for validateNamespaceListOutput and displayListNamespaces
Comments suppressed due to low confidence (1)

cmd/namespace/list_test.go:78

  • Add a test case that calls executeListNamespaces with an invalid format (for example, "xml") to assert that it returns errInvalidOutput.
err := nsCmd.executeListNamespaces(ctx, "")

Signed-off-by: Nacho Fuertes <nacho@okteto.com>
@ifbyol
Copy link
Member
ifbyol commented May 23, 2025

Closing in favor of #4722 to make the CI pass as CI secrets are not injected on PRs coming from a fork

@ifbyol ifbyol closed this May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Okteto namespace list outputting options
2 participants
0