Skip to content

Commit

Permalink
Creating bool debug (#1469)
Browse files Browse the repository at this point in the history
* Fix acronyms in struct field names in kubeConfig.go and provider.go

* Fixed acronym in kubeConfig that wasnt pushed in previous pr

* Refactored debug handling to use a boolean variable

* removing unnessary comment

* Updating the debug two conditionals into one

* Fixing edge case logic

* Simpliyfing if statements

* Fixing location of debug variable
  • Loading branch information
JaylonmcShan03 committed Oct 8, 2024
1 parent d733054 commit ad5b7c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
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
11 changes: 4 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,7 @@ 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())
}

if !config.PluginsPath.IsNull() {
pluginsPath = config.PluginsPath.ValueString()
}
Expand Down Expand Up @@ -458,8 +454,9 @@ func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequ
tflog.Debug(ctx, "Config values after overrides", map[string]interface{}{
"config": config,
})
debug := os.Getenv("HELM_DEBUG") == "true" || config.Debug.ValueBool()
settings := cli.New()
settings.Debug = debug == "true"
settings.Debug = debug
if pluginsPath != "" {
settings.PluginsDirectory = pluginsPath
}
Expand Down Expand Up @@ -579,7 +576,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

0 comments on commit ad5b7c1

Please sign in to comment.