@@ -95,39 +95,48 @@ resource "ovh_cloud_project_kube" "cluster" {
95
95
`
96
96
97
97
var testAccCloudProjectKubeVRackConfig = `
98
- resource "ovh_cloud_project_network_private" "network1" {
98
+ resource "ovh_vrack_cloudproject" "attach" {
99
+ service_name = "{{ .VrackID }}"
100
+ project_id = "{{ .ServiceName }}"
101
+ }
102
+
103
+ resource "ovh_cloud_project_network_private" "network" {
99
104
service_name = "{{ .ServiceName }}"
100
- name = "dhcp-default-gateway"
101
- regions = {{ .Regions }}
102
- vlan_id = "{{ .Vlanid }}"
105
+ vlan_id = 0
106
+ name = "terraform_testacc_private_net"
107
+ regions = ["{{ .Region }}"]
108
+ depends_on = [ovh_vrack_cloudproject.attach]
103
109
}
104
110
105
- resource "ovh_cloud_project_network_private_subnet" "network1subnetSBG5" {
106
- service_name = "{{ .ServiceName }}"
107
- network_id = ovh_cloud_project_network_private.network1.id
108
- start = "10.6.0.2" #first ip is burn for gateway ip
109
- end = "10.6.255.254"
110
- network = "10.6.0.0/16"
111
- dhcp = true
112
- region = "{{ .Region }}"
113
- no_gateway = false
114
- depends_on = [ovh_cloud_project_network_private.network1]
111
+ resource "ovh_cloud_project_network_private_subnet" "networksubnet" {
112
+ service_name = ovh_cloud_project_network_private.network.service_name
113
+ network_id = ovh_cloud_project_network_private.network.id
114
+
115
+ # whatever region, for test purpose
116
+ region = "{{ .Region }}"
117
+ start = "192.168.168.100"
118
+ end = "192.168.168.200"
119
+ network = "192.168.168.0/24"
120
+ dhcp = true
121
+ no_gateway = false
122
+
123
+ depends_on = [ovh_cloud_project_network_private.network]
115
124
}
116
125
117
126
resource "ovh_cloud_project_kube" "cluster" {
118
127
service_name = "{{ .ServiceName }}"
119
128
name = "{{ .Name }}"
120
129
region = "{{ .Region }}"
121
130
122
- private_network_id = tolist(ovh_cloud_project_network_private.network1 .regions_attributes)[index(ovh_cloud_project_network_private.network1.regions_attributes.*.region, "{{ .Region }}") ].openstackid
131
+ private_network_id = tolist(ovh_cloud_project_network_private.network .regions_attributes[* ].openstackid)[0]
123
132
124
133
private_network_configuration {
125
134
default_vrack_gateway = "{{ .DefaultVrackGateway }}"
126
135
private_network_routing_as_default = {{ .PrivateNetworkRoutingAsDefault }}
127
136
}
128
137
129
138
depends_on = [
130
- ovh_cloud_project_network_private.network1
139
+ ovh_cloud_project_network_private.network
131
140
]
132
141
}
133
142
`
@@ -166,8 +175,8 @@ resource "ovh_cloud_project_kube" "cluster" {
166
175
type configData struct {
167
176
Region string
168
177
Regions string
169
- Vlanid string
170
178
ServiceName string
179
+ VrackID string
171
180
Name string
172
181
DefaultVrackGateway string
173
182
PrivateNetworkRoutingAsDefault bool
@@ -221,8 +230,8 @@ func TestAccCloudProjectKubeCustomizationApiServerAdmissionPlugins(t *testing.T)
221
230
}
222
231
223
232
func TestAccCloudProjectKubeVRack (t * testing.T ) {
224
- region := os .Getenv ("OVH_CLOUD_PROJECT_KUBE_REGION_TEST" )
225
233
serviceName := os .Getenv ("OVH_CLOUD_PROJECT_SERVICE_TEST" )
234
+ vrackID := os .Getenv ("OVH_VRACK_SERVICE_TEST" )
226
235
227
236
name := acctest .RandomWithPrefix (test_prefix )
228
237
tmpl , err := template .New ("config" ).Parse (testAccCloudProjectKubeVRackConfig )
@@ -233,20 +242,18 @@ func TestAccCloudProjectKubeVRack(t *testing.T) {
233
242
var config bytes.Buffer
234
243
var configUpdated bytes.Buffer
235
244
configData1 := configData {
236
- Region : region ,
237
- Regions : `["` + region + `"]` ,
238
- Vlanid : "8" ,
239
245
ServiceName : serviceName ,
246
+ VrackID : vrackID ,
240
247
Name : name ,
248
+ Region : "GRA5" ,
241
249
DefaultVrackGateway : "" ,
242
250
PrivateNetworkRoutingAsDefault : false ,
243
251
}
244
252
configData2 := configData {
245
- Region : region ,
246
- Regions : `["` + region + `"]` ,
247
- Vlanid : "8" ,
248
253
ServiceName : serviceName ,
254
+ VrackID : vrackID ,
249
255
Name : name ,
256
+ Region : "GRA5" ,
250
257
DefaultVrackGateway : "10.4.0.1" ,
251
258
PrivateNetworkRoutingAsDefault : true ,
252
259
}
@@ -266,13 +273,13 @@ func TestAccCloudProjectKubeVRack(t *testing.T) {
266
273
testAccPreCheckCloud (t )
267
274
testAccCheckCloudProjectExists (t )
268
275
testAccPreCheckKubernetes (t )
276
+ testAccPreCheckKubernetesVRack (t )
269
277
},
270
278
Providers : testAccProviders ,
271
279
Steps : []resource.TestStep {
272
280
{
273
281
Config : config .String (),
274
282
Check : resource .ComposeTestCheckFunc (
275
- resource .TestCheckResourceAttr ("ovh_cloud_project_kube.cluster" , "region" , region ),
276
283
resource .TestCheckResourceAttrSet ("ovh_cloud_project_kube.cluster" , "kubeconfig" ),
277
284
resource .TestCheckResourceAttr ("ovh_cloud_project_kube.cluster" , kubeClusterNameKey , name ),
278
285
resource .TestCheckResourceAttrSet ("ovh_cloud_project_kube.cluster" , "version" ),
@@ -283,7 +290,6 @@ func TestAccCloudProjectKubeVRack(t *testing.T) {
283
290
{
284
291
Config : configUpdated .String (),
285
292
Check : resource .ComposeTestCheckFunc (
286
- resource .TestCheckResourceAttr ("ovh_cloud_project_kube.cluster" , "region" , region ),
287
293
resource .TestCheckResourceAttrSet ("ovh_cloud_project_kube.cluster" , "kubeconfig" ),
288
294
resource .TestCheckResourceAttr ("ovh_cloud_project_kube.cluster" , kubeClusterNameKey , name ),
289
295
resource .TestCheckResourceAttrSet ("ovh_cloud_project_kube.cluster" , "version" ),
0 commit comments