okteto / okteto

Develop your applications directly in your Kubernetes Cluster
https://okteto.com
Apache License 2.0
3.24k stars 314 forks source link

Incorrect JSON output in `okteto deploy` #2071

Closed maroshii closed 2 years ago

maroshii commented 2 years ago

Describe the bug okteto deploy -o json should send all output in json format. There are a few lines that are not in json which makes it hard to parse the output:

$ okteto deploy -o json
 i  Using maroshii @ cloud.okteto.com as context
{"level":"info","stage":"okteto build -t okteto.dev/api:${OKTETO_GIT_COMMIT} api","message":" i  Running your build in tcp://addr:1234...","timestamp":1639512885}
{"level":"info","stage":"okteto build -t okteto.dev/api:${OKTETO_GIT_COMMIT} api","message":"#2 [internal] load .dockerignore","timestamp":1639512886}
...
{"level":"info","stage":"helm upgrade --install catalog chart --set tag=${OKTETO_GIT_COMMIT}","message":"TEST SUITE: None","timestamp":1639513441}
 i  Endpoints available:
  - https://catalog-chart-maroshii...
  - https://catalog-chart-maroshii...

Expected behavior Either add a --silent option or send the output in json as the other lines with an empty stage (so it can be easily omitted on the other side)

maroshii commented 2 years ago

This also happens for errors:

{"level":"info","stage":"helm upgrade --install movies chart --set tag=${OKTETO_GIT_COMMIT}","message":"Release \"movies\" does not exist. Installing it now.","timestamp":1639588299}
 x  Error executing command 'helm upgrade --install movies chart --set tag=${OKTETO_GIT_COMMIT}': exit status 1

Which doesn't allow correctly parsing error lines.

maroshii commented 2 years ago

For errors we should probably set stage="error" or keep the previous stage if possible. For non important lines that are not part of a stage we can probably go with stage=""