Skip to content

Commit 06715a6

Browse files
committed
Minor fixes:
- extension_headers validation - header prefix must be ‘x-goog-‘ (with a trailing hyphen) - http_method validate, explicitly name the datasource attribute that is failing validation - remove redundant http_method validation that is no longer needed
1 parent 5833198 commit 06715a6

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

builtin/providers/google/data_source_storage_object_signed_url.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func dataSourceGoogleSignedUrl() *schema.Resource {
8787
func validateExtensionHeaders(v interface{}, k string) (ws []string, errors []error) {
8888
hdrMap := v.(map[string]interface{})
8989
for k, _ := range hdrMap {
90-
if !strings.HasPrefix(strings.ToLower(k), "x-goog") {
90+
if !strings.HasPrefix(strings.ToLower(k), "x-goog-") {
9191
errors = append(errors, fmt.Errorf(
9292
"extension_header (%s) not valid, header name must begin with 'x-goog-'", k))
9393
}
@@ -99,7 +99,7 @@ func validateHttpMethod(v interface{}, k string) (ws []string, errs []error) {
9999
value := v.(string)
100100
value = strings.ToUpper(value)
101101
if !regexp.MustCompile(`^(GET|HEAD|PUT|DELETE)$`).MatchString(value) {
102-
errs = append(errs, errors.New("HTTP method must be one of [GET|HEAD|PUT|DELETE]"))
102+
errs = append(errs, errors.New("http_method must be one of [GET|HEAD|PUT|DELETE]"))
103103
}
104104
return
105105
}
@@ -111,10 +111,8 @@ func dataSourceGoogleSignedUrlRead(d *schema.ResourceData, meta interface{}) err
111111
urlData := &UrlData{}
112112

113113
// HTTP Method
114-
if method, ok := d.GetOk("http_method"); ok && len(method.(string)) >= 3 {
114+
if method, ok := d.GetOk("http_method"); ok {
115115
urlData.HttpMethod = method.(string)
116-
} else {
117-
return errors.New("not a valid http method")
118116
}
119117

120118
// convert duration to an expiration datetime (unix time in seconds)

0 commit comments

Comments
 (0)