Skip to content

Commit 3a1f433

Browse files
schrejadammck
authored andcommitted
Add OpenTelekomCloud provider (#112)
1 parent 2417ce8 commit 3a1f433

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The following providers are supported:
2525
* SoftLayer
2626
* VMware
2727
* Nutanix
28+
* Open Telekom Cloud
2829

2930
It's very simple to add support for new providers. See pull requests with the
3031
[provider][pv] label for examples.

parser_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,19 @@ const exampleStateFile = `
395395
}
396396
}
397397
},
398+
"opentelekomcloud_compute_instance_v2.nineteen": {
399+
"type": "opentelekomcloud_compute_instance_v2",
400+
"primary": {
401+
"id": "00000000-0000-0000-0000-000000000015",
402+
"attributes": {
403+
"id": "00000000-0000-0000-0000-000000000015",
404+
"access_ip_v4": "10.0.0.19",
405+
"access_ip_v6": "",
406+
"tag.%": "1",
407+
"tag.tfinventory": "rocks"
408+
}
409+
}
410+
},
398411
"profitbricks_server.sixteen": {
399412
"type": "profitbricks_server",
400413
"primary": {
@@ -444,6 +457,7 @@ const expectedListOutput = `
444457
"10.0.0.11",
445458
"10.0.0.13",
446459
"10.0.0.16",
460+
"10.0.0.19",
447461
"10.0.0.7",
448462
"10.0.0.8",
449463
"10.0.0.9",
@@ -481,6 +495,7 @@ const expectedListOutput = `
481495
"testTag1": ["10.20.30.50"],
482496
"thirteen": ["10.0.0.13"],
483497
"fourteen": ["192.168.102.14"],
498+
"nineteen": ["10.0.0.19"],
484499
"sixteen": ["10.0.0.16"],
485500
"seventeen": ["50.0.0.17"],
486501
"eighteen": ["80.80.100.124"],
@@ -501,6 +516,7 @@ const expectedListOutput = `
501516
"twelve.0": ["10.20.30.50"],
502517
"thirteen.0": ["10.0.0.13"],
503518
"fourteen.0": ["192.168.102.14"],
519+
"nineteen.0": ["10.0.0.19"],
504520
"sixteen.0": ["10.0.0.16"],
505521
"seventeen.0": ["50.0.0.17"],
506522
"eighteen.0": ["80.80.100.124"],
@@ -510,6 +526,7 @@ const expectedListOutput = `
510526
"type_cloudstack_instance": ["10.2.1.5"],
511527
"type_vsphere_virtual_machine": ["10.20.30.40", "10.20.30.50"],
512528
"type_openstack_compute_instance_v2": ["10.120.0.226"],
529+
"type_opentelekomcloud_compute_instance_v2": ["10.0.0.19"],
513530
"type_profitbricks_server": ["10.0.0.16"],
514531
"type_softlayer_virtual_guest": ["10.0.0.7"],
515532
"type_exoscale_compute": ["10.0.0.9"],
@@ -530,7 +547,8 @@ const expectedListOutput = `
530547
"staging": ["192.168.0.3"],
531548
"status_superserver": ["10.120.0.226"],
532549
"database": ["10.0.0.8"],
533-
"scw_test": ["10.0.0.11"]
550+
"scw_test": ["10.0.0.11"],
551+
"tfinventory_rocks": ["10.0.0.19"]
534552
}
535553
`
536554

@@ -540,6 +558,7 @@ const expectedInventoryOutput = `[all]
540558
10.0.0.11
541559
10.0.0.13
542560
10.0.0.16
561+
10.0.0.19
543562
10.0.0.7
544563
10.0.0.8
545564
10.0.0.9
@@ -611,6 +630,12 @@ olddatacenter="\u003c0.7_format"
611630
[nine.0]
612631
10.0.0.9
613632
633+
[nineteen]
634+
10.0.0.19
635+
636+
[nineteen.0]
637+
10.0.0.19
638+
614639
[one]
615640
10.0.0.1
616641
10.0.1.1
@@ -678,6 +703,9 @@ olddatacenter="\u003c0.7_format"
678703
[testTag1]
679704
10.20.30.50
680705
706+
[tfinventory_rocks]
707+
10.0.0.19
708+
681709
[thirteen]
682710
10.0.0.13
683711
@@ -731,6 +759,9 @@ olddatacenter="\u003c0.7_format"
731759
[type_openstack_compute_instance_v2]
732760
10.120.0.226
733761
762+
[type_opentelekomcloud_compute_instance_v2]
763+
10.0.0.19
764+
734765
[type_packet_device]
735766
10.0.0.13
736767

resource.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ func (r Resource) Tags() map[string]string {
112112
t[kk] = vv
113113
}
114114
}
115+
case "opentelekomcloud_compute_instance_v2":
116+
for k, v := range r.Attributes() {
117+
parts := strings.SplitN(k, ".", 2)
118+
// At some point Terraform changed the key for counts of attributes to end with ".%"
119+
// instead of ".#". Both need to be considered as Terraform still supports state
120+
// files using the old format.
121+
if len(parts) == 2 && parts[0] == "tag" && parts[1] != "#" && parts[1] != "%" {
122+
kk := strings.ToLower(parts[1])
123+
vv := strings.ToLower(v)
124+
t[kk] = vv
125+
}
126+
}
115127
case "aws_instance", "linode_instance":
116128
for k, v := range r.Attributes() {
117129
parts := strings.SplitN(k, ".", 2)

0 commit comments

Comments
 (0)