context use: don't create/update config file and directories if not needed#3721
Merged
thaJeztah merged 2 commits intodocker:masterfrom Jul 29, 2022
Merged
context use: don't create/update config file and directories if not needed#3721thaJeztah merged 2 commits intodocker:masterfrom
thaJeztah merged 2 commits intodocker:masterfrom
Conversation
This code was handling validation and parsing, only to discard the results if it was the default context. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
6c9c5e8 to
fc7daec
Compare
Codecov Report
@@ Coverage Diff @@
## master #3721 +/- ##
=======================================
Coverage 59.11% 59.11%
=======================================
Files 289 289
Lines 24665 24665
=======================================
Hits 14581 14581
Misses 9212 9212
Partials 872 872 |
Member
Author
vvoland
approved these changes
Jul 29, 2022
cli/command/context/use_test.go
Outdated
| cli, err := command.NewDockerCli(command.WithCombinedStreams(io.Discard)) | ||
| assert.NilError(t, err) | ||
| assert.NilError(t, newUseCommand(cli).RunE(nil, []string{"default"})) | ||
| assert.NilError(t, err) |
Member
Author
There was a problem hiding this comment.
nice catch; sloppy copy/paste 😅
fixed!
…eeded Avoid updating the config-file if nothing changed. This also prevents creating the file and config-directory if the default is used and no config-file existed yet. `config.Save()` performs various steps (creating the directory, updating or copying permissions, etc etc), which are not needed if the defaults are used; https://github.com/docker/cli/blob/a445d97c2536f0de37469d0ea9881288d6c49cbf/cli/config/configfile/file.go#L135-L176 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
fc7daec to
f87d7ed
Compare
Member
Author
|
All green; let's get this one in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
context use: skip validation for "default" context
This code was handling validation and parsing, only to discard the results if it was the default context.
context use: don't create/update config file and directories if not needed
Avoid updating the config-file if nothing changed. This also prevents creating
the file and config-directory if the default is used and no config-file existed
yet.
config.Save()performs various steps (creating the directory, updatingor copying permissions, etc etc), which are not needed if the defaults are
used;
cli/cli/config/configfile/file.go
Lines 135 to 176 in a445d97
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)