Skip to content

Commit

Permalink
Merge pull request #65 from ddymko/v1-user-data-fix
Browse files Browse the repository at this point in the history
V1 : Fix user-data for strings to be encoded on create/update call
  • Loading branch information
ddymko authored Sep 15, 2020
2 parents b472843 + ec9813d commit 09a16af
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ require (
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.8.0
github.com/pkg/errors v0.9.1
github.com/vultr/govultr v0.5.0
github.com/vultr/govultr v1.0.0
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4A
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vultr/govultr v0.5.0 h1:iQzYhzbokmpDARbvIkvTkoyS7WMH82zVTKAL1PZ4JOA=
github.com/vultr/govultr v0.5.0/go.mod h1:wZZXZbYbqyY1n3AldoeYNZK4Wnmmoq6dNFkvd5TV3ss=
github.com/vultr/govultr v1.0.0 h1:yeJrYp9wyA4xXaQZ7eOL2u1wKn2JU79HjRevwvpxbJ4=
github.com/vultr/govultr v1.0.0/go.mod h1:wZZXZbYbqyY1n3AldoeYNZK4Wnmmoq6dNFkvd5TV3ss=
github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.1.0 h1:uJwc9HiBOCpoKIObTQaLR+tsEXx1HBHnOsOOpcdhZgw=
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/vultr/govultr/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/vultr/govultr/govultr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ github.com/ulikunitz/xz/lzma
# github.com/vmihailenco/msgpack v4.0.1+incompatible
github.com/vmihailenco/msgpack
github.com/vmihailenco/msgpack/codes
# github.com/vultr/govultr v0.5.0
# github.com/vultr/govultr v1.0.0
github.com/vultr/govultr
# github.com/zclconf/go-cty v1.2.1
github.com/zclconf/go-cty/cty
Expand Down
2 changes: 1 addition & 1 deletion vultr/data_source_vultr_server_ipv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func dataSourceVultrServerIPV4() *schema.Resource {
Computed: true,
},
"reverse": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
},
Expand Down
5 changes: 3 additions & 2 deletions vultr/resource_vultr_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vultr

import (
"context"
"encoding/base64"
"fmt"
"log"
"strconv"
Expand Down Expand Up @@ -259,7 +260,7 @@ func resourceVultrServerCreate(d *schema.ResourceData, meta interface{}) error {
EnablePrivateNetwork: d.Get("enable_private_network").(bool),
Label: d.Get("label").(string),
AutoBackups: d.Get("auto_backup").(bool),
UserData: d.Get("user_data").(string),
UserData: base64.StdEncoding.EncodeToString([]byte(d.Get("user_data").(string))),
NotifyActivate: d.Get("notify_activate").(bool),
DDOSProtection: d.Get("ddos_protection").(bool),
Hostname: d.Get("hostname").(string),
Expand Down Expand Up @@ -527,7 +528,7 @@ func resourceVultrServerUpdate(d *schema.ResourceData, meta interface{}) error {

if d.HasChange("user_data") {
log.Printf("[INFO] Updating user_data")
if err := client.Server.SetUserData(context.Background(), d.Id(), d.Get("user_data").(string)); err != nil {
if err := client.Server.SetUserData(context.Background(), d.Id(), base64.StdEncoding.EncodeToString([]byte(d.Get("user_data").(string)))); err != nil {
return fmt.Errorf("error occured while updating user_data for server %s : %v", d.Id(), err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion vultr/resource_vultr_server_ipv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func resourceVultrServerIPV4() *schema.Resource {
Computed: true,
},
"reverse": {
Type: schema.TypeString,
Type: schema.TypeString,
Computed: true,
},
"reboot": {
Expand Down

0 comments on commit 09a16af

Please sign in to comment.