Skip to content

Commit

Permalink
Change experiments from List to Object
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhouston committed Jan 14, 2025
1 parent bd21dee commit 1cd343a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 39 deletions.
16 changes: 8 additions & 8 deletions docs/guides/v3-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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

Expand Down
8 changes: 3 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
```
39 changes: 13 additions & 26 deletions helm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1cd343a

Please sign in to comment.