Skip to content

Commit 7f3d3e6

Browse files
Merge pull request kubernetes#18956 from deads2k/up-21-componentinstall
Automatic merge from submit-queue. make registry installation a component Demonstrate a simple way of making a component and installing it. This builds on previous pulls and shows how we can start define an interface. I think after we switch pieces over, we'll find points of commonality as their entry points. I suspect they will include: 1. cluster-admin.kubeconfig 2. docker helper? We should try to switch this to actually installing with pods. 3. uninstall API. Something to remove it anyway. 4. idempotent. We will call it *on every cluster up* /assign @mfojtik /assign @soltysh Origin-commit: eb016b358623b0d6c672ba1c3cfcfa1b20f1970b
2 parents b9d40fd + 0068458 commit 7f3d3e6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

staging/src/k8s.io/client-go/tools/clientcmd/client_config.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ func NewInteractiveClientConfig(config clientcmdapi.Config, contextName string,
100100
return &DirectClientConfig{config, contextName, overrides, fallbackReader, configAccess, promptedCredentials{}}
101101
}
102102

103+
// NewClientConfigFromBytes takes your kubeconfig and gives you back a ClientConfig
104+
func NewClientConfigFromBytes(configBytes []byte) (ClientConfig, error) {
105+
config, err := Load(configBytes)
106+
if err != nil {
107+
return nil, err
108+
}
109+
110+
return &DirectClientConfig{*config, "", &ConfigOverrides{}, nil, nil, promptedCredentials{}}, nil
111+
}
112+
113+
// RESTConfigFromKubeConfig is a convenience method to give back a restconfig from your kubeconfig bytes.
114+
// For programmatic access, this is what you want 80% of the time
115+
func RESTConfigFromKubeConfig(configBytes []byte) (*restclient.Config, error) {
116+
clientConfig, err := NewClientConfigFromBytes(configBytes)
117+
if err != nil {
118+
return nil, err
119+
}
120+
return clientConfig.ClientConfig()
121+
}
122+
103123
func (config *DirectClientConfig) RawConfig() (clientcmdapi.Config, error) {
104124
return config.config, nil
105125
}

0 commit comments

Comments
 (0)