...
1
16
17 package genericclioptions
18
19 import (
20 restclient "k8s.io/client-go/rest"
21 "k8s.io/client-go/tools/clientcmd"
22 clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
23 )
24
25 var (
26
27 ErrEmptyConfig = clientcmd.NewEmptyConfigError(`Missing or incomplete configuration info. Please point to an existing, complete config file:
28
29
30 1. Via the command-line flag --kubeconfig
31 2. Via the KUBECONFIG environment variable
32 3. In your home directory as ~/.kube/config
33
34 To view or setup config directly use the 'config' command.`)
35 )
36
37 var _ = clientcmd.ClientConfig(&clientConfig{})
38
39 type clientConfig struct {
40 defaultClientConfig clientcmd.ClientConfig
41 }
42
43 func (c *clientConfig) RawConfig() (clientcmdapi.Config, error) {
44 config, err := c.defaultClientConfig.RawConfig()
45
46 if clientcmd.IsEmptyConfig(err) {
47 return config, ErrEmptyConfig
48 }
49 return config, err
50 }
51
52 func (c *clientConfig) ClientConfig() (*restclient.Config, error) {
53 config, err := c.defaultClientConfig.ClientConfig()
54
55 if clientcmd.IsEmptyConfig(err) {
56 return config, ErrEmptyConfig
57 }
58 return config, err
59 }
60
61 func (c *clientConfig) Namespace() (string, bool, error) {
62 namespace, ok, err := c.defaultClientConfig.Namespace()
63
64 if clientcmd.IsEmptyConfig(err) {
65 return namespace, ok, ErrEmptyConfig
66 }
67 return namespace, ok, err
68 }
69
70 func (c *clientConfig) ConfigAccess() clientcmd.ConfigAccess {
71 return c.defaultClientConfig.ConfigAccess()
72 }
73
View as plain text