-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
stop secretly setting defaults under the pretense of negotiation #45743
Merged
k8s-github-robot
merged 2 commits into
kubernetes:master
from
deads2k:cli-12-apiversion
May 17, 2017
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ import ( | |
restclient "k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
fedclientset "k8s.io/kubernetes/federation/client/clientset_generated/federation_internalclientset" | ||
"k8s.io/kubernetes/pkg/api" | ||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" | ||
oldclient "k8s.io/kubernetes/pkg/client/unversioned" | ||
"k8s.io/kubernetes/pkg/version" | ||
|
@@ -98,19 +97,7 @@ func (c *ClientCache) ClientConfigForVersion(requiredVersion *schema.GroupVersio | |
|
||
// clientConfigForVersion returns the correct config for a server | ||
func (c *ClientCache) clientConfigForVersion(requiredVersion *schema.GroupVersion) (*restclient.Config, error) { | ||
// TODO: have a better config copy method | ||
config, discoveryClient, err := c.getDefaultConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if requiredVersion == nil && config.GroupVersion != nil { | ||
// if someone has set the values via flags, our config will have the groupVersion set | ||
// that means it is required. | ||
requiredVersion = config.GroupVersion | ||
} | ||
|
||
// required version may still be nil, since config.GroupVersion may have been nil. Do the check | ||
// before looking up from the cache | ||
// only lookup in the cache if the requiredVersion is set | ||
if requiredVersion != nil { | ||
if config, ok := c.configs[*requiredVersion]; ok { | ||
return copyConfig(config), nil | ||
|
@@ -119,11 +106,21 @@ func (c *ClientCache) clientConfigForVersion(requiredVersion *schema.GroupVersio | |
return copyConfig(c.noVersionConfig), nil | ||
} | ||
|
||
negotiatedVersion, err := discovery.NegotiateVersion(discoveryClient, requiredVersion, api.Registry.EnabledVersions()) | ||
// this returns a shallow copy to work with | ||
config, discoveryClient, err := c.getDefaultConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
config.GroupVersion = negotiatedVersion | ||
|
||
if requiredVersion != nil { | ||
if err := discovery.ServerSupportsVersion(discoveryClient, *requiredVersion); err != nil { | ||
return nil, err | ||
} | ||
config.GroupVersion = requiredVersion | ||
} else { | ||
// TODO remove this hack. This is allowing the GetOptions to be serialized. | ||
config.GroupVersion = &schema.GroupVersion{Group: "", Version: "v1"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to set Group: "" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
liggitt prefers it to be explicit. I don't really care either way. |
||
} | ||
|
||
// TODO this isn't what we want. Each clientset should be setting defaults as it sees fit. | ||
oldclient.SetKubernetesDefaults(&config) | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
do we want to glog when this is nil to help tracing?
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.
I think we want to go the other way around. Someday, someone will allow the groupVersion to be nil and chase the panics.