databricks / cli

Databricks CLI
Other
132 stars 50 forks source link

Improve `bundle validate` output #1532

Closed kanterov closed 3 months ago

kanterov commented 3 months ago

Changes

This combination of changes allows pretty-printing errors happening during the "load" and "init" phases, including their locations.

Move to render code into a separate module dedicated to rendering diag.Diagnostics in a human-readable format. This will be used for the bundle deploy command.

Preserve the "bundle" value if an error occurs in mutators. Rewrite the go templates to handle the case when the bundle isn't yet loaded if an error occurs during loading, that is possible now.

Improve rendering for errors and warnings:

Add root.ErrAlreadyPrinted indicating that the error was already printed, and the CLI entry point shouldn't print it again.

Tests

Add tests for output, that are especially handy to detect extra newlines

kanterov commented 3 months ago

@pietern I've manually checked if there is a diff for warnings. There were a couple of extra new lines, and I've added tests for these cases. I also added tests in case the bundle is nil so we don't crash.

I also moved the package as you suggested. Please take a look again.