Skip to content

Commit

Permalink
Issue opsgenie#437 - Update resource_opsgenie_service.go
Browse files Browse the repository at this point in the history
opsgenie#437

To achieve the team_id update, applying a quick solution - Deleting & creating service again, as there is no issue with service creation or deletion. Hence to apply a quick fix to the problem, we can delete and create the service again.
  • Loading branch information
SharmaRakeshKumar authored Jul 4, 2024
1 parent 1fe1e11 commit c16ccbf
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions opsgenie/resource_opsgenie_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,31 @@ func resourceOpsGenieServiceRead(d *schema.ResourceData, meta interface{}) error
}

func resourceOpsGenieServiceUpdate(d *schema.ResourceData, meta interface{}) error {
client, err := service.NewClient(meta.(*OpsgenieClient).client.Config)
if err != nil {
return err
}
name := d.Get("name").(string)
description := d.Get("description").(string)
tags := flattenTags(d, "tags")

log.Printf("[INFO] Updating OpsGenie service '%s'", name)

updateRequest := &service.UpdateRequest{
Id: d.Id(),
Name: name,
Description: description,
Tags: tags,
}

_, err = client.Update(context.Background(), updateRequest)
if err != nil {
return err
}

resourceOpsGenieServiceDelete(d, meta)
resourceOpsGenieServiceCreate(d, meta)

// client, err := service.NewClient(meta.(*OpsgenieClient).client.Config)
// if err != nil {
// return err
// }
// name := d.Get("name").(string)
// description := d.Get("description").(string)
// tags := flattenTags(d, "tags")

// log.Printf("[INFO] Updating OpsGenie service '%s'", name)

// updateRequest := &service.UpdateRequest{
// Id: d.Id(),
// Name: name,
// Description: description,
// Tags: tags,
// }

// _, err = client.Update(context.Background(), updateRequest)
// if err != nil {
// return err
// }

return nil
}
Expand Down

0 comments on commit c16ccbf

Please sign in to comment.