Skip to content

Commit

Permalink
expand home directory
Browse files Browse the repository at this point in the history
  • Loading branch information
LilliJane committed May 18, 2018
1 parent 0d5dd4b commit 9cd0097
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/opts.go
Expand Up @@ -84,6 +84,13 @@ func NewDeps(logs svc.Logger, kopts KubeOpts) (*Deps, error) {
kopts.KubeConfig = filepath.Join(hdir, ".kube", "config")
}

var err error
kopts.KubeConfig, err = homedir.Expand(kopts.KubeConfig)
if err != nil {
return nil, errors.Wrap(err, "failed to expand home directory in kube config file path")
}
//Normalize all slashes to native platform slashes (e.g. / to \ on Windows)
kopts.KubeConfig = filepath.FromSlash(kopts.KubeConfig)
kcfg, err := clientcmd.BuildConfigFromFlags("", kopts.KubeConfig)
if err != nil {
if os.IsNotExist(err) {
Expand Down
6 changes: 5 additions & 1 deletion pkg/populator/generic.go
Expand Up @@ -69,7 +69,11 @@ func (o *GenericPopulator) PopulateKubeConfig(namespace string) error {
if o.cluster.CaCertificate == "" {
c.InsecureSkipTLSVerify = true
} else {
c.CertificateAuthorityData = []byte(o.cluster.CaCertificate)
data, err := base64.StdEncoding.DecodeString(o.cluster.CaCertificate)
if err != nil {
return err
}
c.CertificateAuthorityData = data
}
c.Server = o.cluster.ServiceURL

Expand Down

0 comments on commit 9cd0097

Please sign in to comment.