github.com/zoumo/helm@v2.5.0+incompatible/pkg/helm/environment/environment.go (about)

     1  /*
     2  Copyright 2016 The Kubernetes Authors All rights reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  /*Package environment describes the operating environment for Tiller.
    18  
    19  Tiller's environment encapsulates all of the service dependencies Tiller has.
    20  These dependencies are expressed as interfaces so that alternate implementations
    21  (mocks, etc.) can be easily generated.
    22  */
    23  package environment
    24  
    25  import (
    26  	"os"
    27  	"path/filepath"
    28  
    29  	"k8s.io/helm/pkg/helm/helmpath"
    30  )
    31  
    32  const (
    33  	// HomeEnvVar is the HELM_HOME environment variable key.
    34  	HomeEnvVar = "HELM_HOME"
    35  	// PluginEnvVar is the HELM_PLUGIN environment variable key.
    36  	PluginEnvVar = "HELM_PLUGIN"
    37  	// PluginDisableEnvVar is the HELM_NO_PLUGINS environment variable key.
    38  	PluginDisableEnvVar = "HELM_NO_PLUGINS"
    39  	// HostEnvVar is the HELM_HOST environment variable key.
    40  	HostEnvVar = "HELM_HOST"
    41  	// DebugEnvVar is the HELM_DEBUG environment variable key.
    42  	DebugEnvVar = "HELM_DEBUG"
    43  )
    44  
    45  // DefaultHelmHome is the default HELM_HOME.
    46  var DefaultHelmHome = filepath.Join("$HOME", ".helm")
    47  
    48  // EnvSettings describes all of the environment settings.
    49  type EnvSettings struct {
    50  	// TillerHost is the host and port of Tiller.
    51  	TillerHost string
    52  	// TillerNamespace is the namespace in which Tiller runs.
    53  	TillerNamespace string
    54  	// Home is the local path to the Helm home directory.
    55  	Home helmpath.Home
    56  	// Debug indicates whether or not Helm is running in Debug mode.
    57  	Debug bool
    58  }
    59  
    60  // PluginDirs is the path to the plugin directories.
    61  func (s EnvSettings) PluginDirs() string {
    62  	if d := os.Getenv(PluginEnvVar); d != "" {
    63  		return d
    64  	}
    65  	return s.Home.Plugins()
    66  }