Skip to content
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 skaffold build --push flag #5708

Merged

Conversation

aaron-prindle
Copy link
Contributor

@aaron-prindle aaron-prindle commented Apr 19, 2021

What is the problem being solved?
Fixes #5667, adding --push flag to skaffold build. This --push flag overrides any skaffold.yaml "build.local.push: false" configuration for a build allowing easier artifact pushing after local dev without having to modify yaml configuration.

Why is this the best approach?
This approach follows the style and convention for adding a flag that has been used prior for adding a flag used by a single command, similar to #4039. Additionally this approach does not change the skaffold build default push behaviour to be false, instead only taking precendence when the --push flag is set true which is the intended use case.

What other approaches did you consider?
N/A

What side effects will this approach have?
The addition of this single flag should not have side effects on skaffold functionally outside of --push, the default behavior for skaffold build will be preserved w/o --push specified.

What future work remains to be done?
N/A

@aaron-prindle aaron-prindle requested a review from a team as a code owner April 19, 2021 21:25
@google-cla google-cla bot added the cla: yes label Apr 19, 2021
@aaron-prindle aaron-prindle force-pushed the skaff-build-push-flag branch 2 times, most recently from 3abc38b to b83fd94 Compare April 20, 2021 22:14
@pull-request-size pull-request-size bot added size/S and removed size/M labels Apr 20, 2021
@tejal29 tejal29 added this to the v1.23.0 milestone Apr 20, 2021
@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #5708 (10c7325) into master (0e506fa) will increase coverage by 0.33%.
The diff coverage is 89.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5708      +/-   ##
==========================================
+ Coverage   70.51%   70.84%   +0.33%     
==========================================
  Files         413      421       +8     
  Lines       15996    16048      +52     
==========================================
+ Hits        11279    11370      +91     
+ Misses       3885     3845      -40     
- Partials      832      833       +1     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/flags.go 89.02% <ø> (ø)
pkg/skaffold/config/options.go 100.00% <ø> (ø)
pkg/skaffold/runner/new.go 66.66% <25.00%> (+3.88%) ⬆️
cmd/skaffold/app/cmd/build.go 90.00% <100.00%> (+0.25%) ⬆️
pkg/skaffold/config/types.go 100.00% <100.00%> (ø)
pkg/skaffold/runner/runcontext/context.go 84.74% <100.00%> (+4.92%) ⬆️
pkg/skaffold/build/local/local.go 61.36% <0.00%> (-6.82%) ⬇️
pkg/skaffold/build/cluster/cluster.go 22.85% <0.00%> (-2.86%) ⬇️
pkg/skaffold/docker/parse.go 86.19% <0.00%> (-0.96%) ⬇️
pkg/skaffold/build/gcb/cloud_build.go 0.00% <0.00%> (-0.71%) ⬇️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca4886f...10c7325. Read the comment docs.

@aaron-prindle aaron-prindle force-pushed the skaff-build-push-flag branch from b83fd94 to 8043500 Compare April 21, 2021 00:21
@pull-request-size pull-request-size bot added size/L and removed size/S labels Apr 21, 2021
@aaron-prindle aaron-prindle force-pushed the skaff-build-push-flag branch 8 times, most recently from c8768fc to 431b811 Compare April 21, 2021 23:08
Comment on lines +191 to 200

switch {
case runCtx.Opts.PushImages.Value() != nil:
logrus.Debugf("push value set via skaffold build --push flag, --push=%t", *runCtx.Opts.PushImages.Value())
pushImages = *runCtx.Opts.PushImages.Value()
case pipeline.Build.LocalBuild.Push == nil:
pushImages = cl.PushImages
logrus.Debugf("push value not present, defaulting to %t because cluster.PushImages is %t", pushImages, cl.PushImages)
} else {
default:
pushImages = *pipeline.Build.LocalBuild.Push
Copy link
Contributor

@tejal29 tejal29 Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests here so we never unintentionally break the precedence?
Test to make sure if runCtx.Opts.PushImages is not set a and pipeline.Build.LocalBuild.Push is set, then pushImages is true.

If runCtx.Opts.PushImages is set to false and pipeline.Build.LocalBuild.Push is true, pushImages is set to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this, thanks! Do you have any code examples of how to mock/set skaffold.yaml values or directly set the pipelines values? Still trying to understand how to do this from poking around.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can get away with just testing isImageLocal function with manually set values for runcontext.RunContext?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah makes sense, added TestIsImageLocal to new_test.go testing all combinations of --push=[nil|false|true] and pipeline.Build.LocalBuild.Push=[nil|false|true] w/ desired functionality

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Please rebase and add tests.

@aaron-prindle
Copy link
Contributor Author

Rebased using the BooleanOrUndefined type from:
#5712

@aaron-prindle aaron-prindle force-pushed the skaff-build-push-flag branch 3 times, most recently from 2ec1c93 to e99f52b Compare April 23, 2021 20:28
@pull-request-size pull-request-size bot added size/L and removed size/M labels Apr 23, 2021
@aaron-prindle aaron-prindle force-pushed the skaff-build-push-flag branch 4 times, most recently from dacaf2b to ccc6d26 Compare April 23, 2021 22:00
What is the problem being solved?
Fixes GoogleContainerTools#5667, adding --push flag to skaffold build.  This --push flag overrides any skaffold.yaml "build.local.push: false" configuration for a build allowing easier artifact pushing after local dev without having to modify yaml configuration.

Why is this the best approach?
This approach follows the style and convention for adding a flag that has been used prior for adding a flag used by a single command, similar to GoogleContainerTools#4039. Additionally this approach does not change the skaffold build default push behaviour to be false, instead only taking precendence when the --push flag is set true which is the intended use case.

What other approaches did you consider?
N/A

What side effects will this approach have?
The addition of this single flag should not have side effects on skaffold functionally outside of --push, the default behavior for skaffold build will be preserved w/o --push specified.

What future work remains to be done?
N/A
@aaron-prindle aaron-prindle force-pushed the skaff-build-push-flag branch from ccc6d26 to 10c7325 Compare April 24, 2021 04:26
@aaron-prindle
Copy link
Contributor Author

Rebased and added tests.

@tejal29 tejal29 merged commit e48a418 into GoogleContainerTools:master Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

skaffold build should support a --push flag to override build.local.push
4 participants