Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit a76cb97

Browse files
committed
rename gcore_instance added
1 parent b7a1839 commit a76cb97

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

gcore/resource_gcore_instance.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func resourceInstance() *schema.Resource {
9191
"name": &schema.Schema{
9292
Type: schema.TypeString,
9393
Optional: true,
94+
Computed: true,
9495
},
9596
"name_templates": &schema.Schema{
9697
Type: schema.TypeList,
@@ -643,6 +644,18 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, m inter
643644
return diag.FromErr(err)
644645
}
645646

647+
if d.HasChange("name") {
648+
nameTemplate := d.Get("name_templates").([]interface{})
649+
if len(nameTemplate) == 0 {
650+
opts := instances.RenameInstanceOpts{
651+
Name: d.Get("name").(string),
652+
}
653+
if _, err := instances.RenameInstance(client, instanceID, opts).Extract(); err != nil {
654+
return diag.FromErr(err)
655+
}
656+
}
657+
}
658+
646659
if d.HasChange("flavor_id") {
647660
flavor_id := d.Get("flavor_id").(string)
648661
results, err := instances.Resize(client, instanceID, instances.ChangeFlavorOpts{FlavorID: flavor_id}).Extract()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/G-Core/g-dns-sdk-go v0.1.2
99
github.com/G-Core/gcorelabs-storage-sdk-go v0.0.9
1010
github.com/G-Core/gcorelabscdn-go v0.1.2
11-
github.com/G-Core/gcorelabscloud-go v0.4.35
11+
github.com/G-Core/gcorelabscloud-go v0.4.36
1212
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1313
github.com/hashicorp/terraform-exec v0.15.0 // indirect
1414
github.com/hashicorp/terraform-plugin-docs v0.5.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ github.com/G-Core/gcorelabs-storage-sdk-go v0.0.9 h1:6uyKbknI8Q2pIJApPBf6JA0CN5O
4747
github.com/G-Core/gcorelabs-storage-sdk-go v0.0.9/go.mod h1:BZef79y4G28n8ic3x6iQWbW+mtpHPSUyJRfIRSkeAJw=
4848
github.com/G-Core/gcorelabscdn-go v0.1.2 h1:AiwZY3oIHL4wMJNmIlLgxw4eQmSqtQmkTzrkGpa7ckc=
4949
github.com/G-Core/gcorelabscdn-go v0.1.2/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
50-
github.com/G-Core/gcorelabscloud-go v0.4.35 h1:SXgfWPEPRwodZ8l7Mv/Dt2ZTgOK2YKfZMpODI46JB8A=
51-
github.com/G-Core/gcorelabscloud-go v0.4.35/go.mod h1:Z1MF80mWagEUrxygtYkvW/MJEYNmIUPsIEYBB3cKjOM=
50+
github.com/G-Core/gcorelabscloud-go v0.4.36 h1:SUf+LE8u8YKr0r1tPvL+YYhfw32zXk0OG2qSdPrCtaw=
51+
github.com/G-Core/gcorelabscloud-go v0.4.36/go.mod h1:Z1MF80mWagEUrxygtYkvW/MJEYNmIUPsIEYBB3cKjOM=
5252
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
5353
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
5454
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=

0 commit comments

Comments
 (0)