Skip to content

Commit

Permalink
- Add tags to the instance
Browse files Browse the repository at this point in the history
- Update civo api to v0.1.0

Signed-off-by: Alejandro JNM <alejandrojnm@gmail.com>
  • Loading branch information
alejandrojnm committed Mar 8, 2020
1 parent 62c4abe commit e5e45e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
21 changes: 8 additions & 13 deletions civo/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,11 @@ func resourceInstance() *schema.Resource {
Description: "The ID of an already uploaded SSH public key to use for login to the default user (optional; if one isn't provided a random password will be set and returned in the initial_password field)",
},
"tags": {
Type: schema.TypeString,
Type: schema.TypeSet,
Optional: true,
Description: "An optional tags",
Description: "An optional list of tags, represented as a key, value pair",
Elem: &schema.Schema{Type: schema.TypeString},
},
//"tags": {
// Type: schema.TypeSet,
// Optional: true,
// Description: "An optional list of tags, represented as a key, value pair",
// Elem: &schema.Schema{Type: schema.TypeString},
//},
// Computed resource
"private_ip": {
Type: schema.TypeString,
Expand Down Expand Up @@ -143,10 +138,10 @@ func resourceInstanceCreate(d *schema.ResourceData, m interface{}) error {
config.SSHKeyID = attr.(string)
}

//if attr, ok := d.GetOk("tags"); ok {
// //config.Tags = attr.(*schema.Set).List()
// config.Tags = attr.(string)
//}
if attr, ok := d.GetOk("tags"); ok {
//config.Tags = attr.(*schema.Set).List()
config.Tags = attr.([]string)
}

instance, err := apiClient.CreateInstance(config)
if err != nil {
Expand Down Expand Up @@ -230,7 +225,7 @@ func resourceInstanceUpdate(d *schema.ResourceData, m interface{}) error {
notes := d.Get("notes").(string)
instance, err := apiClient.GetInstance(d.Id())
if err != nil {
// check if the droplet no longer exists.
// check if the instance no longer exists.
log.Printf("[WARN] Civo instance (%s) not found", d.Id())
d.SetId("")
return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/civo/terraform-provider-civo

require (
github.com/aws/aws-sdk-go v1.25.39 // indirect
github.com/civo/civogo v0.0.0-20200302122345-dd906190213e
github.com/civo/civogo v0.1.0
github.com/hashicorp/terraform-plugin-sdk v1.3.0
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d // indirect
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ github.com/civo/civogo v0.0.0-20200301092416-fc4a75b783d1 h1:TgSEHBD78LJmdFt+tuW
github.com/civo/civogo v0.0.0-20200301092416-fc4a75b783d1/go.mod h1:QwPxaDertZ7sxu3Fdibu/JdXBJV3RqYZrh76YEbGLKg=
github.com/civo/civogo v0.0.0-20200302122345-dd906190213e h1:psOQ3OL+5gjkKYS/ydfeFT/+DN+rOtFJHR4DxUR8Cok=
github.com/civo/civogo v0.0.0-20200302122345-dd906190213e/go.mod h1:QwPxaDertZ7sxu3Fdibu/JdXBJV3RqYZrh76YEbGLKg=
github.com/civo/civogo v0.1.0 h1:ltxiVPehDJ3uuUW/bCezHI4P+A1CSHfZKQAy/5Es2tw=
github.com/civo/civogo v0.1.0/go.mod h1:QwPxaDertZ7sxu3Fdibu/JdXBJV3RqYZrh76YEbGLKg=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down

0 comments on commit e5e45e6

Please sign in to comment.