Skip to content

Commit

Permalink
Fixed error in kub/config template
Browse files Browse the repository at this point in the history
  • Loading branch information
fd committed May 4, 2016
1 parent 84d7cc3 commit 84880e3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/k8s/gcp_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package main

import (
"bytes"
"io/ioutil"
"os"
"path"
"text/template"

"golang.org/x/oauth2"
Expand All @@ -28,18 +26,21 @@ func gcpLogin(app *kingpin.Application, gcpProjectID, gcpZone, gkeCluster string
err = k8sConfigTmpl.Execute(&buf, cluster)
app.FatalIfError(err, "k8s")

err = os.MkdirAll(path.Join(os.Getenv("HOME"), ".kube"), 0755)
app.FatalIfError(err, "k8s")
buf.WriteTo(os.Stdout)

err = ioutil.WriteFile(path.Join(os.Getenv("HOME"), ".kube/config"), buf.Bytes(), 0600)
app.FatalIfError(err, "k8s")
// err = os.MkdirAll(path.Join(os.Getenv("HOME"), ".kube"), 0755)
// app.FatalIfError(err, "k8s")
//
// err = ioutil.WriteFile(path.Join(os.Getenv("HOME"), ".kube/config"), buf.Bytes(), 0600)
// app.FatalIfError(err, "k8s")
}

var k8sConfigTmpl = template.Must(template.New("").Parse(`
apiVersion: v1
kind: Config
preferences: {}
current-context: k8s-context
contexts:
- context:
cluster: k8s-cluster
user: k8s-user
Expand All @@ -49,7 +50,6 @@ clusters:
certificate-authority-data: {{.MasterAuth.ClusterCaCertificate}}
server: https://{{.Endpoint}}
name: k8s-cluster
contexts:
users:
- name: k8s-user
user:
Expand Down

0 comments on commit 84880e3

Please sign in to comment.