Skip to content

Commit

Permalink
Migrate to terraform plugin framework (#1379)
Browse files Browse the repository at this point in the history
Co-authored-by: Mauricio Alvarez Leon <[email protected]>
Co-authored-by: John Houston <[email protected]>
Co-authored-by: Brandy Jackson <[email protected]>
  • Loading branch information
4 people authored Jan 16, 2025
1 parent afc64ed commit b328cfa
Show file tree
Hide file tree
Showing 27 changed files with 5,141 additions and 4,176 deletions.
3 changes: 3 additions & 0 deletions .changelog/1379.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:dependency
Provider project ported from `terraform-plugin-sdk/v2` to `terraform-plugin-framework`
```
42 changes: 0 additions & 42 deletions .github/workflows/documentation-check.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ on:
push:
branches:
- main
- helm-framework
pull_request:
branches:
- main
- helm-framework

env:
KUBECONFIG: ${{ github.workspace }}/.kube/config
Expand Down Expand Up @@ -59,6 +57,7 @@ jobs:
env:
KUBE_CONFIG_PATH: ${{ env.KUBECONFIG }}
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform_version }}
TF_ACC_TEMP_DIR: ${{ runner.temp }}
TESTARGS: "-parallel 1"
run: |
make testacc
1 change: 0 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ifneq ($(origin TRAVIS_TAG), undefined)
BRANCH := $(TRAVIS_TAG)
VERSION := $(TRAVIS_TAG)
endif

# For changelog generation, default the last release to the last tag on
# any branch, and this release to just be the current branch we're on.
LAST_RELEASE?=$$(git describe --tags $$(git rev-list --tags --max-count=1))
Expand Down
49 changes: 30 additions & 19 deletions docs/data-sources/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,22 @@ data "helm_template" "mariadb_instance" {
chart = "mariadb"
version = "7.1.0"
set {
name = "service.port"
value = "13306"
}
set_sensitive {
name = "rootUser.password"
value = "s3cr3t!"
}
set = [
{
name = "service.port"
value = "13306"
}
]
set_sensitive = [
{
name = "rootUser.password"
value = "s3cr3t!"
}
]
}
resource "local_file" "mariadb_manifests" {
for_each = data.helm_template.mariadb_instance.manifests
Expand Down Expand Up @@ -188,18 +193,23 @@ data "helm_template" "mariadb_instance" {
"templates/master-statefulset.yaml",
"templates/master-svc.yaml",
]
set {
name = "service.port"
value = "13306"
}
set_sensitive {
name = "rootUser.password"
value = "s3cr3t!"
}
set = [
{
name = "service.port"
value = "13306"
}
]
set_sensitive = [
{
name = "rootUser.password"
value = "s3cr3t!"
}
]
}
resource "local_file" "mariadb_manifests" {
for_each = data.helm_template.mariadb_instance.manifests
Expand All @@ -219,3 +229,4 @@ output "mariadb_instance_notes" {
value = data.helm_template.mariadb_instance.notes
}
```

246 changes: 246 additions & 0 deletions docs/guides/v3-upgrade-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
---
layout: "helm"
page_title: "Helm: Upgrade Guide for Helm Provider v3.0.0"
description: |-
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.
---

# 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

### Adoption of the Terraform Plugin Framework

The Helm provider has been migrated from the legacy [Terraform Plugin SDKv2](https://github.com/hashicorp/terraform-plugin-sdk) to the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). This migration introduces structural changes to the schema, affecting nested blocks, attribute names, and how configurations are represented. Users must update their configurations to align with the new framework. Key changes include:

- **Blocks to Nested Objects**: Blocks like `kubernetes`, `registry`, and `experiments` are now represented as nested objects.
- **List Syntax for Nested Attributes**: Attributes like `set`, `set_list`, and `set_sensitive` in `helm_release` and `helm_template` are now lists of nested objects instead of blocks.

### Terraform Version Compatability

The new framework code uses [Terraform Plugin Protocol Version 6](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol#protocol-version-6) which is compatible with Terraform versions 1.0 and aboove. Users of earlier versions of Terraform can continue to use the Helm provider by pinning their configuration to the 2.x version.

---

### Changes to Provider Attributes

#### Kubernetes Configuration (`kubernetes`)

The `kubernetes` block has been updated to a single nested object.

**Old SDKv2 Configuration:**

```hcl
provider "helm" {
kubernetes {
config_path = "~/.kube/config"
}
registry {
url = "oci://localhost:5000"
username = "username"
password = "password"
}
registry {
url = "oci://private.registry"
username = "username"
password = "password"
}
}
```

**New Plugin Framework Configuration:**

```hcl
provider "helm" {
kubernetes = {
config_path = "~/.kube/config"
}
registries = [
{
url = "oci://localhost:5000"
username = "username"
password = "password"
},
{
url = "oci://private.registry"
username = "username"
password = "password"
}
]
}
```

**What Changed?**

- `kubernetes` is now a single nested object attribute using `{ ... }`.
- `registry` blocks have been replaced by a `registries` list attribute.

#### Experiments Configuration (experiments)

The `experiments` block has been updated to a list of nested objects.

**Old SDKv2 Configuration:**

```hcl
provider "helm" {
experiments {
manifest = true
}
}
```

**New Plugin Framework Configuration:**

```hcl
provider "helm" {
experiments = {
manifest = true
}
}
```

**What Changed?**

- `experiments` is now a single nested object attribute using `{ ... }`.

### Changes to helm_release Resource

#### `set`, `set_list`, and `set_sensitive` Configuration

Attributes `set`, `set_list`, and `set_sensitive` are now represented as lists of nested objects instead of individual blocks.

**Old SDKv2 Configuration:**

```hcl
resource "helm_release" "nginx_ingress" {
name = "nginx-ingress-controller"
repository = "https://charts.bitnami.com/bitnami"
chart = "nginx-ingress-controller"
set {
name = "service.type"
value = "ClusterIP"
}
set_list {
name = "allowed.hosts"
value = ["host1", "host2"]
}
set_sensitive {
name = "api.key"
value = "super-secret-key"
}
}
```

**New Plugin Framework Configuration:**

```hcl
resource "helm_release" "nginx_ingress" {
name = "nginx-ingress-controller"
repository = "https://charts.bitnami.com/bitnami"
chart = "nginx-ingress-controller"
set = [
{
name = "service.type"
value = "ClusterIP"
}
]
set_list = [
{
name = "allowed.hosts"
value = ["host1", "host2"]
}
]
set_sensitive = [
{
name = "api.key"
value = "super-secret-key"
}
]
}
```

**What Changed?**

- `set`, `set_list`, and `set_sensitive` is now a list of nested objects using `[ { ... } ]`.

### Changes to helm_template Data Source

#### `set`, `set_list`, and `set_sensitive` Configuration

Attributes `set`, `set_list`, and `set_sensitive` are now represented as lists of nested objects instead of individual blocks.

**Old SDKv2 Configuration:**

```hcl
data "helm_template" "example" {
name = "my-release"
chart = "my-chart"
namespace = "my-namespace"
values = ["custom-values.yaml"]
set {
name = "image.tag"
value = "1.2.3"
}
set_list {
name = "allowed.hosts"
value = ["host1", "host2"]
}
set_sensitive {
name = "api.key"
value = "super-secret-key"
}
}
```

**New Plugin Framework Configuration:**

```hcl
data "helm_template" "example" {
name = "my-release"
chart = "my-chart"
namespace = "my-namespace"
values = ["custom-values.yaml"]
set = [
{
name = "image.tag"
value = "1.2.3"
}
]
set_list = [
{
name = "allowed.hosts"
value = ["host1", "host2"]
}
]
set_sensitive = [
{
name = "api.key"
value = "super-secret-key"
}
]
}
```

**What Changed?**

- `set`, `set_list`, and `set_sensitive` is now a list of nested objects using `[ { ... } ]`.
Loading

0 comments on commit b328cfa

Please sign in to comment.