Skip to content
4 changes: 2 additions & 2 deletions helm-framework/helm/kubeConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ func (m *Meta) NewKubeConfig(ctx context.Context, namespace string) (*KubeConfig
"tlsServerName": overrides.ClusterInfo.TLSServerName,
})
}
if !kubernetesConfig.ClusterCaCertificate.IsNull() {
overrides.ClusterInfo.CertificateAuthorityData = []byte(kubernetesConfig.ClusterCaCertificate.ValueString())
if !kubernetesConfig.ClusterCACertificate.IsNull() {
overrides.ClusterInfo.CertificateAuthorityData = []byte(kubernetesConfig.ClusterCACertificate.ValueString())
fmt.Println("Setting cluster CA certificate")
tflog.Debug(ctx, "Setting cluster CA certificate")
}
Expand Down
12 changes: 5 additions & 7 deletions helm-framework/helm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ func execSchema() map[string]schema.Attribute {

// Setting up the provider, anything we need to get the provider running, probbaly authentication. like the api
func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
debug := os.Getenv("HELM_DEBUG")
pluginsPath := os.Getenv("HELM_PLUGINS_PATH")
registryConfigPath := os.Getenv("HELM_REGISTRY_CONFIG_PATH")
repositoryConfigPath := os.Getenv("HELM_REPOSITORY_CONFIG_PATH")
Expand Down Expand Up @@ -339,10 +338,9 @@ func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequ
if resp.Diagnostics.HasError() {
return
}
// Override environment variables if the configuration values are provided
if !config.Debug.IsNull() {
debug = fmt.Sprintf("%t", config.Debug.ValueBool())
}

debug := os.Getenv("HELM_DEBUG") == "true" || config.Debug.ValueBool()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice one liner! One last request

Here debug is initialized on line 342 but is first used here in the provider.go file:

It's best practice to include the variable initialization near the first call of the variable. In order to reduce the need to go searching for where the variable was first set.


if !config.PluginsPath.IsNull() {
pluginsPath = config.PluginsPath.ValueString()
}
Expand Down Expand Up @@ -459,7 +457,7 @@ func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequ
"config": config,
})
settings := cli.New()
settings.Debug = debug == "true"
settings.Debug = debug
if pluginsPath != "" {
settings.PluginsDirectory = pluginsPath
}
Expand Down Expand Up @@ -579,7 +577,7 @@ func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequ

meta := &Meta{
Data: &HelmProviderModel{
Debug: types.BoolValue(debug == "true"),
Debug: types.BoolValue(debug),
PluginsPath: types.StringValue(pluginsPath),
RegistryConfigPath: types.StringValue(registryConfigPath),
RepositoryConfigPath: types.StringValue(repositoryConfigPath),
Expand Down