Differentiate between server error messages and client error messages in kubectl

This commit is contained in:
Brendan Burns
2015-03-03 16:24:29 -08:00
parent 53ec66caf4
commit f505a33998
22 changed files with 142 additions and 114 deletions

View File

@@ -22,6 +22,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/portforward"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/util"
"github.com/golang/glog"
"github.com/spf13/cobra"
)
@@ -61,20 +62,20 @@ func (f *Factory) NewCmdPortForward() *cobra.Command {
}
namespace, err := f.DefaultNamespace(cmd)
checkErr(err)
util.CheckErr(err)
client, err := f.Client(cmd)
checkErr(err)
util.CheckErr(err)
pod, err := client.Pods(namespace).Get(flags.pod)
checkErr(err)
util.CheckErr(err)
if pod.Status.Phase != api.PodRunning {
glog.Fatalf("Unable to execute command because pod is not running. Current status=%v", pod.Status.Phase)
}
config, err := f.ClientConfig(cmd)
checkErr(err)
util.CheckErr(err)
signals := make(chan os.Signal, 1)
signal.Notify(signals, os.Interrupt)
@@ -93,10 +94,10 @@ func (f *Factory) NewCmdPortForward() *cobra.Command {
Suffix("portForward", namespace, flags.pod)
pf, err := portforward.New(req, config, args, stopCh)
checkErr(err)
util.CheckErr(err)
err = pf.ForwardPorts()
checkErr(err)
util.CheckErr(err)
},
}
cmd.Flags().StringVarP(&flags.pod, "pod", "p", "", "Pod name")