Skip to content

Commit

Permalink
Merge pull request #133 from lpabon/certdata
Browse files Browse the repository at this point in the history
Save ca data
  • Loading branch information
lpabon authored Mar 20, 2020
2 parents 2a06486 + cf22782 commit a1d9dc0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions handler/config/cluster_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/kubernetes/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]:")
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubernetes/portforward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand All @@ -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",
},
}

Expand Down

0 comments on commit a1d9dc0

Please sign in to comment.