jmccann / drone-terraform

Drone plugin for triggering Terraform deployments
http://plugins.drone.io/jmccann/terraform/
Apache License 2.0
86 stars 93 forks source link

Plugin tagged 5.2 panics in Drone 1.3.1, cannot unmarshal vars #103

Closed francoispqt closed 5 years ago

francoispqt commented 5 years ago

Hi,

The pipeline below panics in drone 1.3.1

---
kind: pipeline
type: docker
name: datadog-tf

steps:
  - name: plan
    image: jmccann/drone-terraform:5.2
    settings:
      tf_version: 0.11.13
      pull: true
      actions:
        - fmt
        - validate
        - plan
      secrets:
        - source: AWS_ROLE_TO_ASSUME
           target: PLUGIN_ROLE_ARN_TO_ASSUME
    when:
      event: pull_request

The logs are

time="2019-10-18T15:54:31Z" level=info msg="Drone Terraform Plugin Version" Revision=
panic: json: cannot unmarshal array into Go value of type map[string]string [recovered]
panic: json: cannot unmarshal array into Go value of type map[string]string  
goroutine 1 [running]:
github.com/urfave/cli.HandleAction.func1(0xc000149888)
/go/pkg/mod/github.com/urfave/cli@v0.0.0-20161006035353-55f715e28c46/app.go:478 +0x23a
panic(0x7e37e0, 0xc0000ae820)
/usr/local/go/src/runtime/panic.go:513 +0x1b9
main.run(0xc0000de780, 0x0, 0x0)
/tmp/drone-terraform/main.go:136 +0xc40
reflect.Value.call(0x7d3600, 0x8700a8, 0x13, 0x8555b0, 0x4, 0xc00008f848, 0x1, 0x1, 0xc0000c6000, 0xc0000de780, ...)
/usr/local/go/src/reflect/value.go:447 +0x454
reflect.Value.Call(0x7d3600, 0x8700a8, 0x13, 0xc00008f848, 0x1, 0x1, 0x2, 0x2, 0x1)
/usr/local/go/src/reflect/value.go:308 +0xa4
github.com/urfave/cli.HandleAction(0x7d3600, 0x8700a8, 0xc0000de780, 0x0, 0x0)
/go/pkg/mod/github.com/urfave/cli@v0.0.0-20161006035353-55f715e28c46/app.go:487 +0x1f8
github.com/urfave/cli.(*App).Run(0xc00007e480, 0xc0000921c0, 0x1, 0x1, 0x0, 0x0)
/go/pkg/mod/github.com/urfave/cli@v0.0.0-20161006035353-55f715e28c46/app.go:245 +0x47f
main.main()
/tmp/drone-terraform/main.go:113 +0xd9d

Am I doing anything wrong?

Thanks

francoispqt commented 5 years ago

If I set vars explicitely to an empty object, it works:

---
kind: pipeline
type: docker
name: datadog-tf

steps:
  - name: plan
    image: jmccann/drone-terraform:5.2
    settings:
      tf_version: 0.11.13
      pull: true
      actions:
        - fmt
        - validate
        - plan
      role_arn_to_assume:
         from_secret: AWS_ROLE_TO_ASSUME
      vars: {}
    when:
      event: pull_request