-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add a Build command #476
Add a Build command #476
Conversation
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.
First pass. I'm actually really excited for exposing these subcommands. Might have to wait for after kubecon to merge, but looks pretty good.
} | ||
return r.dev(ctx) | ||
// Build builds the artifacts. | ||
func (r *SkaffoldRunner) Build(ctx context.Context) error { |
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.
Should skaffold build
or skaffold deploy
call the builders and deployers directly? Theoretically, they should only do exactly that, and the CLI output UX could be handled in cmd.
Right now I guess that would mean exposing getBuilder
or getDeployer
, which should hopefully go away with #388
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.
Since the builder is embedded in the runner, you can just call build straight from that. Then, our cmd/build would just look like
runner := NewForConfig()
runner.Build()
Or most likely you can reuse the private r.build here so that the UX looks similar.
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'd rather try that in another PR. I've tried something similar and failed.
cmd/skaffold/app/cmd/build.go
Outdated
Short: "Builds the artifacts", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return runSkaffold(out, filename, func(ctx context.Context, r *runner.SkaffoldRunner) error { |
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'm not sure I have a better idea right now, but the signature of this function makes it feel like its a bit overloaded.
Its toggling between run (build + deploy), dev (build + deploy loop), and build.
I'd be fine just having a function that returns the runner and call run, dev, or build here.
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.
Good point! I'll just return the runner
func (r *SkaffoldRunner) Build(ctx context.Context) error { | ||
bRes, err := r.build(ctx, r.config.Build.Artifacts) | ||
|
||
for _, res := range bRes.Builds { |
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.
This could live in r.build and be exposed there. Or if you dont think its appropriate for dev/run mode, we can add it in cmd/
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.
Build
and build
don't take the same parameters. I'd rather try to refactor that in a separate PR
return config, err | ||
}, | ||
} | ||
|
||
func GetConfig(contents []byte, useDefault bool, dev bool) (util.VersionedConfig, error) { | ||
func GetConfig(contents []byte, useDefault bool) (util.VersionedConfig, error) { |
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.
Does this also mean that we no longer have default differences between dev/run? I'm ok with that if thats the case, but it should be noted.
} else { | ||
cfg.Build.TagPolicy = TagPolicy{GitTagger: &GitTagger{}} | ||
} | ||
cfg.Build.TagPolicy = TagPolicy{GitTagger: &GitTagger{}} |
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'm guessing addresses #425 ?
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! That's in the commit message. I've added that to the PR description. It greatly simplify the code and makes more sense for the users.
@r2d4 I've applied your feedback and would love to refactor the Dev/Build/Run functions on a separate PR. It requires refactoring a lot of the tests too. |
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Fixes GoogleContainerTools#425 Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Also fixes #425, which means there are no more different defaults in dev and run modes.