Skip to content

Commit 55edec5

Browse files
authored
Add support for deferred actions (#2510)
* Deferred actions for SDK resources * Deferred actions for kubernetes_manifest * Defer on missing CRD * Deprecate manifest experiment flag in framework * Add example for deferred actions * Deferred actions acc test * Add ProtocolVersion attribute to provider reattach configuration * Extract mux setup into own function to re-use in acc test * Add version constraint for DA test * New GH action to run DA tests
1 parent 0687d3d commit 55edec5

File tree

25 files changed

+2559
-205
lines changed

25 files changed

+2559
-205
lines changed

.changelog/2510.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
Add support for Terraform's experimental deferred actions
3+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deferred Actions
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- "manifest/**/*.go"
9+
- 'kubernetes/**/*.go'
10+
- "go.mod"
11+
workflow_dispatch:
12+
inputs:
13+
terraformVersion:
14+
description: Terraform version
15+
default: 1.9.0-alpha20240516
16+
17+
jobs:
18+
acceptance_tests:
19+
runs-on: custom-linux-medium
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
23+
- name: Set up Go
24+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
25+
with:
26+
go-version-file: 'go.mod'
27+
- name: Run Tests
28+
env:
29+
TF_ACC: 1
30+
TF_ACC_TERRAFORM_VERSION: ${{ github.event.inputs.terraformVersion || vars.TERRAFORM_VERSION_EXP }}
31+
run: |
32+
go test -v -run '^TestAccKubernetesDeferredActions' ./kubernetes/test-dfa
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
terraform {
5+
required_providers {
6+
kind = {
7+
source = "tehcyx/kind"
8+
}
9+
kubernetes = {}
10+
}
11+
}
12+
13+
resource "kind_cluster" "demo" {
14+
name = "demo-cluster"
15+
}
16+
17+
provider "kubernetes" {
18+
host = kind_cluster.demo.endpoint
19+
cluster_ca_certificate = kind_cluster.demo.cluster_ca_certificate
20+
client_certificate = kind_cluster.demo.client_certificate
21+
client_key = kind_cluster.demo.client_key
22+
}

_examples/deferred-actions/crd.tf

Lines changed: 1032 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) HashiCorp, Inc.
2+
# SPDX-License-Identifier: MPL-2.0
3+
4+
resource "kubernetes_namespace_v1" "demo_ns" {
5+
metadata {
6+
name = "demo-ns"
7+
}
8+
}
9+
10+
resource "kubernetes_manifest" "demo_workspace" {
11+
manifest = {
12+
apiVersion = "app.terraform.io/v1alpha2"
13+
kind = kubernetes_manifest.crd_workspaces.object.spec.names.kind
14+
metadata = {
15+
name = "deferred-demo"
16+
namespace = kubernetes_namespace_v1.demo_ns.id
17+
}
18+
spec = {
19+
name = "demo-ws"
20+
organization = "demo-org"
21+
token = {
22+
secretKeyRef = {
23+
name = "demo-token"
24+
key = "token"
25+
}
26+
}
27+
}
28+
}
29+
}

go.mod

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ require (
66
github.com/Masterminds/semver v1.5.0
77
github.com/getkin/kin-openapi v0.111.0
88
github.com/google/go-cmp v0.6.0
9-
github.com/hashicorp/go-hclog v1.6.2
9+
github.com/hashicorp/go-hclog v1.6.3
1010
github.com/hashicorp/go-plugin v1.6.0
1111
github.com/hashicorp/go-version v1.6.0
12-
github.com/hashicorp/hc-install v0.6.3
13-
github.com/hashicorp/hcl/v2 v2.20.0
14-
github.com/hashicorp/terraform-exec v0.20.0
15-
github.com/hashicorp/terraform-json v0.21.0
12+
github.com/hashicorp/hc-install v0.6.4
13+
github.com/hashicorp/hcl/v2 v2.20.1
14+
github.com/hashicorp/terraform-exec v0.21.0
15+
github.com/hashicorp/terraform-json v0.22.1
1616
github.com/hashicorp/terraform-plugin-docs v0.16.0
1717
github.com/hashicorp/terraform-plugin-framework v1.7.0
18-
github.com/hashicorp/terraform-plugin-go v0.22.1
18+
github.com/hashicorp/terraform-plugin-go v0.23.0
1919
github.com/hashicorp/terraform-plugin-log v0.9.0
20-
github.com/hashicorp/terraform-plugin-mux v0.15.0
21-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
22-
github.com/hashicorp/terraform-plugin-testing v1.7.0
20+
github.com/hashicorp/terraform-plugin-mux v0.16.0
21+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
22+
github.com/hashicorp/terraform-plugin-testing v1.8.0
2323
github.com/jinzhu/copier v0.3.5
2424
github.com/mitchellh/go-homedir v1.1.0
2525
github.com/mitchellh/hashstructure v1.1.0
2626
github.com/robfig/cron v1.2.0
2727
github.com/stretchr/testify v1.8.2
28-
golang.org/x/mod v0.15.0
28+
golang.org/x/mod v0.16.0
2929
k8s.io/api v0.28.6
3030
k8s.io/apiextensions-apiserver v0.28.6
3131
k8s.io/apimachinery v0.28.6
@@ -40,7 +40,7 @@ require (
4040
github.com/Masterminds/goutils v1.1.1 // indirect
4141
github.com/Masterminds/semver/v3 v3.2.0 // indirect
4242
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
43-
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
43+
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
4444
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
4545
github.com/armon/go-radix v1.0.0 // indirect
4646
github.com/bgentry/speakeasy v0.1.0 // indirect
@@ -61,7 +61,7 @@ require (
6161
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
6262
golang.org/x/sync v0.6.0 // indirect
6363
golang.org/x/tools v0.16.1 // indirect
64-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
64+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
6565
)
6666

6767
require (
@@ -80,7 +80,7 @@ require (
8080
github.com/go-openapi/jsonreference v0.20.2 // indirect
8181
github.com/go-openapi/swag v0.22.3 // indirect
8282
github.com/gogo/protobuf v1.3.2 // indirect
83-
github.com/golang/protobuf v1.5.3 // indirect
83+
github.com/golang/protobuf v1.5.4 // indirect
8484
github.com/google/btree v1.1.2 // indirect
8585
github.com/google/gofuzz v1.2.0 // indirect
8686
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
@@ -123,18 +123,18 @@ require (
123123
github.com/spf13/pflag v1.0.5 // indirect
124124
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
125125
github.com/xlab/treeprint v1.2.0 // indirect
126-
github.com/zclconf/go-cty v1.14.3
126+
github.com/zclconf/go-cty v1.14.4
127127
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
128-
golang.org/x/crypto v0.21.0 // indirect
128+
golang.org/x/crypto v0.23.0 // indirect
129129
golang.org/x/net v0.23.0 // indirect
130-
golang.org/x/oauth2 v0.16.0 // indirect
131-
golang.org/x/sys v0.18.0 // indirect
132-
golang.org/x/term v0.18.0 // indirect
133-
golang.org/x/text v0.14.0 // indirect
130+
golang.org/x/oauth2 v0.17.0 // indirect
131+
golang.org/x/sys v0.20.0 // indirect
132+
golang.org/x/term v0.20.0 // indirect
133+
golang.org/x/text v0.15.0 // indirect
134134
golang.org/x/time v0.3.0 // indirect
135135
google.golang.org/appengine v1.6.8 // indirect
136-
google.golang.org/grpc v1.62.1
137-
google.golang.org/protobuf v1.33.0 // indirect
136+
google.golang.org/grpc v1.63.2
137+
google.golang.org/protobuf v1.34.0 // indirect
138138
gopkg.in/inf.v0 v0.9.1 // indirect
139139
gopkg.in/yaml.v2 v2.4.0 // indirect
140140
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)