Skip to content

fleet cli json output #3559

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

0xavi0
Copy link
Contributor

@0xavi0 0xavi0 commented Apr 16, 2025

Uses a JSONFormatter in fleet cli.
It also filters out the output received from fleet cli so the error set in the conditions is only the one sent by the fleet cli code and not from any used libraries.

In order to use the json formatter we need to set the FLEET_JSON_OUTPUT env var to true. This way the command line user won't get the json output unless it's explicitly specified.

Refers to: #3234

@0xavi0 0xavi0 self-assigned this Apr 16, 2025
@0xavi0 0xavi0 force-pushed the 3234-json-output-fleet-cli branch from 1b8ba26 to 22feb32 Compare April 16, 2025 13:59
Uses a JSONFormatter in fleet cli.
It also filters out the output received from fleet cli so the error set in the conditions is only the one sent by the fleet cli code and not from any used libraries.

Refers to: rancher#3234

Signed-off-by: Xavi Garcia <[email protected]>
@0xavi0 0xavi0 force-pushed the 3234-json-output-fleet-cli branch from 22feb32 to 7ced5c9 Compare April 16, 2025 14:59
@0xavi0 0xavi0 marked this pull request as ready for review April 16, 2025 15:31
@0xavi0 0xavi0 requested a review from a team as a code owner April 16, 2025 15:31
@@ -3,6 +3,10 @@ package main

import (
// Ensure GVKs are registered
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep this comment together with the blank imports.

Status: "True",
Reason: "BackoffLimitExceeded",
Message: "Job has reached the specified backoff limit",
Message: `{"fleetErrorMessage":"fleet error message","level":"fatal","msg":"Fleet cli failed","time":"2025-04-15T14:53:15+02:00"}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Beware that message in status conditions is by definition meant to be human-readable:

❯ kubectl explain job.status.conditions.message
GROUP:      batch
KIND:       Job
VERSION:    v1

FIELD: message <string>


DESCRIPTION:
    Human readable message indicating details about last transition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants