-
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
🏃 Homogenize commands through Scaffolder interface #1330
🏃 Homogenize commands through Scaffolder interface #1330
Conversation
Hi @Adirio. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
27f745e
to
5e1cf20
Compare
b61fb5e
to
df222db
Compare
df222db
to
e07ad64
Compare
/ok-to-test |
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.
Generally looks good. Is there any way that we can put the steps into an interface / helper so we don't have to repeat them in every run method?
@DirectXMan12 Something like the following? type commandOptions interface {
bindFlags(cmd *cobra.Command)
loadConfig() (*Config, error)
validate(*config.Config) error
scaffolder(*config.Config) (Scaffolder, error)
postScaffold(*config.Config) error
}
func run(options commandOptions) error {
// Step 1: load config
config, err := options.loadConfig()
if err != nil {
return err
}
// Step 2: validate
if err := options.validate(config); err != nil {
return err
}
// Step 3: create scaffolder
scaffolder, err := options.scaffolder(config)
if err != nil {
return err
}
// Step 4: scaffold
if err := scaffolder.Scaffold(); err != nil {
return err
}
// Step 5: finish
if err := options.postScaffold(); err != nil {
return err
}
} |
e07ad64
to
a373c63
Compare
a373c63
to
abd4bda
Compare
Didn't expect the golden test to check file permission, but it does. |
@DirectXMan12 I made a separate commit with the helper as I described here. |
22269f0
to
5ecdb8b
Compare
looks good once it's rebased |
5ecdb8b
to
4ddaf11
Compare
4ddaf11
to
5627ff6
Compare
Signed-off-by: Adrian Orive <adrian.orive.oneca@gmail.com>
5627ff6
to
6d5e8bb
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.
one nit.
Other bits LGTM.
This is a great refactor! Thanks for working on this. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Adirio, mengqiy 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 |
Description
This PR defines a Scaffolder interface with a single method:
This interface is used as the API between the
cmd
and thepkg/scaffold
packages. This allows to provide a clearer limit between the two packages, as previously the limit was not clear and logic that should be placed inpkg/scaffold
could be found incmd
(e.g., webhook scaffolding was being done directly incmd
).Additionally the option structs for each command has also been homogenized. An unexported interface has been used for this purpose:
The logic flow described for the
run
method has been used for every command. In some cases, some steps are simply no-ops, like the 5th step for the edit command.Motivation
This PR is one of the main contributors to #1218.