File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,10 @@ func (c *Client) WithMetricLabels(labels map[string]string) {
129129 c .metricLabels = labels
130130}
131131
132+ func (c * Client ) WithRestConfig (config * rest.Config ) {
133+ c .restConfig = config
134+ }
135+
132136func (c * Client ) DefaultNamespace () string {
133137 return c .defaultNamespace
134138}
@@ -160,7 +164,12 @@ func (c *Client) Init() error {
160164 configType := "out-of-cluster"
161165 var defaultNs string
162166
163- if c .server == "" {
167+ switch {
168+ case c .restConfig != nil :
169+ config = c .restConfig
170+ defaultNs = "default"
171+ configType = "server"
172+ case c .server == "" :
164173 // Try to load from kubeconfig in flags or from ~/.kube/config
165174 var outOfClusterErr error
166175 config , defaultNs , outOfClusterErr = getOutOfClusterConfig (c .contextName , c .configPath )
@@ -191,7 +200,7 @@ func (c *Client) Init() error {
191200 }
192201 configType = "in-cluster"
193202 }
194- } else {
203+ default :
195204 // use specific server to connect to API
196205 config = & rest.Config {
197206 Host : c .server ,
You can’t perform that action at this time.
0 commit comments