Skip to content

Commit 090b56f

Browse files
Add Grafana Oncall support (#456)
* Add resource_amixr_integration * Add amixr token description * Return accidentally deleted resource * Rename aapi to amixrAPI and prefix amixr resources * Add bunch of Amixr resources. - Route - Escalation Chain - Escalation - Schedule - On-call shift * Add Amixr's data sources: - Action - Escalation Chain - Schedule - Team - User - User Group - SlackChanel * Minor naming fixes * Add handling of non-existent resources * Fix handling of non-existent resources if server is down * Add default amixr_url * Add trailing slash to default amixr_url * Add acceptance test for Grafana OnCall * Add "amixr" prefix to route_test * Linting * Lint imports * Fix TestProviderConfigure * Add grafana-amixr-access-token secret * Configute amixr client only if token provided * Fix grafana-amixr-token secret name * Run make drone * Fix TestProviderConfigure * Fix TestProviderConfigure * Fix amixr tests * Fix amixr tests * Change default amixr_url * Fix TestProviderConfigure * Add autogenerated docs * Fix access to amixrAPI client in tests * Make default_route required for an integration * Improve amixr docs, add examples * Add import section in amixr docs * Rename amixr -> oncall * Format examples * Recreate oncall docs * Style fixes * Rename amixr to oncall in drone * Fix exmaple for grafana_oncall_outgoing_webhook * Lint * Fix TestProviderConfigure * format errors * Rename outgoing_webhook back to action * Add docs oncall_action * Fix docs drift
1 parent b7cb0ea commit 090b56f

File tree

66 files changed

+3999
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3999
-3
lines changed

.drone/drone.jsonnet

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ local secret(name, vaultPath, vaultKey) = {
1818
local cloudApiKey = secret('grafana-cloud-api-key', 'infra/data/ci/terraform-provider-grafana/cloud', 'cloud-api-key');
1919
local apiToken = secret('grafana-api-token', 'infra/data/ci/terraform-provider-grafana/cloud', 'api-key');
2020
local smToken = secret('grafana-sm-token', 'infra/data/ci/terraform-provider-grafana/cloud', 'sm-access-token');
21+
local onCallToken = secret('grafana-oncall-token', 'infra/data/ci/terraform-provider-grafana/cloud', 'oncall-access-token');
2122

2223
local pipeline(name, steps, services=[]) = {
2324
kind: 'pipeline',
@@ -116,6 +117,7 @@ local pipeline(name, steps, services=[]) = {
116117
GRAFANA_AUTH: apiToken.fromSecret,
117118
GRAFANA_SM_ACCESS_TOKEN: smToken.fromSecret,
118119
GRAFANA_ORG_ID: 1,
120+
GRAFANA_ONCALL_ACCESS_TOKEN: onCallToken.fromSecret,
119121
},
120122
},
121123
]
@@ -126,6 +128,7 @@ local pipeline(name, steps, services=[]) = {
126128
cloudApiKey,
127129
apiToken,
128130
smToken,
131+
onCallToken,
129132
] +
130133
[
131134
pipeline(

.drone/drone.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ steps:
110110
environment:
111111
GRAFANA_AUTH:
112112
from_secret: grafana-api-token
113+
GRAFANA_ONCALL_ACCESS_TOKEN:
114+
from_secret: grafana-oncall-token
113115
GRAFANA_ORG_ID: 1
114116
GRAFANA_SM_ACCESS_TOKEN:
115117
from_secret: grafana-sm-token
@@ -144,6 +146,12 @@ get:
144146
kind: secret
145147
name: grafana-sm-token
146148
---
149+
get:
150+
name: oncall-access-token
151+
path: infra/data/ci/terraform-provider-grafana/cloud
152+
kind: secret
153+
name: grafana-oncall-token
154+
---
147155
kind: pipeline
148156
name: 'oss tests: 8.5.0'
149157
platform:
@@ -300,6 +308,6 @@ workspace:
300308
path: /drone/terraform-provider-grafana
301309
---
302310
kind: signature
303-
hmac: 6ff6d080f8016b9d41ac6f560d82c5bb0ea1a267e30adbf66fd2e99b1be6b5b0
311+
hmac: 2525048a966617acb86ea8f67062ceed15fb03290ebfc01f2f089447dbcee09d
304312

305313
...

GNUmakefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
GRAFANA_VERSION ?= 8.4.4
2+
OS_ARCH=darwin_arm64
3+
BINARY=terraform-provider-${NAME}
4+
HOSTNAME=grafana.com
5+
NAMESPACE=raintank
6+
NAME=grafana
7+
VERSION=0.2.4
28

39
testacc:
410
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m
@@ -45,3 +51,11 @@ drone:
4551
drone jsonnet --stream --source .drone/drone.jsonnet --target .drone/drone.yml --format
4652
drone lint .drone/drone.yml
4753
drone sign --save grafana/terraform-provider-grafana .drone/drone.yml
54+
55+
build:
56+
go build -o ${BINARY}
57+
58+
install: build
59+
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
60+
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
61+

docs/data-sources/oncall_action.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_action Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
HTTP API https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/outgoing_webhooks/
7+
---
8+
9+
# grafana_oncall_action (Data Source)
10+
11+
* [HTTP API](https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/outgoing_webhooks/)
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "grafana_oncall_action" "example_action" {
17+
name = "example_action"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `name` (String) The action name.
27+
28+
### Optional
29+
30+
- `id` (String) The ID of this resource.
31+
32+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_escalation_chain Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
HTTP API https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/escalation_chains/
7+
---
8+
9+
# grafana_oncall_escalation_chain (Data Source)
10+
11+
* [HTTP API](https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/escalation_chains/)
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "grafana_oncall_escalation_chain" "default" {
17+
name = "default"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `name` (String) The escalation chain name.
27+
28+
### Optional
29+
30+
- `id` (String) The ID of this resource.
31+
32+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_schedule Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
Official documentation https://grafana.com/docs/grafana-cloud/oncall/calendar-schedules/HTTP API https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/schedules/
7+
---
8+
9+
# grafana_oncall_schedule (Data Source)
10+
11+
* [Official documentation](https://grafana.com/docs/grafana-cloud/oncall/calendar-schedules/)
12+
* [HTTP API](https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/schedules/)
13+
14+
## Example Usage
15+
16+
```terraform
17+
data "grafana_oncall_schedule" "schedule" {
18+
name = "example_schedule"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `name` (String) The schedule name.
28+
29+
### Optional
30+
31+
- `id` (String) The ID of this resource.
32+
33+
### Read-Only
34+
35+
- `type` (String) The schedule type.
36+
37+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_slack_channel Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
HTTP API https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/slack_channels/
7+
---
8+
9+
# grafana_oncall_slack_channel (Data Source)
10+
11+
* [HTTP API](https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/slack_channels/)
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "grafana_oncall_slack_channel" "example_slack_channel" {
17+
name = "example_slack_channel"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `name` (String) The Slack channel name.
27+
28+
### Optional
29+
30+
- `id` (String) The ID of this resource.
31+
32+
### Read-Only
33+
34+
- `slack_id` (String) The Slack ID of the channel.
35+
36+

docs/data-sources/oncall_team.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_team Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# grafana_oncall_team (Data Source)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "grafana_oncall_team" "example_team" {
17+
name = "example_team"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `name` (String) The team name.
27+
28+
### Optional
29+
30+
- `id` (String) The ID of this resource.
31+
32+
### Read-Only
33+
34+
- `avatar_url` (String)
35+
- `email` (String)
36+
37+

docs/data-sources/oncall_user.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_user Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
HTTP API https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/users/
7+
---
8+
9+
# grafana_oncall_user (Data Source)
10+
11+
* [HTTP API](https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/users/)
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "grafana_oncall_user" "alex" {
17+
username = "alex"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `username` (String) The username of the user.
27+
28+
### Optional
29+
30+
- `id` (String) The ID of this resource.
31+
32+
### Read-Only
33+
34+
- `email` (String) The email of the user.
35+
- `role` (String) The role of the user.
36+
37+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_oncall_user_group Data Source - terraform-provider-grafana"
4+
subcategory: ""
5+
description: |-
6+
HTTP API https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/user_groups/
7+
---
8+
9+
# grafana_oncall_user_group (Data Source)
10+
11+
* [HTTP API](https://grafana.com/docs/grafana-cloud/oncall/oncall-api-reference/user_groups/)
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "grafana_oncall_user_group" "example_user_group" {
17+
slack_handle = "example_slack_handle"
18+
}
19+
```
20+
21+
<!-- schema generated by tfplugindocs -->
22+
## Schema
23+
24+
### Required
25+
26+
- `slack_handle` (String)
27+
28+
### Optional
29+
30+
- `id` (String) The ID of this resource.
31+
32+
### Read-Only
33+
34+
- `slack_id` (String)
35+
36+

0 commit comments

Comments
 (0)