provider/triton: support importing triton_key

This commit is contained in:
James Nugent 2016-05-04 18:09:38 -05:00 committed by Mitchell Hashimoto
parent 6bdab07174
commit e1e1a08569
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 8 additions and 1 deletions

View File

@ -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
}