Skip to content

Commands print non-json warning when output set to json #1015

@MichaelHindley

Description

@MichaelHindley

When using the list command(and others it seems) always print the warning.

This makes it very hard to programatically do things based on for instance json output, since the json output is not valid json due to the warning that is always printed, introducing parsing logic for the warning before working with the json output.

➜  k8s git:(main) ✗ dapr list -k --namespace default -o json
⚠  In future releases, this command will only query the "default" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.
{
  "namespace": "default",
  "appId": "bakery",
  "appPort": "8080",
  "age": "16h",
  "created": "2022-06-29 18:01.58"
}

SyntaxError: Unexpected token ⚠ in JSON at position 0

Suggestion: If namespace is provided to the command, or json output requested, disable the warning from printing.
Or add a flag to disable the warning (--no-warning) or similar.

print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.")

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions