@ -30,6 +30,7 @@ import (
"github.com/spf13/pflag"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/rest"
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/helmpath"
)
)
@ -37,6 +38,9 @@ import (
// defaultMaxHistory sets the maximum number of releases to 0: unlimited
// defaultMaxHistory sets the maximum number of releases to 0: unlimited
const defaultMaxHistory = 10
const defaultMaxHistory = 10
// defaultBurstLimit sets the default client-side throttling limit
const defaultBurstLimit = 250
// EnvSettings describes all of the environment settings.
// EnvSettings describes all of the environment settings.
type EnvSettings struct {
type EnvSettings struct {
namespace string
namespace string
@ -68,6 +72,8 @@ type EnvSettings struct {
PluginsDirectory string
PluginsDirectory string
// MaxHistory is the max release history maintained.
// MaxHistory is the max release history maintained.
MaxHistory int
MaxHistory int
// DefaultBurstLimit is the default client-side throttling limit.
DefaultBurstLimit int
}
}
func New ( ) * EnvSettings {
func New ( ) * EnvSettings {
@ -84,6 +90,7 @@ func New() *EnvSettings {
RegistryConfig : envOr ( "HELM_REGISTRY_CONFIG" , helmpath . ConfigPath ( "registry/config.json" ) ) ,
RegistryConfig : envOr ( "HELM_REGISTRY_CONFIG" , helmpath . ConfigPath ( "registry/config.json" ) ) ,
RepositoryConfig : envOr ( "HELM_REPOSITORY_CONFIG" , helmpath . ConfigPath ( "repositories.yaml" ) ) ,
RepositoryConfig : envOr ( "HELM_REPOSITORY_CONFIG" , helmpath . ConfigPath ( "repositories.yaml" ) ) ,
RepositoryCache : envOr ( "HELM_REPOSITORY_CACHE" , helmpath . CachePath ( "repository" ) ) ,
RepositoryCache : envOr ( "HELM_REPOSITORY_CACHE" , helmpath . CachePath ( "repository" ) ) ,
DefaultBurstLimit : envIntOr ( "HELM_DEFAULT_BURST_LIMIT" , defaultBurstLimit ) ,
}
}
env . Debug , _ = strconv . ParseBool ( os . Getenv ( "HELM_DEBUG" ) )
env . Debug , _ = strconv . ParseBool ( os . Getenv ( "HELM_DEBUG" ) )
@ -97,6 +104,10 @@ func New() *EnvSettings {
KubeConfig : & env . KubeConfig ,
KubeConfig : & env . KubeConfig ,
Impersonate : & env . KubeAsUser ,
Impersonate : & env . KubeAsUser ,
ImpersonateGroup : & env . KubeAsGroups ,
ImpersonateGroup : & env . KubeAsGroups ,
WrapConfigFn : func ( config * rest . Config ) * rest . Config {
config . Burst = env . DefaultBurstLimit
return config
} ,
}
}
return env
return env
}
}
@ -115,6 +126,7 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
fs . StringVar ( & s . RegistryConfig , "registry-config" , s . RegistryConfig , "path to the registry config file" )
fs . StringVar ( & s . RegistryConfig , "registry-config" , s . RegistryConfig , "path to the registry config file" )
fs . StringVar ( & s . RepositoryConfig , "repository-config" , s . RepositoryConfig , "path to the file containing repository names and URLs" )
fs . StringVar ( & s . RepositoryConfig , "repository-config" , s . RepositoryConfig , "path to the file containing repository names and URLs" )
fs . StringVar ( & s . RepositoryCache , "repository-cache" , s . RepositoryCache , "path to the file containing cached repository indexes" )
fs . StringVar ( & s . RepositoryCache , "repository-cache" , s . RepositoryCache , "path to the file containing cached repository indexes" )
fs . IntVar ( & s . DefaultBurstLimit , "default-burst-limit" , s . DefaultBurstLimit , "client-side default throttling limit" )
}
}
func envOr ( name , def string ) string {
func envOr ( name , def string ) string {
@ -157,6 +169,7 @@ func (s *EnvSettings) EnvVars() map[string]string {
"HELM_REPOSITORY_CONFIG" : s . RepositoryConfig ,
"HELM_REPOSITORY_CONFIG" : s . RepositoryConfig ,
"HELM_NAMESPACE" : s . Namespace ( ) ,
"HELM_NAMESPACE" : s . Namespace ( ) ,
"HELM_MAX_HISTORY" : strconv . Itoa ( s . MaxHistory ) ,
"HELM_MAX_HISTORY" : strconv . Itoa ( s . MaxHistory ) ,
"HELM_DEFAULT_BURST_LIMIT" : strconv . Itoa ( s . DefaultBurstLimit ) ,
// broken, these are populated from helm flags and not kubeconfig.
// broken, these are populated from helm flags and not kubeconfig.
"HELM_KUBECONTEXT" : s . KubeContext ,
"HELM_KUBECONTEXT" : s . KubeContext ,