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

skaffold init --force supports cases with 1 image and multiple builders #4973

Merged

Conversation

MarlonGamez
Copy link
Contributor

Fixes #3661

Description
Allows for skaffold init --force to work in situations where it detects one image and multiple builders. Previously, the user would see the following

FATA[0000] unable to automatically resolve builder/image pairs; run `skaffold init` without `--force` to manually resolve ambiguities

Now, a builder will be chosen with the following priority: Docker > Jib > Bazel > Buildpacks
This ordering was decided upon from input on both #3661 and https://kubernetes.slack.com/archives/CABQMSZA6/p1602786450111700.

Follow-up Work
It would be nice to do something in the case of multiple images and builders. I've opened #4912 to talk about this.

@codecov
Copy link

codecov bot commented Oct 29, 2020

Codecov Report

Merging #4973 into master will decrease coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4973      +/-   ##
==========================================
- Coverage   72.27%   72.25%   -0.02%     
==========================================
  Files         361      361              
  Lines       12603    12660      +57     
==========================================
+ Hits         9109     9148      +39     
- Misses       2821     2833      +12     
- Partials      673      679       +6     
Impacted Files Coverage Δ
pkg/skaffold/initializer/build/resolve.go 79.16% <66.66%> (-5.45%) ⬇️
pkg/skaffold/docker/image.go 80.61% <0.00%> (-1.33%) ⬇️
pkg/skaffold/deploy/kpt/kpt.go 73.92% <0.00%> (+0.67%) ⬆️

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 939b7c0...0ee8789. Read the comment docs.

@MarlonGamez MarlonGamez marked this pull request as ready for review October 29, 2020 18:07
@MarlonGamez MarlonGamez requested a review from a team as a code owner October 29, 2020 18:07
@MarlonGamez MarlonGamez requested a review from IsaacPD October 29, 2020 18:07
@tejal29
Copy link
Contributor

tejal29 commented Oct 30, 2020

Can we update the init docs with the order of preference?

}

d.builderImagePairs = append(d.builderImagePairs, BuilderImagePair{Builder: choice, ImageName: image})
d.unresolvedImages = util.RemoveFromSlice(d.unresolvedImages, image)
Copy link
Contributor

Choose a reason for hiding this comment

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

should unresolvedImages be a map instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

perhaps! Could you explain your thoughts on why it should be?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry I missed this comment. A map would have been more efficient for this RemoveFromSlice behavior.

@IsaacPD IsaacPD removed their request for review October 30, 2020 17:31
@MarlonGamez
Copy link
Contributor Author

MarlonGamez commented Oct 30, 2020

Can we update the init docs with the order of preference?

@tejal29 how would you suggest documenting this without being too verbose? If we say something like "In the case of multiple builders being matched to a single image, the priority is Docker > Jib > Bazel > Buildpacks" I'm worried it might make things really long

@tejal29
Copy link
Contributor

tejal29 commented Oct 30, 2020

Can we update the init docs with the order of preference?

@tejal29 how would you suggest documenting this without being too verbose? If we say something like "In the case of multiple builders being matched to a single image, the priority is Docker > Jib > Bazel > Buildpacks" I'm worried it might make things really long

Ah not the output. I meant the Init docs https://skaffold.dev/docs/pipeline-stages/init/.
We don't have --force documented here. Upto you if you want to create another PR for this or in this same one.

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.

I would prefer to describe the --force in this PR so change as well as documentation for the change go hand in hand.

Leaving it upto you.

}

d.builderImagePairs = append(d.builderImagePairs, BuilderImagePair{Builder: choice, ImageName: image})
d.unresolvedImages = util.RemoveFromSlice(d.unresolvedImages, image)
Copy link
Contributor

Choose a reason for hiding this comment

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

you could set d.unresolvedImages to empty array instead of calling RemoveFromSlice here.

@MarlonGamez
Copy link
Contributor Author

@tejal29 Added a section to the docs, PTAL. I wasn't sure exactly where to place it within the init page

@tejal29
Copy link
Contributor

tejal29 commented Oct 31, 2020

@tejal29 Added a section to the docs, PTAL. I wasn't sure exactly where to place it within the init page

Looks good! Ship it!

@MarlonGamez MarlonGamez merged commit 06d46a5 into GoogleContainerTools:master Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants