Skip to content

Add a way to unset global config values#1086

Merged
nkubala merged 4 commits intoGoogleContainerTools:masterfrom
nkubala:unset_global_config
Oct 10, 2018
Merged

Add a way to unset global config values#1086
nkubala merged 4 commits intoGoogleContainerTools:masterfrom
nkubala:unset_global_config

Conversation

@nkubala
Copy link
Copy Markdown
Contributor

@nkubala nkubala commented Oct 3, 2018

skaffold config unset default-repo

@nkubala nkubala force-pushed the unset_global_config branch from d2b30c7 to 374e997 Compare October 3, 2018 18:09
@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 3, 2018

Codecov Report

Merging #1086 into master will decrease coverage by 1.15%.
The diff coverage is 7.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1086      +/-   ##
==========================================
- Coverage   44.09%   42.93%   -1.16%     
==========================================
  Files          84       89       +5     
  Lines        3667     3915     +248     
==========================================
+ Hits         1617     1681      +64     
- Misses       1895     2066     +171     
- Partials      155      168      +13
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/config/util.go 40% <0%> (ø)
cmd/skaffold/app/cmd/config.go 0% <0%> (ø) ⬆️
cmd/skaffold/app/cmd/config/set.go 50% <0%> (ø)
cmd/skaffold/app/cmd/config/unset.go 9.52% <9.52%> (ø)
pkg/skaffold/build/local/jib_gradle.go 25% <0%> (-17.11%) ⬇️
pkg/skaffold/build/local/local.go 48.33% <0%> (-8.49%) ⬇️
pkg/skaffold/build/local/jib_maven.go 26.66% <0%> (-8.34%) ⬇️
pkg/skaffold/kubernetes/wait.go 24.44% <0%> (-4.97%) ⬇️
pkg/skaffold/deploy/kubectl/cli.go 0% <0%> (ø) ⬆️
pkg/skaffold/deploy/kubectl/version.go 0% <0%> (ø) ⬆️
... and 7 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 a651b8f...25245d0. Read the comment docs.

Copy link
Copy Markdown
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

Please write tests!

@nkubala nkubala force-pushed the unset_global_config branch from 374e997 to 11d789d Compare October 5, 2018 17:40
balopat
balopat previously requested changes Oct 8, 2018
}

// unset the values and ensure they're not present in the config
unsetArgs := []string{"config", "unset", test.key}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this way of testing a functionality as a "step" of an integration test and depending on the output format is brittle and slow to give feedback. Do you mind writing a simple unit test that exercises the config file, sets and unsets the value?


if fieldType != val.Type() {
return fmt.Errorf("%s is not a valid value for field %s", value, fieldName)
if IsZero(val) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are you introducing this to handle empty strings? If that's the case, we can just ignore the empty string case - if user sets "" then the value will be set to "".
This way we don't have to introduce the whole IsZero function which was decided to be abandoned in the reflect package as well (see this comment). For the first branch value == nil check should be sufficient to set with reflect.Zero

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason I added this was to make the unset logic generic for all types (i.e. so we can pass nil to setConfigValue without worrying about the type), in case we added values of different types to the global config (e.g. int, bool, etc) - empty string is actually the only case I didn't need IsZero for. However, after thinking about it a little more I think it's fine for now to just pass the empty string when we're unsetting. I'll remove this.

@nkubala nkubala force-pushed the unset_global_config branch from cc8724c to 144f694 Compare October 9, 2018 18:47
@nkubala nkubala dismissed balopat’s stale review October 10, 2018 17:40

I believe I addressed all the requested changes

@nkubala nkubala merged commit 9bc2ca6 into GoogleContainerTools:master Oct 10, 2018
@nkubala nkubala deleted the unset_global_config branch October 10, 2018 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants