mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
make kubernetes plugin kubeconfig argument 'context' optional (#4451)
Signed-off-by: answer1991 <answer1991.chen@gmail.com>
This commit is contained in:
@@ -253,15 +253,18 @@ func ParseStanza(c *caddy.Controller) (*Kubernetes, error) {
|
||||
}
|
||||
case "kubeconfig":
|
||||
args := c.RemainingArgs()
|
||||
if len(args) == 2 {
|
||||
config := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: args[0]},
|
||||
&clientcmd.ConfigOverrides{CurrentContext: args[1]},
|
||||
)
|
||||
k8s.ClientConfig = config
|
||||
continue
|
||||
if len(args) != 1 && len(args) != 2 {
|
||||
return nil, c.ArgErr()
|
||||
}
|
||||
return nil, c.ArgErr()
|
||||
overrides := &clientcmd.ConfigOverrides{}
|
||||
if len(args) == 2 {
|
||||
overrides.CurrentContext = args[1]
|
||||
}
|
||||
config := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: args[0]},
|
||||
overrides,
|
||||
)
|
||||
k8s.ClientConfig = config
|
||||
default:
|
||||
return nil, c.Errf("unknown property '%s'", c.Val())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user