From e1e1a08569ccf1f4cbb5d978db864801ddbece4e Mon Sep 17 00:00:00 2001 From: James Nugent Date: Wed, 4 May 2016 18:09:38 -0500 Subject: [PATCH] provider/triton: support importing triton_key --- builtin/providers/triton/resource_key.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/providers/triton/resource_key.go b/builtin/providers/triton/resource_key.go index b941cb0bf..dc8d16327 100644 --- a/builtin/providers/triton/resource_key.go +++ b/builtin/providers/triton/resource_key.go @@ -20,6 +20,9 @@ func resourceKey() *schema.Resource { Exists: resourceKeyExists, Read: resourceKeyRead, Delete: resourceKeyDelete, + Importer: &schema.ResourceImporter{ + State: resourceKeyImporter, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -87,7 +90,7 @@ func resourceKeyExists(d *schema.ResourceData, meta interface{}) (bool, error) { func resourceKeyRead(d *schema.ResourceData, meta interface{}) error { client := meta.(*cloudapi.Client) - key, err := client.GetKey(d.Get("name").(string)) + key, err := client.GetKey(d.Id()) if err != nil { return err } @@ -108,3 +111,7 @@ func resourceKeyDelete(d *schema.ResourceData, meta interface{}) error { return nil } + +func resourceKeyImporter(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + return []*schema.ResourceData{d}, nil +}