Skip to content

Commit d7f6390

Browse files
authored
Revert "Update OnCall client setup to support service account auth (#1859)" (#1954)
This reverts commit cedadb6.
1 parent cedadb6 commit d7f6390

File tree

5 files changed

+2
-112
lines changed

5 files changed

+2
-112
lines changed

docs/index.md

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -201,46 +201,6 @@ resource "grafana_oncall_escalation" "example_notify_step" {
201201
}
202202
```
203203

204-
Alternatively, you can also configure the provider block by setting `url`
205-
to your Grafana URL and `auth` to a service account token:
206-
207-
```terraform
208-
// Step 1: Configure provider block.
209-
provider "grafana" {
210-
alias = "oncall"
211-
url = "http://grafana.example.com/"
212-
auth = var.grafana_auth
213-
}
214-
215-
data "grafana_oncall_user" "alex" {
216-
username = "alex"
217-
}
218-
219-
// Step 2: Interact with Grafana OnCall
220-
resource "grafana_oncall_integration" "test-acc-integration" {
221-
provider = grafana.oncall
222-
name = "my integration"
223-
type = "grafana"
224-
default_route {
225-
escalation_chain_id = grafana_oncall_escalation_chain.default.id
226-
}
227-
}
228-
229-
resource "grafana_oncall_escalation_chain" "default" {
230-
provider = grafana.oncall
231-
name = "default"
232-
}
233-
234-
resource "grafana_oncall_escalation" "example_notify_step" {
235-
escalation_chain_id = grafana_oncall_escalation_chain.default.id
236-
type = "notify_persons"
237-
persons_to_notify = [
238-
data.grafana_oncall_user.alex.id
239-
]
240-
position = 0
241-
}
242-
```
243-
244204
<!-- schema generated by tfplugindocs -->
245205
## Schema
246206

examples/provider/provider-oncall-sa.tf

Lines changed: 0 additions & 34 deletions
This file was deleted.

pkg/provider/configure_clients.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func CreateClients(providerConfig ProviderConfig) (*common.Client, error) {
5252
if !providerConfig.SMAccessToken.IsNull() {
5353
c.SMAPI = SMAPI.NewClient(providerConfig.SMURL.ValueString(), providerConfig.SMAccessToken.ValueString(), getRetryClient(providerConfig))
5454
}
55-
if !providerConfig.OncallURL.IsNull() && (!providerConfig.OncallAccessToken.IsNull() || (!providerConfig.Auth.IsNull() && !providerConfig.URL.IsNull())) {
55+
if !providerConfig.OncallAccessToken.IsNull() {
5656
var onCallClient *onCallAPI.Client
5757
onCallClient, err = createOnCallClient(providerConfig)
5858
if err != nil {
@@ -182,12 +182,7 @@ func createCloudClient(client *common.Client, providerConfig ProviderConfig) err
182182
}
183183

184184
func createOnCallClient(providerConfig ProviderConfig) (*onCallAPI.Client, error) {
185-
authToken := providerConfig.OncallAccessToken.ValueString()
186-
if authToken == "" {
187-
// prefer OncallAccessToken if it was set, otherwise use Grafana auth (service account) token
188-
authToken = providerConfig.Auth.ValueString()
189-
}
190-
return onCallAPI.NewWithGrafanaURL(providerConfig.OncallURL.ValueString(), authToken, providerConfig.URL.ValueString())
185+
return onCallAPI.New(providerConfig.OncallURL.ValueString(), providerConfig.OncallAccessToken.ValueString())
191186
}
192187

193188
func createCloudProviderClient(client *common.Client, providerConfig ProviderConfig) error {

pkg/provider/configure_clients_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ func TestCreateClients(t *testing.T) {
120120
assert.NotNil(t, c.GrafanaAPI)
121121
assert.NotNil(t, c.MLAPI)
122122
assert.NotNil(t, c.SLOClient)
123-
assert.Nil(t, c.OnCallClient)
124123
},
125124
},
126125
{
@@ -134,31 +133,6 @@ func TestCreateClients(t *testing.T) {
134133
assert.NotNil(t, c.GrafanaAPI)
135134
},
136135
},
137-
{
138-
name: "OnCall client using original config (not setting Grafana URL)",
139-
config: ProviderConfig{
140-
OncallAccessToken: types.StringValue("oncall-token"),
141-
OncallURL: types.StringValue("http://oncall.url"),
142-
},
143-
expected: func(c *common.Client, err error) {
144-
assert.Nil(t, err)
145-
assert.NotNil(t, c.OnCallClient)
146-
assert.Nil(t, c.OnCallClient.GrafanaURL())
147-
},
148-
},
149-
{
150-
name: "OnCall client setting Grafana URL (using Grafana URL and auth)",
151-
config: ProviderConfig{
152-
URL: types.StringValue("http://localhost:3000"),
153-
Auth: types.StringValue("service-account-token"),
154-
OncallURL: types.StringValue("http://oncall.url"),
155-
},
156-
expected: func(c *common.Client, err error) {
157-
assert.Nil(t, err)
158-
assert.NotNil(t, c.OnCallClient)
159-
assert.Equal(t, "http://localhost:3000", c.OnCallClient.GrafanaURL().String())
160-
},
161-
},
162136
}
163137

164138
for _, tc := range testCases {

templates/index.md.tmpl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ The changelog for this provider can be found here: <https://github.com/grafana/t
3030

3131
{{ tffile "examples/provider/provider-oncall.tf" }}
3232

33-
Alternatively, you can also configure the provider block by setting `url`
34-
to your Grafana URL and `auth` to a service account token:
35-
36-
{{ tffile "examples/provider/provider-oncall-sa.tf" }}
37-
3833
{{ .SchemaMarkdown | trimspace }}
3934

4035
### Managing Cloud Provider

0 commit comments

Comments
 (0)