Skip to content

Commit

Permalink
Always use the absolute path of helmfile_release_set.kubeconfig (#46)
Browse files Browse the repository at this point in the history
This turned out to be more intuitive when you use sub-helmfiles, due to that each sub-helmfile uses the KUBECONFIG relative to it by the nature of Helmfile.

Since this commit, any helmfile command run by this provider can be treated as `KUBECONFIG=$(pwd)/<helmfile_release_set kubecondfig attr> helmfile blah`.
  • Loading branch information
mumoshu authored Nov 9, 2020
1 parent bc940c1 commit 5f0e6af
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/helmfile/release_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"crypto/sha256"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"golang.org/x/xerrors"
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -193,6 +194,8 @@ func NewCommandWithKubeconfig(fs *ReleaseSet, args ...string) (*exec.Cmd, error)
}

func getKubeconfig(fs *ReleaseSet) (*string, error) {
var rel string

att := fs.Kubeconfig

var env string
Expand All @@ -205,10 +208,18 @@ func getKubeconfig(fs *ReleaseSet) (*string, error) {
if env != "" {
return nil, fmt.Errorf("validating release set: helmfile_release_set.environment_variables.KUBECONFIG cannot be set with helmfile_release_set.kubeconfig")
}
return &att, nil

rel = att
} else {
rel = env
}

abs, err := filepath.Abs(rel)
if err != nil {
return nil, xerrors.Errorf("determining absolute path for kubeconfig path %s: %w", rel, err)
}

return &env, nil
return &abs, nil
}

func CreateReleaseSet(fs *ReleaseSet, d ResourceReadWrite) error {
Expand Down

0 comments on commit 5f0e6af

Please sign in to comment.