|
1 | | -Terraform Provider |
2 | | -================== |
| 1 | +<a href="https://terraform.io"> |
| 2 | + <img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-hashicorp.svg" title="Terraform" align="right" height="50" /> |
| 3 | +</a> |
3 | 4 |
|
4 | | -- Website: https://www.terraform.io |
5 | | -- [](https://gitter.im/hashicorp-terraform/Lobby) |
6 | | -- Mailing list: [Google Groups](http://groups.google.com/group/terraform-tool) |
| 5 | +# Terraform Provider for Grafana |
7 | 6 |
|
8 | | -<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-hashicorp.svg" width="600px"> |
| 7 | +- Terraform website: https://terraform.io |
| 8 | +- Grafana website: https://grafana.com |
| 9 | +- Provider Documentation: https://registry.terraform.io/providers/grafana/grafana/latest/docs |
| 10 | +- Terraform Chat: [Terraform Gitter](https://gitter.im/hashicorp-terraform/Lobby) |
| 11 | +- Grafana Chat: [Grafana #terraform Slack channel](https://grafana.slack.com/archives/C017MUCFJUT) |
| 12 | +- Terraform Mailing List: [Google Groups](http://groups.google.com/group/terraform-tool) |
9 | 13 |
|
10 | | -Requirements |
11 | | ------------- |
| 14 | +## Development |
12 | 15 |
|
13 | | -- [Terraform](https://www.terraform.io/downloads.html) 0.10.x |
14 | | -- [Go](https://golang.org/doc/install) 1.11 (to build the provider plugin) |
| 16 | +If you're new to provider development, a good place to start is the [Extending |
| 17 | +Terraform](https://www.terraform.io/docs/extend/index.html) docs. |
15 | 18 |
|
16 | | -Building The Provider |
17 | | ---------------------- |
| 19 | +Set up your local environment by installing [Go](http://www.golang.org). Also |
| 20 | +recommended is [Docker](https://docs.docker.com/install/). Docker is not |
| 21 | +required, but it makes running a local Grafana instance for acceptance tests |
| 22 | +very easy. |
18 | 23 |
|
19 | | -Clone repository to: `$GOPATH/src/github.com/terraform-providers/terraform-provider-grafana` |
| 24 | +Run [unit tests](https://www.terraform.io/docs/extend/testing/unit-testing.html): |
20 | 25 |
|
21 | 26 | ```sh |
22 | | -$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers |
23 | | -$ git clone [email protected]:terraform-providers/terraform-provider-grafana |
| 27 | +make test |
24 | 28 | ``` |
25 | 29 |
|
26 | | -Enter the provider directory and build the provider |
| 30 | +Run [acceptance tests](https://www.terraform.io/docs/extend/testing/acceptance-tests/index.html): |
27 | 31 |
|
28 | 32 | ```sh |
29 | | -$ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-grafana |
30 | | -$ make build |
| 33 | +# In one terminal, run a Grafana container. |
| 34 | +# You may optionally override the image tag... |
| 35 | +# GRAFANA_VERSION=7.1.1 \ |
| 36 | +make test-serve |
| 37 | + |
| 38 | +# In another... |
| 39 | +GRAFANA_URL=http://localhost:3000 \ |
| 40 | +GRAFANA_AUTH=admin:admin \ |
| 41 | +make testacc |
31 | 42 | ``` |
32 | 43 |
|
33 | | -Developing the Provider |
34 | | ---------------------------- |
35 | | - |
36 | | -If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.11+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`. |
37 | | - |
38 | | -To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory. |
39 | | - |
40 | | -```sh |
41 | | -$ make bin |
42 | | -... |
43 | | -$ $GOPATH/bin/terraform-provider-grafana |
44 | | -... |
45 | | -``` |
46 | | - |
47 | | -In order to test the provider, you can simply run `make test`. |
48 | | - |
49 | | -```sh |
50 | | -$ make test |
51 | | -``` |
52 | | - |
53 | | -In order to run the full suite of Acceptance tests, run `make testacc`. This should be |
54 | | -performed before merging or opening pull requests. |
55 | | - |
56 | | -```sh |
57 | | -$ GRAFANA_URL=http://localhost:3000 GRAFANA_AUTH=admin:admin make testacc |
58 | | -``` |
59 | | - |
60 | | -This requires a running Grafana server locally. This provider targets |
61 | | -the latest version of Grafana, but older versions should be compatible where |
62 | | -possible. In some cases, older versions of this provider will work with |
63 | | -older versions of Grafana. |
64 | | - |
65 | | -If you have [Docker](https://docs.docker.com/install/) installed, you can |
66 | | -run Grafana with the following command: |
67 | | - |
68 | | -```sh |
69 | | -$ make test-serv |
70 | | -``` |
71 | | - |
72 | | -By default, this will use the latest version of Grafana based on their |
73 | | -Docker repository. You can specify the version with the following: |
74 | | - |
75 | | -```sh |
76 | | -$ GRAFANA_VERSION=3.1.1 make test-serv |
77 | | -``` |
78 | | - |
79 | | -This command will run attached and will stop the Grafana server when |
80 | | -interrupted. Images will be cached locally by Docker so it is quicky to |
81 | | -restart the server as necessary. The server will use the default port and |
82 | | -credentials for the `GRAFANA_AUTH` and `GRAFANA_URL` environment variables. |
83 | | - |
84 | | -Nightly acceptance tests are run against the `latest` tag of the Grafana |
85 | | -maintained Docker image. |
| 44 | +This codebase leverages |
| 45 | +[grafana/grafana-api-golang-client](https://github.com/grafana/grafana-api-golang-client) as its Grafana API |
| 46 | +client. All resources and data sources should leverage this. |
0 commit comments