Skip to content

Commit

Permalink
Fix getting services in expose cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Kargakis committed Apr 28, 2015
1 parent 7a122a4 commit e6ee32a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/kubectl/cmd/util/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,23 @@ func NewFactory(optionalClientConfig clientcmd.ClientConfig) *Factory {
}
return kubectl.MakeLabels(rc.Spec.Selector), nil
case "Pod":
rc, err := client.Pods(namespace).Get(name)
pod, err := client.Pods(namespace).Get(name)
if err != nil {
return "", err
}
if len(rc.Labels) == 0 {
if len(pod.Labels) == 0 {
return "", fmt.Errorf("the pod has no labels and cannot be exposed")
}
return kubectl.MakeLabels(rc.Labels), nil
return kubectl.MakeLabels(pod.Labels), nil
case "Service":
rc, err := client.ReplicationControllers(namespace).Get(name)
svc, err := client.Services(namespace).Get(name)
if err != nil {
return "", err
}
if rc.Spec.Selector == nil {
if svc.Spec.Selector == nil {
return "", fmt.Errorf("the service has no pod selector set")
}
return kubectl.MakeLabels(rc.Spec.Selector), nil
return kubectl.MakeLabels(svc.Spec.Selector), nil
default:
return "", fmt.Errorf("it is not possible to get a pod selector from %s", mapping.Kind)
}
Expand Down

0 comments on commit e6ee32a

Please sign in to comment.