Skip to content

Commit

Permalink
Merge pull request #176 from gridscale/bugfix/fix-invalid-kubeconfig-…
Browse files Browse the repository at this point in the history
…due-to-escaped-newline-chars-in-kubeconfigStr

Fix invalid kubeconfig when \\n is present in kubeconfigStr
  • Loading branch information
nvthongswansea authored Jul 16, 2024
2 parents 3877795 + 6aff3fe commit 40bd0e2
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 40bd0e2

Please sign in to comment.