hashicorp/terraform — pull request #184 by catsby (2014-08-12 03:06:14+00:00)
Title: Update heroku-go to cyberdelia/heroku-go/v3

Hello Hashicorp –

**TL;DR:** switch Heroku Go library from [bgentry/heroku-go][1] to [cyberdelia/heroku-go/v3][2]

I wanted to take a stab at #116, but [bgentry/heroku-go][1] doesn't have support for the [Heroku Build API][3].
I tried adding it in bgentry/heroku-go#10 but ran into issues, and Blake suggested that Tim's library (cyberdelia/heroku-go) might be a better way forward. Thankfully it includes the [Build][3] and [App setup][4] APIs I would need, but instead of 1 giant pull request that changes the library *and* adds the features of #116, I broke them in two. Not much sense in developing new things if the foundation they're built on gets rejected :smile:

Porting over was pretty trivial; there are just a few minor differences:

- heroku-go/v3 uses a `heroku.Service` type instead of a `heroku.Client`
- ID fields are typically `ID` instead of `Id`
- Some methods like `AddonCreate` take 2 params, an app `name` and a `struct{config, plan}`, instead of 3 params for `name`, `config` and `plan`.
- some changing / removing of `&`'s

The latter of which may be "wrong". I'm still a Go novice, and may be using pointers when I should be using values, or values when I should be using pointers. The changes may simply be chalked up to differences in what the two libraries return/expect, and maybe not "wrong" at all ¯\\\_(ツ)_/¯

Caveat(s):

The Heroku tests pass:

$ make test TEST=./builtin/providers/heroku
TF_ACC= go test ./builtin/providers/heroku -timeout=10s
ok	github.com/hashicorp/terraform/builtin/providers/heroku	0.086s

The main test suite does not at the moment, neither on my branch or on master:

```
$ make test
TF_ACC= go test ./... -timeout=10s
ok	github.com/hashicorp/terraform	0.060s
ok	github.com/hashicorp/terraform/builtin/bins/provider-aws	0.016s
ok	github.com/hashicorp/terraform/builtin/bins/provider-cloudflare	0.013s
?	github.com/hashicorp/terraform/builtin/bins/provider-consul	[no test files]
ok	github.com/hashicorp/terraform/builtin/bins/provider-digitalocean	0.008s
[...]
2014/08/11 21:58:17 [ERROR] Error walking 'test_instance.foo': 1 error(s) occurred:

* error
2014/08/11 21:58:17 [INFO] Walking: test_instance.bar (Graph node: test_instance.bar)
[...]
2014/08/11 21:58:17 [INFO] Apply walk complete
--- FAIL: TestApply_vars (0.00 seconds)
panic: unsupported type: invalid [recovered]
panic: unsupported type: invalid

goroutine 168 [running]:
runtime.panic(0x41c2840, 0xc208100460)
[...]
FAIL	github.com/hashicorp/terraform/command	0.121s
ok	github.com/hashicorp/terraform/config	0.052s
[...]
--- FAIL: TestContextValidate_requiredVar (0.00 seconds)
panic: unsupported type: invalid [recovered]
panic: unsupported type: invalid
[...]
goroutine 17 [syscall]:
runtime.goexit()
/Users/clint/Developer/Cellar/go/1.3/libexec/src/pkg/runtime/proc.c:1445
FAIL	github.com/hashicorp/terraform/terraform	0.062s
make: *** [test] Error 1
```

The full test output [is here][5].

Let me know what you think!

--
Clint

[1]: https://github.com/bgentry/heroku-go
[2]: https://github.com/cyberdelia/heroku-go
[3]: https://devcenter.heroku.com/articles/build-and-release-using-the-api
[4]: https://blog.heroku.com/archives/2014/5/22/introducing_the_app_json_application_manifest
[5]: https://gist.github.com/catsby/7b0d11890c362f2cb8ee