-
Notifications
You must be signed in to change notification settings - Fork 286
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 global pull policy configuration command #1008
Add global pull policy configuration command #1008
Conversation
7488370
to
677b1e9
Compare
Codecov Report
@@ Coverage Diff @@
## main #1008 +/- ##
==========================================
+ Coverage 79.47% 79.61% +0.15%
==========================================
Files 129 130 +1
Lines 5716 5777 +61
==========================================
+ Hits 4542 4599 +57
- Misses 755 757 +2
- Partials 419 421 +2
Flags with carried forward coverage won't be shown. Click here to find out more. |
} | ||
|
||
pullPolicy, err := pubcfg.ParsePullPolicy(cfg.PullPolicy) | ||
if err != nil { |
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.
Don't necessarily need to check for error here, as the pull policy has been set to one (line 34 this file) that we know is valid. But there could easily be more succinct ways to do this.
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
677b1e9
to
6c780b2
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.
Overall, this is phenomenal, and really helpful. I had a bunch of nit suggestions, mostly stylistic, but this is super helpful.
One addition location to make this change is in internal/commands/package_buildpack.go
Also, one additional location that I'd add a test in is in internal/commands/confg_test.go
, specifically here, just to provide assurance that the command is displayed as we would expect.
var err error | ||
pullPolicy, err := pubcfg.ParsePullPolicy(flags.Policy) | ||
var pullPolicy pubcfg.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.
nit: In this particular case, you should be able to remove both of these lines, and just do:
pullPolicy, err := pubcfg.ParsePullPolicy(stringPolicy)
below
aa61e55
to
14fb1a1
Compare
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
14fb1a1
to
82d792e
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 super close. Just a few more small changes I'd like to see, if you have the time.
Args: cobra.MaximumNArgs(1), | ||
Short: "List, set and unset the global pull policy used by other commands", | ||
Aliases: []string{"pull-policy"}, | ||
Long: bpRegistryExplanation + "\n\nYou can use this command to list, set, and unset the default pull policy that will be used when working with containers:\n" + |
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 still relevant, bpRegistryExplanataion isn't relevant for understanding pull-policies
Signed-off-by: Nathan Kuik <nkuik@toogoodtogo.com>
14fb55b
to
c62a8f3
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.
Summary
Adds the following commands to set, list, or unset a global container pull policy:
pack config pull-policy
(lists the configured policy--default is "always")pack config pull-policy <if-not-present | always | never>
(set the default pull-policy)pack config pull-policy --unset
(unset a configured global policy and reset to default--"always)The changes still allow
--pull-policy
to be provided as an option in the command line. If--pull-policy
is provided, it takes precedence to any globally configured pull-policyOutput
Before
These commands did not exist, so I can't think of any output to show.
After
pack config -h
pack config pull-policy -h
pack config pull-policy
When no other policy has been configured.
pack config pull-policy never
When no other policy has been configured.
$ out/pack config pull-policy never Successfully set never as the pull policy
pack config pull-policy if-not-present
When no other policy has been configured.
$ out/pack config pull-policy if-not-present Successfully set if-not-present as the pull policy
pack config pull-policy always
When no other policy has been configured.
$ out/pack config pull-policy always Successfully set always as the pull policy
pack config pull-policy never
When never was already the configured policy.
$ out/pack config pull-policy always Pull policy is already set to never
pack config pull-policy invalid-policy
When never was already the configured policy.
pack config pull-policy --unset
pack config pull-policy never --unset
(invalid command)Documentation
Related
Resolves #991