Skip to content

Commit

Permalink
Federation - common libs - get clientset for cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
mwielgus committed Aug 11, 2016
1 parent 035ec51 commit 8b53924
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions federation/pkg/federation-controller/util/cluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/golang/glog"
federation_v1beta1 "k8s.io/kubernetes/federation/apis/federation/v1beta1"
federation_release_1_4 "k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_4"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/restclient"
client "k8s.io/kubernetes/pkg/client/unversioned"
Expand Down Expand Up @@ -130,3 +131,13 @@ var KubeconfigGetterForSecret = func(secretName string) clientcmd.KubeconfigGett
return clientcmd.Load(data)
}
}

// Retruns Clientset for the given cluster.
func GetClientsetForCluster(cluster *federation_v1beta1.Cluster) (*federation_release_1_4.Clientset, error) {
clusterConfig, err := BuildClusterConfig(cluster)
if err != nil && clusterConfig != nil {
clientset := federation_release_1_4.NewForConfigOrDie(restclient.AddUserAgent(clusterConfig, userAgentName))
return clientset, nil
}
return nil, err
}

0 comments on commit 8b53924

Please sign in to comment.