-
Notifications
You must be signed in to change notification settings - Fork 2.9k
hooks: Add package support for extension stages #758
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ Each JSON file should contain an object with the following properties: | |
| Entries MUST be [POSIX extended regular expressions][POSIX-ERE]. | ||
| * **`hasBindMounts`** (OPTIONAL, boolean) If `hasBindMounts` is true and the caller requested host-to-container bind mounts (beyond those that CRI-O or libpod use by default), this condition matches. | ||
| * **`stages`** (REQUIRED, array of strings) Stages when the hook MUST be injected. | ||
| Entries MUST be chosen from the 1.0.1 OCI Runtime Specification [hook stages][spec-hooks]. | ||
| Entries MUST be chosen from the 1.0.1 OCI Runtime Specification [hook stages][spec-hooks] or from extention stages supported by the package consumer. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Being strict here helps catch typos like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm content to say that all users of a single
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So what directory should I change to when I add |
||
|
|
||
| If *all* of the conditions set in `when` match, then the `hook` MUST be injected for the stages set in `stages`. | ||
|
|
||
|
|
@@ -114,10 +114,7 @@ Previous versions of CRI-O and libpod supported the 0.1.0 hook schema: | |
| The injected hook's [`args`][spec-hooks] is `hook` with `arguments` appended. | ||
| * **`stages`** (REQUIRED, array of strings) Stages when the hook MUST be injected. | ||
| `stage` is an allowed synonym for this property, but you MUST NOT set both `stages` and `stage`. | ||
| Entries MUST be chosen from: | ||
| * **`prestart`**, to inject [pre-start][]. | ||
| * **`poststart`**, to inject [post-start][]. | ||
| * **`poststop`**, to inject [post-stop][]. | ||
| Entries MUST be chosen from the 1.0.1 OCI Runtime Specification [hook stages][spec-hooks] or from extention stages supported by the package consumer. | ||
| * **`cmds`** (OPTIONAL, array of strings) The hook MUST be injected if the configured [`process.args[0]`][spec-process] matches an entry. | ||
| `cmd` is an allowed synonym for this property, but you MUST NOT set both `cmds` and `cmd`. | ||
| Entries MUST be [POSIX extended regular expressions][POSIX-ERE]. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do on one line
if err := ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to do this automatically (e.g. with
gofmt)? I usually use separate lines, and there are already many instances of the separate-line approach in the hooks package:It looks like I've only gone with the one-line approach twice:
I can go whichever way you like for any lines you like. Changing this one line manually is easy, but I'm not sure how you feel about the other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know of any gofmt call to do it. But when I look at the go code in hooks directory I see all instances where err is created by itself to use the single line.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're looking at a version from before 68eb128 (#686), which moved the
Unmarshalcall frompkg/hooks/hooks.gointo other places:My grep above is still what I get with the current master (69a6cb2). And 68eb128 added a bunch of examples with the two-line approach. Most of those additions were
*_test.gofiles, but there were some others which show up in my earlier grep.Anyhow, I'm fine translating any of these to the one-line approach but identifying them is hard. Do you also want me to adjust master entries like this to:
I'm not sure where you see the tighter-scoping benefit of the one-line approach balancing out the readability drop from the more compact approach. For that
TestUnknownPathexample, the above if/else would be the entire test function, so gains from tighter scoping would be very small.Or should I just be adjusting entries already being touched by this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an example of a line touched in this PR that could be one-lined if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I guess I was looking at an older pool. I guess we can allow this in and then I will open a PR to fix the non single like ones.