Skip to content

Commit a8addd7

Browse files
Remove validation in new provider framework config (#1235)
* Remove validation in new provider framework config This validation was added here: #1206 However, it's done too early and it prevents the cases where we create a second provider with auth from a dynamically created API key or service account * Remove failing test. This validation is now done later
1 parent 1dfd29a commit a8addd7

File tree

3 files changed

+1
-14
lines changed

3 files changed

+1
-14
lines changed

internal/provider/configure_clients.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
func createClients(providerConfig frameworkProviderConfig) (*common.Client, error) {
2929
var err error
3030
c := &common.Client{}
31-
if !providerConfig.Auth.IsNull() {
31+
if !providerConfig.Auth.IsNull() && !providerConfig.URL.IsNull() {
3232
c.GrafanaAPIURL, c.GrafanaAPIConfig, c.DeprecatedGrafanaAPI, err = createGrafanaClient(providerConfig)
3333
if err != nil {
3434
return nil, err

internal/provider/framework_provider.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ func (c *frameworkProviderConfig) SetDefaults() error {
100100
})
101101
}
102102

103-
// Validating here so that it's done for both provider versions (SDK and Plugin Framework)
104-
if c.Auth.IsNull() && c.CloudAPIKey.IsNull() && c.SMAccessToken.IsNull() && c.OncallAccessToken.IsNull() {
105-
return fmt.Errorf("at least one of the following attributes must be set: auth, cloud_api_key, sm_access_token, oncall_access_token")
106-
}
107-
if !c.Auth.IsNull() && c.URL.IsNull() || c.Auth.IsNull() && !c.URL.IsNull() {
108-
return fmt.Errorf("both auth and url must be set")
109-
}
110-
111103
return nil
112104
}
113105

internal/provider/legacy_provider_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ func TestProviderConfigure(t *testing.T) {
7070
expectedErr string
7171
check func(t *testing.T, provider *schema.Provider)
7272
}{
73-
{
74-
name: "no config",
75-
env: map[string]string{},
76-
expectedErr: "at least one of the following attributes must be set: auth, cloud_api_key, sm_access_token, oncall_access_token",
77-
},
7873
{
7974
name: "grafana config from env",
8075
env: map[string]string{

0 commit comments

Comments
 (0)