Commit 23905f14 authored by Jerry Zhou's avatar Jerry Zhou Committed by z00417096 zhoujaiwei

feat(helm):use a variable for labels to get tiller pod

parent e61ee5c5
...@@ -29,6 +29,10 @@ import ( ...@@ -29,6 +29,10 @@ import (
"k8s.io/helm/pkg/kube" "k8s.io/helm/pkg/kube"
) )
var (
tillerPodLabels labels.Set = labels.Set{"app": "helm", "name": "tiller"}
)
// New creates a new and initialized tunnel. // New creates a new and initialized tunnel.
func New(namespace string, client kubernetes.Interface, config *rest.Config) (*kube.Tunnel, error) { func New(namespace string, client kubernetes.Interface, config *rest.Config) (*kube.Tunnel, error) {
podName, err := getTillerPodName(client.CoreV1(), namespace) podName, err := getTillerPodName(client.CoreV1(), namespace)
...@@ -41,8 +45,7 @@ func New(namespace string, client kubernetes.Interface, config *rest.Config) (*k ...@@ -41,8 +45,7 @@ func New(namespace string, client kubernetes.Interface, config *rest.Config) (*k
} }
func getTillerPodName(client corev1.PodsGetter, namespace string) (string, error) { func getTillerPodName(client corev1.PodsGetter, namespace string) (string, error) {
// TODO use a const for labels selector := tillerPodLabels.AsSelector()
selector := labels.Set{"app": "helm", "name": "tiller"}.AsSelector()
pod, err := getFirstRunningPod(client, namespace, selector) pod, err := getFirstRunningPod(client, namespace, selector)
if err != nil { if err != nil {
return "", err return "", err
......
...@@ -29,7 +29,7 @@ func mockTillerPod() v1.Pod { ...@@ -29,7 +29,7 @@ func mockTillerPod() v1.Pod {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: "orca", Name: "orca",
Namespace: v1.NamespaceDefault, Namespace: v1.NamespaceDefault,
Labels: map[string]string{"app": "helm", "name": "tiller"}, Labels: tillerPodLabels,
}, },
Status: v1.PodStatus{ Status: v1.PodStatus{
Phase: v1.PodRunning, Phase: v1.PodRunning,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment