Skip to content

Commit

Permalink
Add support for deferred actions (#2510)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
alexsomesan authored Jun 7, 2024
1 parent 0687d3d commit 55edec5
Show file tree
Hide file tree
Showing 25 changed files with 2,559 additions and 205 deletions.
3 changes: 3 additions & 0 deletions .changelog/2510.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Add support for Terraform's experimental deferred actions
```
32 changes: 32 additions & 0 deletions .github/workflows/acceptance_test_dfa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deferred Actions

on:
pull_request:
branches:
- main
paths:
- "manifest/**/*.go"
- 'kubernetes/**/*.go'
- "go.mod"
workflow_dispatch:
inputs:
terraformVersion:
description: Terraform version
default: 1.9.0-alpha20240516

jobs:
acceptance_tests:
runs-on: custom-linux-medium
steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Set up Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
- name: Run Tests
env:
TF_ACC: 1
TF_ACC_TERRAFORM_VERSION: ${{ github.event.inputs.terraformVersion || vars.TERRAFORM_VERSION_EXP }}
run: |
go test -v -run '^TestAccKubernetesDeferredActions' ./kubernetes/test-dfa
22 changes: 22 additions & 0 deletions _examples/deferred-actions/cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

terraform {
required_providers {
kind = {
source = "tehcyx/kind"
}
kubernetes = {}
}
}

resource "kind_cluster" "demo" {
name = "demo-cluster"
}

provider "kubernetes" {
host = kind_cluster.demo.endpoint
cluster_ca_certificate = kind_cluster.demo.cluster_ca_certificate
client_certificate = kind_cluster.demo.client_certificate
client_key = kind_cluster.demo.client_key
}
1,032 changes: 1,032 additions & 0 deletions _examples/deferred-actions/crd.tf

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions _examples/deferred-actions/workspace.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

resource "kubernetes_namespace_v1" "demo_ns" {
metadata {
name = "demo-ns"
}
}

resource "kubernetes_manifest" "demo_workspace" {
manifest = {
apiVersion = "app.terraform.io/v1alpha2"
kind = kubernetes_manifest.crd_workspaces.object.spec.names.kind
metadata = {
name = "deferred-demo"
namespace = kubernetes_namespace_v1.demo_ns.id
}
spec = {
name = "demo-ws"
organization = "demo-org"
token = {
secretKeyRef = {
name = "demo-token"
key = "token"
}
}
}
}
}
42 changes: 21 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/getkin/kin-openapi v0.111.0
github.com/google/go-cmp v0.6.0
github.com/hashicorp/go-hclog v1.6.2
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-plugin v1.6.0
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/hc-install v0.6.3
github.com/hashicorp/hcl/v2 v2.20.0
github.com/hashicorp/terraform-exec v0.20.0
github.com/hashicorp/terraform-json v0.21.0
github.com/hashicorp/hc-install v0.6.4
github.com/hashicorp/hcl/v2 v2.20.1
github.com/hashicorp/terraform-exec v0.21.0
github.com/hashicorp/terraform-json v0.22.1
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-framework v1.7.0
github.com/hashicorp/terraform-plugin-go v0.22.1
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/terraform-plugin-testing v1.7.0
github.com/hashicorp/terraform-plugin-mux v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/hashicorp/terraform-plugin-testing v1.8.0
github.com/jinzhu/copier v0.3.5
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/hashstructure v1.1.0
github.com/robfig/cron v1.2.0
github.com/stretchr/testify v1.8.2
golang.org/x/mod v0.15.0
golang.org/x/mod v0.16.0
k8s.io/api v0.28.6
k8s.io/apiextensions-apiserver v0.28.6
k8s.io/apimachinery v0.28.6
Expand All @@ -40,7 +40,7 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.0 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
Expand All @@ -61,7 +61,7 @@ require (
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/tools v0.16.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
)

require (
Expand All @@ -80,7 +80,7 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand Down Expand Up @@ -123,18 +123,18 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/zclconf/go-cty v1.14.3
github.com/zclconf/go-cty v1.14.4
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/term v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/grpc v1.62.1
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.34.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 55edec5

Please sign in to comment.