forked from kbst/terraform-provider-kustomization
-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (160 loc) · 5.44 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Run Tests
on: push
jobs:
tf_acc_tests:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Setup Kind'
uses: engineerd/[email protected]
with:
version: "v0.6.1"
- name: 'Setup Go'
uses: actions/setup-go@v1
with:
go-version: "1.13.5"
- name: 'Run TF acceptance tests'
run: |
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
make test
env:
TF_ACC: '1'
compile_provider:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Setup Go'
uses: actions/setup-go@v1
with:
go-version: "1.13.5"
- name: 'Compile provider'
run: |
go build -o terraform.d/plugins/linux_amd64/terraform-provider-kustomization
ls -al
pwd
- name: 'Upload provider binary'
uses: actions/upload-artifact@v1
with:
name: terraform.d
path: terraform.d
download_terraform:
runs-on: ubuntu-latest
steps:
- name: 'Download Terraform'
run: |
wget https://releases.hashicorp.com/terraform/0.12.20/terraform_0.12.20_linux_amd64.zip
unzip terraform_0.12.20_linux_amd64.zip
./terraform version
- name: 'Upload terraform binary'
uses: actions/upload-artifact@v1
with:
name: terraform
path: terraform
int_test_kubeconfig_path:
runs-on: ubuntu-latest
needs: [compile_provider, download_terraform]
steps:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Download terraform binary'
uses: actions/download-artifact@v1
with:
name: terraform
- name: 'Download provider binary'
uses: actions/download-artifact@v1
with:
name: terraform.d
- name: 'Make binaries executable'
run: |
chmod +x ./terraform/terraform
chmod +x ./terraform.d/plugins/linux_amd64/terraform-provider-kustomization
- name: 'Setup Kind'
uses: engineerd/[email protected]
with:
version: "v0.6.1"
- name: 'Set KUBECONFIG env var'
run: |
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
- name: 'Terraform Init'
run: ./terraform/terraform init
- name: 'Terraform Apply'
run: ./terraform/terraform apply --auto-approve
int_test_kubeconfig_raw:
runs-on: ubuntu-latest
needs: [compile_provider, download_terraform]
steps:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Setup Kind'
uses: engineerd/[email protected]
with:
version: "v0.6.1"
- name: 'Download terraform binary'
uses: actions/download-artifact@v1
with:
name: terraform
- name: 'Download provider binary'
uses: actions/download-artifact@v1
with:
name: terraform.d
- name: 'Make binaries executable'
run: |
chmod +x ./terraform/terraform
chmod +x ./terraform.d/plugins/linux_amd64/terraform-provider-kustomization
- name: 'Create provider.tf with kubeconfig_raw'
run: |
unset KUBECONFIG
echo "provider "kustomization" {" > provider.tf
echo " kubeconfig_raw = <<EOT" >> provider.tf
cat $(kind get kubeconfig-path --name="kind") >> provider.tf
echo "EOT" >> provider.tf
echo "}" >> provider.tf
- name: 'Terraform Init'
run: ./terraform/terraform init
- name: 'Terraform Apply'
run: ./terraform/terraform apply --auto-approve
int_test_state_import:
runs-on: ubuntu-latest
needs: [compile_provider, download_terraform]
steps:
- name: 'Checkout'
uses: actions/checkout@v1
- name: 'Setup Kind'
uses: engineerd/[email protected]
with:
version: "v0.6.1"
- name: 'Download terraform binary'
uses: actions/download-artifact@v1
with:
name: terraform
- name: 'Download provider binary'
uses: actions/download-artifact@v1
with:
name: terraform.d
- name: 'Make binaries executable'
run: |
chmod +x ./terraform/terraform
chmod +x ./terraform.d/plugins/linux_amd64/terraform-provider-kustomization
- name: 'Set KUBECONFIG env var'
run: |
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
- name: 'Download kustomize'
run: |
wget https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.5.4/kustomize_v3.5.4_linux_amd64.tar.gz
sudo tar -C /usr/local/bin -xvf kustomize_v3.5.4_linux_amd64.tar.gz
kustomize version
- name: 'Kubectl apply'
run: |
kustomize build test_kustomizations/basic/initial | kubectl apply -f -
- name: 'Terraform Init'
run: ./terraform/terraform init
- name: 'Terraform Import'
run: |
./terraform/terraform import 'kustomization_resource.test["~G_v1_Namespace|~X|test-basic"]' '~G_v1_Namespace|~X|test-basic'
./terraform/terraform import 'kustomization_resource.test["apps_v1_Deployment|test-basic|test"]' 'apps_v1_Deployment|test-basic|test'
./terraform/terraform import 'kustomization_resource.test["~G_v1_Service|test-basic|test"]' '~G_v1_Service|test-basic|test'
./terraform/terraform import 'kustomization_resource.test["networking.k8s.io_v1beta1_Ingress|test-basic|test"]' 'networking.k8s.io_v1beta1_Ingress|test-basic|test'
- name: 'Terraform Apply'
run: ./terraform/terraform apply --auto-approve