Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitely set service attributes to null #62

Closed

Conversation

jtsaito
Copy link

@jtsaito jtsaito commented Jan 27, 2017

This PR addresses a change in the behaviour /services POST endpoint in the V2 API of Pagerduty (see documentation). Due to the change we had issues with our Terraform setup.

Problem
When creating a service without acknowledgement_timeout or auto_resolve_timeout, the service has acknowledgement timeout feature or auto resolve timeout feature enabled respectively. This was not the case so far. There is no longer a way to create a resource with the features disabled.

Expected behaviour:
When creating a pagerduty.Service without acknowledgement_timeout or auto_resolve_timeout by calling client.CreateService(service), the service disables the features and does not set acknowledgement_timeout and auto_resolve_timeout. (This used to be the case until a few days ago.)

Observed behaviour:
The service enables the features and sets non-zero default values for acknowledgement_timeout and auto_resolve_timeout.

Example code for reproducing the issue

package main

import (
  "fmt"

  pagerduty "github.com/PagerDuty/go-pagerduty"
)

func main() {
  client := pagerduty.NewClient("YOUR-API-TOKEN-HERE")

  epo := pagerduty.GetEscalationPolicyOptions{}
  ep, epErr := client.GetEscalationPolicy("PH77HFE", &epo)

  if epErr != nil {
    fmt.Printf("error: %v\n", epErr)
  }

  s := pagerduty.Service{
    Name:               "Cha0tic App",
    Description:        "Some infinities are bigger than other infinities",
    EscalationPolicy:   *ep,
    AutoResolveTimeout: nil,
  }

  t, e := client.CreateService(s)
  if e != nil {
    fmt.Printf("error: %v\n", e)
  }

  fmt.Println(t)
}

Submitted solution
We drop omitempty for the attributes in question. This restores the default behaviour of client.CreateService(service).

@jtsaito
Copy link
Author

jtsaito commented Jan 27, 2017

Sorry, there has already been a PR for the same issue: #53. Please merge that.

Closing this one.

@jtsaito jtsaito closed this Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant