Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

ref(*): Use HELMC_HOME instead of HELM_HOME #460

Merged
merged 1 commit into from May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions action/generate.go
Expand Up @@ -20,6 +20,9 @@ func Generate(chart, homedir string, exclude []string, force bool) {
}
chartPath := util.WorkspaceChartDirectory(homedir, chart)

// Although helmc itself may use the new HELMC_HOME environment variable to optionally define its
// home directory, to maintain compatibility with charts created for the ORIGINAL helm, we
// continue to support expansion of these "legacy" environment variables, including HELM_HOME.
os.Setenv("HELM_HOME", homedir)
os.Setenv("HELM_DEFAULT_REPO", mustConfig(homedir).Repos.Default)
os.Setenv("HELM_FORCE_FLAG", strconv.FormatBool(force))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we be setting the values for the HELMC_HOME and others so that when new charts are created and uses $HELMC_HOME it works?

Copy link
Contributor Author

@krancour krancour May 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New charts should continue to use HELM_HOME. If people start using HELMC_HOME in charts, those charts won't work with older / original helm. This is addressed in the updated documentation I have also PR'ed. It ensures both backwards and forwards compatibility.

Re: whether we might want to additionally set HELMC_HOME, I believe the answer is no. Existing environment variables do get expanded here. This means if someone has HELMC_HOME set to a custom value, it will be properly inherited and interpreted by any possible invocation of the helmc binary in the generator header. If it is absent, the invocation of the helmc binary in the generator header will use the default helmc home dir, just as the initial invocation of helmc (by the user) would have.

The only thing we'd gain by setting HELMC_HOME is that chart authors would be able to use it for some custom command like the following:

#helm:generate sed -i s/foo/bar/ $HELMC_HOME/blah/blah

And that is precisely the thing we don't want chart authors doing because it will break their chart's compatibility with older / original helm. I feel that if we don't want them doing that, we shouldn't encourage that mistake by unnecessarily injecting a value into the HELMC_HOME env var when generators are invoked.

Expand Down
4 changes: 4 additions & 0 deletions action/plugin.go
Expand Up @@ -24,6 +24,10 @@ func Plugin(homedir, cmd string, args []string) {
if abs, err := filepath.Abs(homedir); err == nil {
homedir = abs
}

// Although helmc itself may use the new HELMC_HOME environment variable to optionally define its
// home directory, to maintain compatibility with plugins created for the ORIGINAL helm, we
// continue to support expansion of these "legacy" environment variables, including HELM_HOME.
os.Setenv("HELM_HOME", homedir)
os.Setenv("HELM_COMMAND", args[0])
os.Setenv("HELM_DEFAULT_REPO", mustConfig(homedir).Repos.Default)
Expand Down
8 changes: 4 additions & 4 deletions cli/helm.go
Expand Up @@ -32,8 +32,8 @@ include:
For more information on Helm, go to http://helm.sh.

ENVIRONMENT:
$HELM_HOME: Set an alternative location for Helm files. By default, these
are stored in ~/.helm
$HELMC_HOME: Set an alternative location for Helm files. By default, these
are stored in ~/.helmc

`

Expand All @@ -54,9 +54,9 @@ func Cli() *cli.App {
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "home",
Value: "$HOME/.helm",
Value: "$HOME/.helmc",
Usage: "The location of your Helm files",
EnvVar: "HELM_HOME",
EnvVar: "HELMC_HOME",
},
cli.BoolFlag{
Name: "debug",
Expand Down
4 changes: 2 additions & 2 deletions cli/update.go
Expand Up @@ -6,8 +6,8 @@ import (
)

const updateDescription = `This will synchronize the local repository with the upstream GitHub project.
The local cached copy is stored in '~/.helm/cache' or (if specified)
'$HELM_HOME/cache'.
The local cached copy is stored in '~/.helmc/cache' or (if specified)
'$HELMC_HOME/cache'.

The first time 'helm update' is run, the necessary directory structures are
created and then the Git repository is pulled in full.
Expand Down
2 changes: 1 addition & 1 deletion dependency/dependency.go
Expand Up @@ -15,7 +15,7 @@ import (
// Resolve takes a chart and a location and checks whether the chart's dependencies are satisfied.
//
// The `installdir` is the location where installed charts are located. Typically
// this is in $HELM_HOME/workspace/charts.
// this is in $HELMC_HOME/workspace/charts.
//
// This returns a list of unsatisfied dependencies (NOT an error condition).
//
Expand Down
3 changes: 3 additions & 0 deletions plugins/example/helm-example.go
Expand Up @@ -7,6 +7,9 @@ import (

func main() {
fmt.Printf("Args are: %v\n", os.Args)
// Although helmc itself may use the new HELMC_HOME environment variable to optionally define its
// home directory, to maintain compatibility with charts created for the ORIGINAL helm, helmc
// still expands "legacy" Helm environment variables, which Helm Classic plugins continue to use.
fmt.Printf("Helm home is: %s\n", os.Getenv("HELM_HOME"))
fmt.Printf("Helm command is: %s\n", os.Getenv("HELM_COMMAND"))
fmt.Printf("Helm default repo is: %s\n", os.Getenv("HELM_DEFAULT_REPO"))
Expand Down
4 changes: 2 additions & 2 deletions test/helm.go
Expand Up @@ -23,9 +23,9 @@ const tmpConfigfile = `repos:
// HelmRoot - dir root of the project
var HelmRoot = filepath.Join(os.Getenv("GOPATH"), "src/github.com/helm/helm-classic/")

// CreateTmpHome create a temporary directory for $HELM_HOME
// CreateTmpHome create a temporary directory for $HELMC_HOME
func CreateTmpHome() string {
tmpHome, _ := ioutil.TempDir("", "helm_home")
tmpHome, _ := ioutil.TempDir("", "helmc_home")
defer os.Remove(tmpHome)
return tmpHome
}
Expand Down
2 changes: 1 addition & 1 deletion util/helm.go
Expand Up @@ -21,7 +21,7 @@ const DefaultConfigfile = `repos:
workspace:
`

// EnsureHome ensures that a HELM_HOME exists.
// EnsureHome ensures that a HELMC_HOME exists.
func EnsureHome(home string) {

must := []string{home, CacheDirectory(home), filepath.Join(home, workspacePath)}
Expand Down