| 95 | } |
| 96 | |
| 97 | func New() *EnvSettings { |
| 98 | env := &EnvSettings{ |
| 99 | namespace: os.Getenv("HELM_NAMESPACE"), |
| 100 | MaxHistory: envIntOr("HELM_MAX_HISTORY", defaultMaxHistory), |
| 101 | KubeConfig: os.Getenv("KUBECONFIG"), |
| 102 | KubeContext: os.Getenv("HELM_KUBECONTEXT"), |
| 103 | KubeToken: os.Getenv("HELM_KUBETOKEN"), |
| 104 | KubeAsUser: os.Getenv("HELM_KUBEASUSER"), |
| 105 | KubeAsGroups: envCSV("HELM_KUBEASGROUPS"), |
| 106 | KubeAPIServer: os.Getenv("HELM_KUBEAPISERVER"), |
| 107 | KubeCaFile: os.Getenv("HELM_KUBECAFILE"), |
| 108 | KubeTLSServerName: os.Getenv("HELM_KUBETLS_SERVER_NAME"), |
| 109 | KubeInsecureSkipTLSVerify: envBoolOr("HELM_KUBEINSECURE_SKIP_TLS_VERIFY", false), |
| 110 | PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")), |
| 111 | RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry/config.json")), |
| 112 | RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")), |
| 113 | RepositoryCache: envOr("HELM_REPOSITORY_CACHE", helmpath.CachePath("repository")), |
| 114 | ContentCache: envOr("HELM_CONTENT_CACHE", helmpath.CachePath("content")), |
| 115 | BurstLimit: envIntOr("HELM_BURST_LIMIT", defaultBurstLimit), |
| 116 | QPS: envFloat32Or("HELM_QPS", defaultQPS), |
| 117 | ColorMode: envColorMode(), |
| 118 | } |
| 119 | env.Debug, _ = strconv.ParseBool(os.Getenv("HELM_DEBUG")) |
| 120 | |
| 121 | // bind to kubernetes config flags |
| 122 | config := &genericclioptions.ConfigFlags{ |
| 123 | Namespace: &env.namespace, |
| 124 | Context: &env.KubeContext, |
| 125 | BearerToken: &env.KubeToken, |
| 126 | APIServer: &env.KubeAPIServer, |
| 127 | CAFile: &env.KubeCaFile, |
| 128 | KubeConfig: &env.KubeConfig, |
| 129 | Impersonate: &env.KubeAsUser, |
| 130 | Insecure: &env.KubeInsecureSkipTLSVerify, |
| 131 | TLSServerName: &env.KubeTLSServerName, |
| 132 | ImpersonateGroup: &env.KubeAsGroups, |
| 133 | WrapConfigFn: func(config *rest.Config) *rest.Config { |
| 134 | config.Burst = env.BurstLimit |
| 135 | config.QPS = env.QPS |
| 136 | config.Wrap(func(rt http.RoundTripper) http.RoundTripper { |
| 137 | return &kubeenv.RetryingRoundTripper{Wrapped: rt} |
| 138 | }) |
| 139 | config.UserAgent = version.GetUserAgent() |
| 140 | return config |
| 141 | }, |
| 142 | } |
| 143 | if env.BurstLimit != defaultBurstLimit { |
| 144 | config = config.WithDiscoveryBurst(env.BurstLimit) |
| 145 | } |
| 146 | env.config = config |
| 147 | |
| 148 | return env |
| 149 | } |
| 150 | |
| 151 | // AddFlags binds flags to the given flagset. |
| 152 | func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) { |