-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
📖 Plugin phase 1.5 EP #1990
📖 Plugin phase 1.5 EP #1990
Conversation
95403df
to
8bc3276
Compare
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.
seems pretty reasonable to me. Might want to elaborate on which each step gets each guarantee for posterity's sake, but generally looks good :-)
|
||
#### Post-scaffold | ||
This method will be used to take actions after the main scaffolding is performed, e.g. cleanup. | ||
NOTE: a filesystem abstraction will **NOT** be passed to this method, it should interact directly. |
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 the recommendation that you not interact with the filesystem here then, or is this just because naturally this takes place after KB writes stuff to disk, or both?
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 was because the scaffolding is expected to be done in the previous step, post-scaffold was designed to do tasks like code generation, make targets and things like that that do not require a filesystem. Even though the current design and implementation of plugin phase 1.5 do not pass a filesystem, maybe we want to leave the option to pass a filesystem in the future if the need arises.
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.
I updated the note saying that we may need to pass a filesystenm abstraction in a future. It is more a "We don't need it now" that a "We should not have a filesystem abstraction here".
467d087
to
03b7afe
Compare
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.
Looks great, just one question/suggestion.
InjectResource(*resource.Resource) error | ||
} | ||
|
||
type HasPreScaffold interface { |
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.
I don't see an immediate need for pre (and post, but that is covered above) scaffolding, since these can be done within Scaffold()
. Perhaps remove these to simplify things, and add them back if we find a valid use case for them?
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.
They are optional, so there is no need to use them if you want to develop a simple plugin (you can check the edit subcommands in the implementation PR), but they do offer a great flexibility. All plugins will run their pre-scaffold logic and can return an error (stoping the subcomman execution) before any of the plugins start to scaffold the files. This allows us to validate all the plugins before scaffolding. If we only had one hook (Scaffold) then every plugin will run its validation, scaffold its files and do the post-scaffolding tasks before the rest of the plugin can validate theirselves. Same applies for post-scaffolding tasks.
Let me illustrate this with a couple examples:
- We have a plugin that allows us to define the fields a type will have in some yaml format that must be present before we run
kb create api
. The cli has the base go/v3 and this plugins configured for this project. One of the validations of this plugins is to check that the file is present and that it can be parsed. If we only have one hook, it will check this conditions after go/v3 has scaffolded its files, when it shouldn't because it failed to fulfill the second plugin requirements. - We have a plugin that adds some fields to the generated types. Again, the cli has the base go/v3 plugin and this one that edits its fields. go/v3 runs
make generate
at the end, but if we don't have a post-scaffold hook, it will be run before the second plugin performs the changes to the types file, and therefore be obsolete by the time the command finishes.
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.
Thanks for the explanation, that makes sense.
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.
answers my question as well.
Remove this hold when ready to merge. /lgtm |
/hold cancel |
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.
/lgtm
|
||
Execution methods will be able to return an error. A specific error can be returned to specify that | ||
no further methods of this plugin should be called, but that the scaffold process should be continued. | ||
This enables plugins to exit early, e.g., a plugin that scaffolds some files only for cluster-scoped |
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.
The exit early but continue is nice.
InjectResource(*resource.Resource) error | ||
} | ||
|
||
type HasPreScaffold interface { |
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.
answers my question as well.
@jmrodri: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Adirio, DirectXMan12, estroz, jmrodri The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
Signed-off-by: Adrian Orive <[email protected]>
aa0b71a
to
3948289
Compare
/hold cancel |
/lgtm |
@jmrodri: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/lgtm |
This PR proposes a plugin phase 1.5 by submiting an EP.
Phase 1.5 should provide some of the goals defined for phase 2 in a shorter date.
You can read the EP with a nicer UX that in the chenged files here.