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

Additional formatting updates for config validation #899

Conversation

wyardley
Copy link
Contributor

@wyardley wyardley commented Apr 5, 2023

Checklist

=========

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked for similar issues and haven't found anything relevant.
  • This is not a security issue (which should be reported here: https://circleci.com/security/)
  • I have read Contribution Guidelines.

Internal Checklist

  • I am requesting a review from my own team as well as the owning team
  • I have a plan in place for the monitoring of the changes that I am making (this can include new monitors, logs to be aware of, etc...)

Changes

  • Suppress some whitespace when verbose output is not enabled
  • Write to stderr again
  • Use %v instead of %s so that "number" in pipeline values gets printed correctly
  • Sort values to provide stable output order for pipeline values

Rationale

@elliotforbes sorry - I think one or both of us missed that number doesn't get printed out right when %s is used vs %v. This also moves most of the verbose output to stderr (esp. could be an issue for subcommands that output yaml otherwise). It also gets rid of the extra newline before validate output in the case where verbose output is not used

See #860 for original context. Resolve some issues from #861 and #896

Considerations

Screenshots

============

Before

image

After

image

Here are some helpful tips you can follow when submitting a pull request:

  1. Fork the repository and create your branch from main.
  2. Run make build in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (make test).
  5. The --debug flag is often helpful for debugging HTTP client requests and responses.
  6. Format your code with gofmt.
  7. Make sure your code lints (make lint). Note: This requires Docker to run inside a local job.

@wyardley wyardley requested a review from a team as a code owner April 5, 2023 03:04
// Provide a stable sort order for printed values
keys := make([]string, 0, len(values))
for k := range values {
keys = append(keys, k)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

open to suggestion here; I didn't find a way to do this in place for the original map.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine - it's nice and explicit what's going on and we're not necessarily resource constrained here

Resolve some issues from CircleCI-Public#861 and CircleCI-Public#896

- Suppress some whitespace when verbose output is not enabled
- Write to stderr again
- Use "%v" instead of "%s" so that "number" in pipeline values gets
  printed correctly
- Sort values to provide stable output order for pipeline values
@wyardley wyardley force-pushed the wyardley/config-values-again branch from d5ddf96 to cb2d3e6 Compare April 5, 2023 03:08
}
sort.Strings(keys)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nice improvement 👌🏼

Copy link
Contributor

@JulesFaucherre JulesFaucherre left a comment

Choose a reason for hiding this comment

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

Great improvement, thanks a lot!

@JulesFaucherre JulesFaucherre merged commit 71298be into CircleCI-Public:develop Apr 5, 2023
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.

3 participants