diff --git a/docs/guides/v3-upgrade-guide.md b/docs/guides/v3-upgrade-guide.md index d868df85f..15bbe18f8 100644 --- a/docs/guides/v3-upgrade-guide.md +++ b/docs/guides/v3-upgrade-guide.md @@ -7,6 +7,8 @@ description: |- # Upgrading to v3.0.0 of the Helm provider + + This guide covers the changes introduced in v3.0.0 of the Helm provider and what you may need to do to upgrade your configuration. ## Changes in v3.0.0 @@ -73,8 +75,8 @@ provider "helm" { **What Changed?** -- `kubernetes` is now a single nested object using `{ ... }`. -- `registry` blocks have been replaced by a `registries` list. +- `kubernetes` is now a single nested object attribute using `{ ... }`. +- `registry` blocks have been replaced by a `registries` list attribute. #### Experiments Configuration (experiments) @@ -94,17 +96,15 @@ provider "helm" { ```hcl provider "helm" { - experiments = [ - { - manifest = true - } - ] + experiments = { + manifest = true + } } ``` **What Changed?** -- `experiments` is now a single nested object using `[ { ... } ]`. +- `experiments` is now a single nested object attribute using `{ ... }`. ### Changes to helm_release Resource diff --git a/docs/index.md b/docs/index.md index ba22a5a77..4f0ffc107 100644 --- a/docs/index.md +++ b/docs/index.md @@ -205,10 +205,8 @@ The provider takes an `experiments` block that allows you enable experimental fe ```terraform provider "helm" { - experiments = [ - { - manifest = true - } - ] + experiments = { + manifest = true + } } ``` diff --git a/helm/provider.go b/helm/provider.go index a12ba4d8b..02e712631 100644 --- a/helm/provider.go +++ b/helm/provider.go @@ -52,16 +52,16 @@ type Meta struct { // HelmProviderModel contains the configuration for the provider type HelmProviderModel struct { - Debug types.Bool `tfsdk:"debug"` - PluginsPath types.String `tfsdk:"plugins_path"` - RegistryConfigPath types.String `tfsdk:"registry_config_path"` - RepositoryConfigPath types.String `tfsdk:"repository_config_path"` - RepositoryCache types.String `tfsdk:"repository_cache"` - HelmDriver types.String `tfsdk:"helm_driver"` - BurstLimit types.Int64 `tfsdk:"burst_limit"` - Kubernetes types.Object `tfsdk:"kubernetes"` - Registries types.List `tfsdk:"registries"` - Experiments types.List `tfsdk:"experiments"` + Debug types.Bool `tfsdk:"debug"` + PluginsPath types.String `tfsdk:"plugins_path"` + RegistryConfigPath types.String `tfsdk:"registry_config_path"` + RepositoryConfigPath types.String `tfsdk:"repository_config_path"` + RepositoryCache types.String `tfsdk:"repository_cache"` + HelmDriver types.String `tfsdk:"helm_driver"` + BurstLimit types.Int64 `tfsdk:"burst_limit"` + Kubernetes types.Object `tfsdk:"kubernetes"` + Registries types.List `tfsdk:"registries"` + Experiments *ExperimentsConfigModel `tfsdk:"experiments"` } // ExperimentsConfigModel configures the experiments that are enabled or disabled @@ -302,6 +302,7 @@ func execSchema() map[string]schema.Attribute { }, } } + func execSchemaAttrTypes() map[string]attr.Type { return map[string]attr.Type{ "api_version": types.StringType, @@ -480,22 +481,9 @@ func (p *HelmProvider) Configure(ctx context.Context, req provider.ConfigureRequ return } - var experimentsConfig ExperimentsConfigModel - if !config.Experiments.IsNull() && !config.Experiments.IsUnknown() { - var experimentsConfigs []ExperimentsConfigModel - diags := config.Experiments.ElementsAs(ctx, &experimentsConfigs, false) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - if len(experimentsConfigs) > 0 { - experimentsConfig = experimentsConfigs[0] - } - } - manifestExperiment := false - if !experimentsConfig.Manifest.IsNull() { - manifestExperiment = experimentsConfig.Manifest.ValueBool() + if config.Experiments != nil { + manifestExperiment = config.Experiments.Manifest.ValueBool() } var execAttrValue attr.Value = types.ObjectNull(execSchemaAttrTypes()) @@ -675,7 +663,6 @@ func OCIRegistryLogin(ctx context.Context, meta *Meta, actionConfig *action.Conf // registryClient = client used to comm with the registry, oci urls, un, and pw used for authentication func OCIRegistryPerformLogin(ctx context.Context, meta *Meta, registryClient *registry.Client, ociURL, username, password string) error { - loggedInOCIRegistries := make(map[string]string) // getting the oci url, and extracting the host. u, err := url.Parse(ociURL)