Skip to content

Commit 17f9d79

Browse files
authored
Merge pull request #32 from pluralsh/marcin/eng-1984-add-support-for-infrastructure-stacks-to-terraform-provider
feat: Add support for infrastructure stacks
2 parents 1dcd452 + 11d3079 commit 17f9d79

27 files changed

+1293
-104
lines changed

.github/workflows/test.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
paths-ignore:
55
- 'README.md'
66
push:
7+
branches:
8+
- "main"
79
paths-ignore:
810
- 'README.md'
911
permissions:

docs/resources/cluster.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Required:
138138
Optional:
139139

140140
- `args` (List of String) Arguments to pass to the command when executing it.
141-
- `env` (Map of String) Defines environment variables to expose to the process.
141+
- `env` (Map of String) Defines environment variables to expose to the process.
142142

143143

144144

@@ -186,7 +186,7 @@ Required:
186186
Optional:
187187

188188
- `args` (List of String) Arguments to pass to the command when executing it.
189-
- `env` (Map of String) Defines environment variables to expose to the process.
189+
- `env` (Map of String) Defines environment variables to expose to the process.
190190

191191

192192

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "plural_infrastructure_stack Resource - terraform-provider-plural"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# plural_infrastructure_stack (Resource)
10+
11+
12+
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `cluster_id` (String) The cluster on which the stack will be applied.
21+
- `configuration` (Attributes) Stack configuration. (see [below for nested schema](#nestedatt--configuration))
22+
- `name` (String) Human-readable name of this stack.
23+
- `repository` (Attributes) Repository information used to pull stack. (see [below for nested schema](#nestedatt--repository))
24+
- `type` (String) A type for the stack, specifies the tool to use to apply it. Allowed values include `ANSIBLE` and `TERRAFORM`.
25+
26+
### Optional
27+
28+
- `approval` (Boolean) Determines whether to require approval.
29+
- `bindings` (Attributes) Read and write policies of this stack. (see [below for nested schema](#nestedatt--bindings))
30+
- `detach` (Boolean) Determines behavior during resource destruction, if true it will detach resource instead of deleting it.
31+
- `environment` (Attributes Set) Defines environment variables for the stack. (see [below for nested schema](#nestedatt--environment))
32+
- `files` (Map of String) File path-content map.
33+
- `job_spec` (Attributes) Repository information used to pull stack. (see [below for nested schema](#nestedatt--job_spec))
34+
35+
### Read-Only
36+
37+
- `id` (String) Internal identifier of this stack.
38+
39+
<a id="nestedatt--configuration"></a>
40+
### Nested Schema for `configuration`
41+
42+
Required:
43+
44+
- `version` (String) The semver of the tool you wish to use.
45+
46+
Optional:
47+
48+
- `image` (String) Optional custom image you might want to use.
49+
50+
51+
<a id="nestedatt--repository"></a>
52+
### Nested Schema for `repository`
53+
54+
Required:
55+
56+
- `folder` (String) The folder where manifests live.
57+
- `id` (String) ID of the repository to pull from.
58+
- `ref` (String) A general git ref, either a branch name or commit sha understandable by "git checkout <ref>".
59+
60+
61+
<a id="nestedatt--bindings"></a>
62+
### Nested Schema for `bindings`
63+
64+
Optional:
65+
66+
- `read` (Attributes Set) Read policies of this stack. (see [below for nested schema](#nestedatt--bindings--read))
67+
- `write` (Attributes Set) Write policies of this stack. (see [below for nested schema](#nestedatt--bindings--write))
68+
69+
<a id="nestedatt--bindings--read"></a>
70+
### Nested Schema for `bindings.read`
71+
72+
Optional:
73+
74+
- `group_id` (String)
75+
- `id` (String)
76+
- `user_id` (String)
77+
78+
79+
<a id="nestedatt--bindings--write"></a>
80+
### Nested Schema for `bindings.write`
81+
82+
Optional:
83+
84+
- `group_id` (String)
85+
- `id` (String)
86+
- `user_id` (String)
87+
88+
89+
90+
<a id="nestedatt--environment"></a>
91+
### Nested Schema for `environment`
92+
93+
Required:
94+
95+
- `name` (String) Environment variable name.
96+
- `value` (String) Environment variable value.
97+
98+
Optional:
99+
100+
- `secret` (Boolean) Indicates if environment variable is secret.
101+
102+
103+
<a id="nestedatt--job_spec"></a>
104+
### Nested Schema for `job_spec`
105+
106+
Required:
107+
108+
- `namespace` (String) Namespace where job will be deployed.
109+
110+
Optional:
111+
112+
- `annotations` (Map of String) Kubernetes annotations applied to the job.
113+
- `containers` (Attributes Set) (see [below for nested schema](#nestedatt--job_spec--containers))
114+
- `labels` (Map of String) Kubernetes labels applied to the job.
115+
- `raw` (String) If you'd rather define the job spec via straight Kubernetes YAML.
116+
- `service_account` (String) Kubernetes service account for this job.
117+
118+
<a id="nestedatt--job_spec--containers"></a>
119+
### Nested Schema for `job_spec.containers`
120+
121+
Required:
122+
123+
- `image` (String)
124+
125+
Optional:
126+
127+
- `args` (List of String) Arguments to pass to the command when executing it.
128+
- `env` (Map of String) Defines environment variables to expose to the process.
129+
- `env_from` (Attributes Set) (see [below for nested schema](#nestedatt--job_spec--containers--env_from))
130+
131+
<a id="nestedatt--job_spec--containers--env_from"></a>
132+
### Nested Schema for `job_spec.containers.env_from`
133+
134+
Required:
135+
136+
- `config_map` (String)
137+
- `secret` (String)
File renamed without changes.
File renamed without changes.

example/byok/main.tf renamed to example/cluster/byok/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ resource "plural_cluster" "byok" {
2121
metadata = jsonencode({
2222
test1 = "test"
2323
test2 = false
24-
test3 = jsonencode({
24+
test3 = {
2525
abc = false
26-
})
26+
}
2727
})
2828
helm_repo_url = "https://pluralsh.github.io/deployment-operator"
2929
tags = {
File renamed without changes.

example/cluster_data/main.tf

-16
This file was deleted.

example/stack/main.tf

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
terraform {
2+
required_providers {
3+
plural = {
4+
source = "pluralsh/plural"
5+
version = "0.0.1"
6+
}
7+
}
8+
}
9+
10+
provider "plural" {
11+
use_cli = true
12+
}
13+
14+
data "plural_cluster" "cluster" {
15+
handle = "mgmt"
16+
}
17+
18+
data "plural_git_repository" "repository" {
19+
url = "https://github.com/zreigz/tf-hello.git"
20+
}
21+
22+
resource "random_string" "random" {
23+
length = 5
24+
upper = false
25+
special = false
26+
}
27+
28+
resource "plural_infrastructure_stack" "stack-full" {
29+
name = "stack-tf-full-${random_string.random.result}"
30+
type = "TERRAFORM"
31+
approval = true
32+
detach = true
33+
cluster_id = data.plural_cluster.cluster.id
34+
repository = {
35+
id = data.plural_git_repository.repository.id
36+
ref = "main"
37+
folder = "terraform"
38+
}
39+
configuration = {
40+
image = "hashicorp/terraform:1.8.1"
41+
version = "1.8.1"
42+
}
43+
files = {
44+
"test.yml" = "value: 123"
45+
}
46+
environment = [
47+
{
48+
name = "USERNAME"
49+
value = "joe"
50+
},
51+
{
52+
name = "PASSWORD"
53+
value = "test"
54+
secret = true
55+
}
56+
]
57+
job_spec = {
58+
namespace = "default"
59+
labels = {
60+
test = "123"
61+
}
62+
service_account = "default"
63+
containers = [
64+
{
65+
image = "perl:5.34.0"
66+
args = ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
67+
env = {}
68+
env_from = []
69+
}
70+
]
71+
}
72+
bindings = {
73+
read = []
74+
write = []
75+
}
76+
}
77+
78+
resource "plural_infrastructure_stack" "stack-raw" {
79+
name = "stack-tf-raw-${random_string.random.result}"
80+
type = "TERRAFORM"
81+
approval = true
82+
detach = true
83+
cluster_id = data.plural_cluster.cluster.id
84+
repository = {
85+
id = data.plural_git_repository.repository.id
86+
ref = "main"
87+
folder = "terraform"
88+
}
89+
configuration = {
90+
image = "hashicorp/terraform:1.8.1"
91+
version = "1.8.1"
92+
}
93+
files = {
94+
"test.yml" = "value: 123"
95+
}
96+
environment = [
97+
{
98+
name = "USERNAME"
99+
value = "joe"
100+
},
101+
{
102+
name = "PASSWORD"
103+
value = "test"
104+
secret = true
105+
}
106+
]
107+
job_spec = {
108+
namespace = "default"
109+
raw = yamlencode({
110+
containers = [
111+
{
112+
name = "pi"
113+
image = "perl:5.34.0"
114+
command = ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
115+
}
116+
]
117+
restartPolicy = "Never"
118+
})
119+
}
120+
bindings = {
121+
read = []
122+
write = []
123+
}
124+
}
125+
126+
resource "plural_infrastructure_stack" "stack-empty" {
127+
name = "stack-tf-empty-${random_string.random.result}"
128+
type = "TERRAFORM"
129+
approval = true
130+
detach = true
131+
cluster_id = data.plural_cluster.cluster.id
132+
repository = {
133+
id = data.plural_git_repository.repository.id
134+
ref = "main"
135+
folder = "terraform"
136+
}
137+
configuration = {
138+
version = "1.8.1"
139+
}
140+
files = {}
141+
environment = []
142+
job_spec = {
143+
namespace = "default"
144+
raw = yamlencode({ test = true })
145+
}
146+
bindings = {}
147+
}
148+
149+
resource "plural_infrastructure_stack" "stack-minimal" {
150+
name = "stack-tf-minimal-${random_string.random.result}"
151+
type = "TERRAFORM"
152+
detach = true
153+
cluster_id = data.plural_cluster.cluster.id
154+
repository = {
155+
id = data.plural_git_repository.repository.id
156+
ref = "main"
157+
folder = "terraform"
158+
}
159+
configuration = {
160+
version = "1.8.1"
161+
}
162+
}

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ require (
1212
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
1313
github.com/hashicorp/terraform-plugin-log v0.9.0
1414
github.com/mitchellh/go-homedir v1.1.0
15-
github.com/pluralsh/console-client-go v0.1.17
15+
github.com/pluralsh/console-client-go v0.4.0
1616
github.com/pluralsh/plural-cli v0.8.5-0.20240216094552-efc34ee6de37
1717
github.com/pluralsh/polly v0.1.7
1818
github.com/samber/lo v1.38.1
1919
github.com/sirupsen/logrus v1.9.3
2020
gopkg.in/yaml.v2 v2.4.0
2121
helm.sh/helm/v3 v3.11.2
22+
k8s.io/api v0.26.4
2223
k8s.io/apimachinery v0.26.4
2324
k8s.io/client-go v0.26.4
2425
sigs.k8s.io/yaml v1.3.0
@@ -335,7 +336,6 @@ require (
335336
gopkg.in/warnings.v0 v0.1.2 // indirect
336337
gopkg.in/yaml.v3 v3.0.1 // indirect
337338
honnef.co/go/tools v0.4.6 // indirect
338-
k8s.io/api v0.26.4 // indirect
339339
k8s.io/apiextensions-apiserver v0.26.1 // indirect
340340
k8s.io/apiserver v0.26.1 // indirect
341341
k8s.io/cli-runtime v0.26.1 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
856856
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
857857
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
858858
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
859-
github.com/pluralsh/console-client-go v0.1.17 h1:QMtnWdRvV13/sND/CFjFBUR8nyg3JJgwXReSyM6bK7A=
860-
github.com/pluralsh/console-client-go v0.1.17/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
859+
github.com/pluralsh/console-client-go v0.4.0 h1:lgKaVGi8jB7S8wFF6L3P6H/4Xc88e4FozhyW58O1w3Q=
860+
github.com/pluralsh/console-client-go v0.4.0/go.mod h1:eyCiLA44YbXiYyJh8303jk5JdPkt9McgCo5kBjk4lKo=
861861
github.com/pluralsh/gqlclient v1.11.0 h1:FfXW7FiEJLHOfTAa7NxDb8jb3aMZNIpCAcG+bg8uHYA=
862862
github.com/pluralsh/gqlclient v1.11.0/go.mod h1:qSXKUlio1F2DRPy8el4oFYsmpKbkUYspgPB87T4it5I=
863863
github.com/pluralsh/plural-cli v0.8.5-0.20240216094552-efc34ee6de37 h1:DBnaKvKmbTbKwbkrh/2gJBwyHYfaXdxeT3UGh+94K4g=

0 commit comments

Comments
 (0)