Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
TER-240: Add basic update feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Caussat committed Mar 30, 2018
1 parent 0d68cfa commit 74acb6e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions ghost/resource_ghost_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,20 +510,30 @@ func resourceGhostAppRead(d *schema.ResourceData, meta interface{}) error {
}

func resourceGhostAppUpdate(d *schema.ResourceData, meta interface{}) error {
//client := meta.(*ghost.Client)
client := meta.(*ghost.Client)

log.Printf("[INFO] Updating Ghost app %s", d.Get("name").(string))

app := expandGhostApp(d)

eveMetadata, err := client.UpdateApp(&app, d.Id(), d.Get("eve_etag").(string))
if err != nil {
return fmt.Errorf("[ERROR] error updating Ghost app: %v", err)
}

d.Set("eve_etag", *eveMetadata.Etag)

return resourceGhostAppRead(d, meta)
}

func resourceGhostAppDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ghost.Client)

log.Printf("[INFO] Deleting Ghost app %s", d.Get("name").(string))

err := client.DeleteApp(d.Id(), d.Get("eve_etag").(string))
if err == nil {
fmt.Println("[INFO] App deleted: " + d.Id())
} else {
log.Fatalf("[ERROR] error deleting Ghost app: %v", err)
if err != nil {
return fmt.Errorf("[ERROR] error deleting Ghost app: %v", err)
}

d.SetId("")
Expand Down

0 comments on commit 74acb6e

Please sign in to comment.