Skip to content

Commit

Permalink
Add importer for startup script
Browse files Browse the repository at this point in the history
  • Loading branch information
LA Roberto committed Nov 30, 2017
1 parent 9fb7df0 commit cc6fb30
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vultr/resource_startup_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ func resourceStartupScript() *schema.Resource {
Read: resourceStartupScriptRead,
Update: resourceStartupScriptUpdate,
Delete: resourceStartupScriptDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"content": {
Expand Down Expand Up @@ -67,6 +70,12 @@ func resourceStartupScriptRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error getting startup script (%s): %v", d.Id(), err)
}

if script == (lib.StartupScript{}) {
log.Printf("[WARN] Removing startup script (%s) because it is gone", d.Id())
d.SetId("")
return nil
}

d.Set("content", script.Content)
d.Set("name", script.Name)
d.Set("type", script.Type)
Expand Down

0 comments on commit cc6fb30

Please sign in to comment.