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

feat(builder): Introduce templating for prereq commands #187

Merged
merged 5 commits into from Feb 7, 2022
Merged

Conversation

javorszky
Copy link
Contributor

Closes #123

Adds templating to prerequisite commands

  • moves the logic to do that onto the Prereq struct and out of the builder
  • adds tests
  • adds make target for easier local vendoring (not related to functionality)
  • reorders imports

Copy link
Contributor

@ospencer ospencer left a comment

Choose a reason for hiding this comment

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

This looks great, and tests look handy too! As for the PR title, the scopes typically relate to the subparts of that particular project, usually the folder it's in. In this case, it'd be feat(builder). We don't yet have any of the automation set up that ties any of it together, but that'll be coming soon!

outputLog, err := util.RunInDir(p.Command, runnable.Fullpath)
fullCmd, err := p.GetCommand(runnable)
if err != nil {
return errors.Wrap(err, "failed to get templated full command")
Copy link
Contributor

Choose a reason for hiding this comment

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

It maybe seems a little silly, but the convention we use for error messages is failed to + the name of the function that failed. Something like this:

Suggested change
return errors.Wrap(err, "failed to get templated full command")
return errors.Wrap(err, "failed to GetCommand for preReq")

Copy link
Contributor Author

@javorszky javorszky Feb 4, 2022

Choose a reason for hiding this comment

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

I'll change that up. Also somewhat relatedly, what do you think about using this? https://thanos.io/tip/contributing/coding-style-guide.md/#wrap-errors-for-more-context-dont-repeat-failed--there

NOTE: never prefix wrap messages with wording like failed ... or error occurred while.... Just describe what we wanted to do when the failure occurred. Those prefixes are just noise. We are wrapping error, so it’s obvious that some error occurred, right? (: Improve readability and consider avoiding those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed up the errors in 64cb16d.

Additionally I see that result.OutputLog gets the log from util.RunInDir but it's not being used anywhere that I can see. A global search doesn't reveal anything where OutputLog gets passed to a log function call, or even to an fmt.

Copy link
Contributor

Choose a reason for hiding this comment

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

@javorszky I'm a fan of that honestly. Will ping @cohix for an opinion as well since he came up with the format that's used currently.

@javorszky javorszky changed the title feat(prereq template): Introduce templating for prereq commands feat(builder): Introduce templating for prereq commands Feb 4, 2022
@javorszky
Copy link
Contributor Author

Hm, interesting that a new commit does not dismiss the approval. 🤔

@javorszky javorszky merged commit 9249bb7 into main Feb 7, 2022
@javorszky javorszky deleted the issue-123 branch February 7, 2022 09:08
@javorszky javorszky mentioned this pull request Feb 7, 2022
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.

Insert template strings into prereq strings
2 participants