pactflow / terraform-provider-pact

Terraform provider for Pact Broker (and Pactflow)
https://pactflow.io
MIT License
24 stars 4 forks source link

pact_webhook only allows JSON in the body #6

Closed ghost closed 4 years ago

ghost commented 4 years ago

Terraform Version

0.12.28

Affected Resource(s)

Terraform Configuration Files

provider "pact" {
  host = "http://localhost:9292"
}

resource "pact_pacticipant" "foo_service" {
  name = "foo"
}

resource "pact_webhook" "foo_events" {
  description = ""
  webhook_provider = {
    name = "foo"
  }
  request {
    url = "http://localhost:8000/jenkins/webhook"
    method = "POST"
    username = "username"
    password = "password"
    headers = {
      "Content-Type" = "application/x-www-form-encoded"
    }
    body = "json={\"parameter\": [{\"name\": \"TAG_AND_PUSH\", \"value\": \"false\"}]}"
  }
  events = ["contract_content_changed"]
  depends_on = [pact_pacticipant.foo_service]
}

Expected Behavior

terraform apply should complete successfully

Actual Behavior

terraform apply produced the following error:

Error: invalid character 'j' looking for beginning of value

Appears to be the result of only allowing the body to be JSON. I am attempting to create a webhook to Jenkins and it does not accept a JSON body, but instead expects the request to be form encoded. Requiring the body of the request to be JSON seems overly strict.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
mefellows commented 4 years ago

Thanks for the detailed report!

Yes you're right, it does currently assume a JSON payload. I'll get this fixed ASAP.

mefellows commented 4 years ago

I've just pushed a small change that should address this issue. There may be a few other instances like this that need tuning, but see if this gets you a little further. v0.0.5 should be out soon - thanks again!

ghost commented 4 years ago

That did the trick. Thank you for the quick response!

mefellows commented 4 years ago

Fantastic - thanks for the report!