Skip to content

Commit 2ae7662

Browse files
authored
Merge pull request #1074 from PagerDuty/contact-method-err
False positive validation error on pagerduty_user_contact_method
2 parents ad07573 + 894e521 commit 2ae7662

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

pagerduty/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (c *Config) Client() (*pagerduty.Client, error) {
127127
})
128128

129129
if err != nil {
130-
return nil, fmt.Errorf(fmt.Sprintf("%s\n%s", err, invalidCreds))
130+
return nil, fmt.Errorf("%s\n%s", err, invalidCreds)
131131
}
132132
}
133133

pagerduty/provider.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package pagerduty
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"log"
78
"regexp"
@@ -282,14 +283,14 @@ func expandAppOauthTokenParams(v interface{}) *persistentconfig.AppOauthScopedTo
282283
return aotp
283284
}
284285

285-
var validationAuthMethodConfigWarning = "PagerDuty Provider has been set to authenticate API calls utilizing API token and App Oauth token at same time, in this scenario the use of App Oauth token is prioritised over API token authentication configuration. It is recommended to explicitely set just one authentication method.\nWe also suggest you to check your environment variables in case `token` being automatically read by Provider configuration through `PAGERDUTY_TOKEN` environment variable."
286+
var authMethodConfigErr = errors.New("PagerDuty Provider has been set to authenticate API calls utilizing API token and App Oauth token at same time, in this scenario the use of App Oauth token is prioritised over API token authentication configuration. It is recommended to explicitely set just one authentication method.\nWe also suggest you to check your environment variables in case `token` being automatically read by Provider configuration through `PAGERDUTY_TOKEN` environment variable.")
286287

287288
func validateAuthMethodConfig(data *schema.ResourceData) error {
288289
_, isSetAPIToken := data.GetOk("token")
289290
_, isSetUseAppOauthScopedToken := data.GetOk("use_app_oauth_scoped_token")
290291

291292
if isSetUseAppOauthScopedToken && isSetAPIToken {
292-
return fmt.Errorf(validationAuthMethodConfigWarning)
293+
return authMethodConfigErr
293294
}
294295

295296
return nil

pagerdutyplugin/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (c *Config) Client(ctx context.Context) (*pagerduty.Client, error) {
139139
return nil
140140
})
141141
if err != nil {
142-
return nil, fmt.Errorf(fmt.Sprintf("%s\n%s", err, invalidCreds))
142+
return nil, fmt.Errorf("%s\n%s", err, invalidCreds)
143143
}
144144
}
145145
c.client = client

util/validate_contact_address.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ func (v contactAddressValidator) ValidateString(ctx context.Context, req validat
3535
if resp.Diagnostics.HasError() {
3636
return
3737
}
38+
39+
// Skip validation if any required value is unknown (e.g., from variable references)
40+
if typeConfig.IsUnknown() || req.ConfigValue.IsUnknown() {
41+
return
42+
}
43+
3844
t := typeConfig.ValueString()
3945
code := int(countryCode.ValueInt64())
4046
addr := req.ConfigValue.ValueString()

0 commit comments

Comments
 (0)