Skip to content
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

Feature/improve output #516

Merged
merged 3 commits into from
Dec 2, 2016
Merged

Feature/improve output #516

merged 3 commits into from
Dec 2, 2016

Conversation

arichardet
Copy link
Contributor

Improve output, specifically errors/cascading errors due to an error in a dependency.

Changes:

  • Do not draw nodes of dependency errors
  • In the summary, list dependency errors if any
  • Only sum the changes if the change does not have an associated error/dependency error

Fixes #367

@arichardet arichardet force-pushed the feature/improve-output branch 4 times, most recently from 4c516a6 to 4dd5d3d Compare November 28, 2016 16:08
@arichardet arichardet added this to the 0.5.0 milestone Nov 28, 2016
@@ -70,14 +70,15 @@ func (p *Printer) StartPP(g *graph.Graph) (pp.Renderable, error) {

// FinishPP provides summary statistics about the printed graph
func (p *Printer) FinishPP(g *graph.Graph) (pp.Renderable, error) {
tmpl, err := p.template("{{if gt (len .Errors) 0}}{{red \"Summary\"}}{{else}}{{green \"Summary\"}}{{end}}: {{len .Errors}} errors, {{.ChangesCount}} changes{{if .Errors}}\n{{range .Errors}}\n * {{.}}{{end}}{{end}}\n")
tmpl, err := p.template("{{if .Errors}}Errors:\n{{range .Errors}} * {{.}}\n{{end}}\n{{end}}{{if .DependencyErrors}}Failed due to failing dependency:\n{{range .DependencyErrors}} * {{.}}\n{{end}}\n{{end}}{{if gt (len .Errors) 0}}{{red \"Summary\"}}{{else}}{{green \"Summary\"}}{{end}}: {{len .Errors}} errors, {{.ChangesCount}} changes{{if .DependencyErrors}}, {{len .DependencyErrors}} dependency errors{{end}}\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more readable if this were broken up into multiple lines as long as that doesn't break anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can avoid newlines by putting a - before or after braces. {{- .}} would print the dot value and trim all whitespace characters before, {{. -}} would do the same but after. You do both, too. :)

@BrianHicks
Copy link
Contributor

What does the output look like now? Does this need to update the docs with the new format?

@arichardet
Copy link
Contributor Author

Output is unchanged if there are no errors or dependency errors. With this PR we draw the nodes that have changes, then once we encounter an error we draw that node; any nodes that depend on that failed node are not drawn (and are no longer counted as changes either).

Here is sample output of running samples/testdata/cert.hcl

Here we have only an error:

root/task.key:
 Messages:
  check (returned: 1)


 Has Changes: yes
 Changes: No changes

root/task.csr:
 Messages:
  check (returned: 1)


 Has Changes: yes
 Changes: No changes

root/task.crt:
 Error: exec: "blah": executable file not found in $PATH
 Messages:
 Has Changes: no
 Changes: No changes

root/task.directory:
 Messages:
  check (returned: 1)


 Has Changes: yes
 Changes: No changes

Errors:
 * root/task.crt: exec: "blah": executable file not found in $PATH

Summary: 1 errors, 3 changes

The next two are sample output with both errors and dependency errors:

root/task.directory:
 Error: exec: "blah": executable file not found in $PATH
 Messages:
 Has Changes: no
 Changes: No changes

Errors:
 * root/task.directory: exec: "blah": executable file not found in $PATH

Failed due to failing dependency:
 * root/task.key: error in dependency "root/task.directory"
 * root/task.csr: error in dependency "root/task.key"
 * root/task.crt: error in dependency "root/task.csr"

Summary: 1 errors, 0 changes, 3 dependency errors
root/task.csr:
 Error: exec: "blah": executable file not found in $PATH
 Messages:
 Has Changes: no
 Changes: No changes

root/task.key:
 Messages:
  check (returned: 1)


 Has Changes: yes
 Changes: No changes

root/task.directory:
 Messages:
  check (returned: 1)


 Has Changes: yes
 Changes: No changes

Errors:
 * root/task.csr: exec: "blah": executable file not found in $PATH

Failed due to failing dependency:
 * root/task.crt: error in dependency "root/task.csr"

Summary: 1 errors, 2 changes, 1 dependency errors

@rebeccaskinner rebeccaskinner merged commit 8a14bb0 into master Dec 2, 2016
@rebeccaskinner rebeccaskinner deleted the feature/improve-output branch December 2, 2016 17:11
BrianHicks pushed a commit that referenced this pull request Dec 22, 2016
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.

3 participants