Skip to content

Add a Build command#476

Merged
dgageot merged 5 commits intoGoogleContainerTools:masterfrom
dgageot:build-command
May 8, 2018
Merged

Add a Build command#476
dgageot merged 5 commits intoGoogleContainerTools:masterfrom
dgageot:build-command

Conversation

@dgageot
Copy link
Copy Markdown
Contributor

@dgageot dgageot commented Apr 26, 2018

Also fixes #425, which means there are no more different defaults in dev and run modes.

Copy link
Copy Markdown
Contributor

@r2d4 r2d4 left a 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 {
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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.

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 {
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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 {
Copy link
Copy Markdown
Contributor

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/

Copy link
Copy Markdown
Contributor Author

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

}

func GetConfig(contents []byte, useDefault bool, dev bool) (util.VersionedConfig, error) {
func GetConfig(contents []byte, useDefault bool) (util.VersionedConfig, error) {
Copy link
Copy Markdown
Contributor

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{}}
Copy link
Copy Markdown
Contributor

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 ?

Copy link
Copy Markdown
Contributor Author

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.

@dgageot
Copy link
Copy Markdown
Contributor Author

dgageot commented Apr 27, 2018

@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.

dgageot added 5 commits May 8, 2018 09:53
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>
@dgageot dgageot merged commit d1987b1 into GoogleContainerTools:master May 8, 2018
@dgageot dgageot deleted the build-command branch May 9, 2018 05:28
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.

Make git tagger the default for both dev and run

3 participants