diff --git a/handler/config/cluster_set.go b/handler/config/cluster_set.go index 04905066..1c91b4d8 100644 --- a/handler/config/cluster_set.go +++ b/handler/config/cluster_set.go @@ -16,6 +16,9 @@ limitations under the License. package configcli import ( + "fmt" + "io/ioutil" + "github.com/portworx/pxc/pkg/commander" "github.com/portworx/pxc/pkg/config" "github.com/portworx/pxc/pkg/util" @@ -69,6 +72,14 @@ var _ = commander.RegisterCommandInit(func() { func clusterSetExec(cmd *cobra.Command, args []string) error { + if len(clusterSet.CACert) != 0 { + var err error + clusterSet.CACertData, err = ioutil.ReadFile(clusterSet.CACert) + if err != nil { + return fmt.Errorf("Failed to read %s: %v", clusterSet.CACert, err) + } + } + if err := config.CM().ConfigSaveCluster(clusterSet); err != nil { return err } diff --git a/pkg/kubernetes/portforward.go b/pkg/kubernetes/portforward.go index 5c0c11ec..02fe1c7e 100644 --- a/pkg/kubernetes/portforward.go +++ b/pkg/kubernetes/portforward.go @@ -149,7 +149,10 @@ func (p *KubectlPortForwarder) Endpoint() string { func (p *KubectlPortForwarder) getEndpointFromKubectlOutput(sbuf string) (string, error) { index := strings.Index(sbuf, "127.0.0.1:") if index >= 0 { - return strings.Split(sbuf[index:], " ")[0], nil + //return strings.Split(sbuf[index:], " ")[0], nil + e := strings.Split(sbuf[index:], " ")[0] + e = "localhost:" + strings.Split(e, ":")[1] + return e, nil } index = strings.Index(sbuf, "[::1]:") diff --git a/pkg/kubernetes/portforward_test.go b/pkg/kubernetes/portforward_test.go index 3e5fc7f7..3f739bad 100644 --- a/pkg/kubernetes/portforward_test.go +++ b/pkg/kubernetes/portforward_test.go @@ -43,7 +43,7 @@ func TestGetEndpointFromKubectlOutput(t *testing.T) { }{ { expectFailure: false, - expectedOutput: "127.0.0.1:12345", + expectedOutput: "localhost:12345", buffer: " Forwarding from 127.0.0.1:12345 --> 9020", }, { @@ -62,7 +62,7 @@ func TestGetEndpointFromKubectlOutput(t *testing.T) { { expectFailure: false, buffer: "Forwarding from 127.0.0.1:41240 -> 9020\n Forwarding from [::1]:41240 -> 9020", - expectedOutput: "127.0.0.1:41240", + expectedOutput: "localhost:41240", }, }