Skip to content

Commit

Permalink
fix invalid kubeconfig when \\n is present in kubeconfigStr
Browse files Browse the repository at this point in the history
replace "\\n" with "\n" in kubeconfig string
  • Loading branch information
nvthongswansea committed Jul 16, 2024
1 parent 3877795 commit 6aff3fe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"
"time"

"github.com/gridscale/gscloud/render"
Expand Down Expand Up @@ -298,7 +299,10 @@ func fetchKubeConfigFromProvider(op runtime.KubernetesOperator, id string) (kube
}

if len(platformService.Properties.Credentials) != 0 {
err := yaml.Unmarshal([]byte(platformService.Properties.Credentials[0].KubeConfig), &kc)
kubeconfigStr := platformService.Properties.Credentials[0].KubeConfig
// replace "\\n" with "\n" in kubeconfig (if present)
kubeconfigStr = strings.ReplaceAll(kubeconfigStr, "\\n", "\n")
err := yaml.Unmarshal([]byte(kubeconfigStr), &kc)
if err != nil {
return kubeConfig{}, time.Time{}, err
}
Expand Down

0 comments on commit 6aff3fe

Please sign in to comment.