1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 13:29:11 +01:00

Refactor code around utils and client.

This commit is contained in:
Avesh Agarwal
2017-07-31 18:54:26 -04:00
parent 5df7cb85d4
commit fe91cca2f3
2 changed files with 18 additions and 26 deletions

View File

@@ -15,26 +15,3 @@ limitations under the License.
*/
package utils
import (
"fmt"
"k8s.io/client-go/tools/clientcmd"
)
func GetMasterFromKubeconfig(filename string) (string, error) {
config, err := clientcmd.LoadFromFile(filename)
if err != nil {
return "", err
}
context, ok := config.Contexts[config.CurrentContext]
if !ok {
return "", fmt.Errorf("Failed to get master address from kubeconfig")
}
if val, ok := config.Clusters[context.Cluster]; ok {
return val.Server, nil
}
return "", fmt.Errorf("Failed to get master address from kubeconfig")
}