-
Notifications
You must be signed in to change notification settings - Fork 279
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 pull-policy flag to build/create-builder/package-buildpack/rebase commands #773
Conversation
8f6af38
to
f6c9920
Compare
Codecov Report
@@ Coverage Diff @@
## main #773 +/- ##
==========================================
+ Coverage 75.59% 76.00% +0.42%
==========================================
Files 77 78 +1
Lines 5197 5290 +93
==========================================
+ Hits 3928 4020 +92
- Misses 972 973 +1
Partials 297 297
Flags with carried forward coverage won't be shown. Click here to find out more. |
f168121
to
461c201
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.
Should we add a --pull-policy
flag to pack inspect-builder
and pack inspect-image
?
@@ -92,7 +94,7 @@ func (c *Client) Build(ctx context.Context, opts BuildOptions) error { | |||
return errors.Wrapf(err, "invalid builder '%s'", opts.Builder) | |||
} | |||
|
|||
rawBuilderImage, err := c.imageFetcher.Fetch(ctx, builderRef.Name(), true, !opts.NoPull) | |||
rawBuilderImage, err := c.imageFetcher.Fetch(ctx, builderRef.Name(), true, opts.PullPolicy) |
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.
From a code readability standpoint, I appreciate the removal of double negatives (from here, and many other place throughout the code).
|
||
const ( | ||
// PullAlways images, even if they are present | ||
PullAlways PullPolicy = iota |
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.
iota
is useful for defining enums. For more on iotas, see https://github.com/golang/go/wiki/Iota or https://splice.com/blog/iota-elegant-constants-golang/
On the other hand, I also debated just defining these as strings, which would've obviated the need for a secondary String()
method. If people would rather change it to a string type to make it simpler, I'm happy to do that.
@@ -64,7 +66,7 @@ func (c *Client) validateRunImageConfig(ctx context.Context, opts CreateBuilderO | |||
var runImages []imgutil.Image | |||
for _, i := range append([]string{opts.Config.Stack.RunImage}, opts.Config.Stack.RunImageMirrors...) { | |||
if !opts.Publish { | |||
img, err := c.imageFetcher.Fetch(ctx, i, true, false) | |||
img, err := c.imageFetcher.Fetch(ctx, i, true, opts.PullPolicy) |
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.
There were times where we had ignored the --no-pull
option, which I think we shouldn't do, once we explicitly ask people what they want to do.
} | ||
|
||
func validateBuildFlags(flags BuildFlags, logger logging.Logger, cfg config.Config, packClient PackClient) error { | ||
func validateBuildFlags(flags *BuildFlags, cfg config.Config, packClient PackClient, logger logging.Logger) 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.
From a readability perspective, I found it confusing for the logger to be so early in the parameters, so I took the liberty of moving it to the end of the parameter list
5b5dbc6
to
3d39744
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.
This is great! Nice clean implementation! 💯
* Adds temporary method NewFetch, to allow for gradual refactoring in adding PullPolicy Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
* Additionally, had to change some create_builder and build lines, due to changing a global method. Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
* Ensure acceptance tests are passing Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
This reverts commit 87e69ce. Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
* Remove ParsePolicyFromBool method. It was used in refactoring over from no-pull to PullPolicy, but is no longer necessary * Ensure fake image fetcher implements PullIfNotPresent * Rename imports to pubcfg * Add tests for unknown policy Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
7f89dfb
to
b801f55
Compare
Summary
This deprecates the
--no-pull
flag, in favor of--pull-policy
, which as three options at the moment:always
→ Always pulls the images necessary (the default behavior of pack)never
→ Never pulls the images necessary (equivalent to--no-pull
)if-not-present
→ Pulls the image only if it is not presentIt also adds the possibility for future policies to be added, by centralizing the
PullPolicy
s.Output
$ pack build
Before
After
$ pack create-builder
Before
After
$ pack package-buildpack
Before
After
$ pack rebase
Before
After
Documentation
Related
Resolves #686
Implements buildpacks/rfcs#80