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
This commit is contained in:
parent
5833198d73
commit
06715a696e
|
@ -87,7 +87,7 @@ func dataSourceGoogleSignedUrl() *schema.Resource {
|
||||||
func validateExtensionHeaders(v interface{}, k string) (ws []string, errors []error) {
|
func validateExtensionHeaders(v interface{}, k string) (ws []string, errors []error) {
|
||||||
hdrMap := v.(map[string]interface{})
|
hdrMap := v.(map[string]interface{})
|
||||||
for k, _ := range hdrMap {
|
for k, _ := range hdrMap {
|
||||||
if !strings.HasPrefix(strings.ToLower(k), "x-goog") {
|
if !strings.HasPrefix(strings.ToLower(k), "x-goog-") {
|
||||||
errors = append(errors, fmt.Errorf(
|
errors = append(errors, fmt.Errorf(
|
||||||
"extension_header (%s) not valid, header name must begin with 'x-goog-'", k))
|
"extension_header (%s) not valid, header name must begin with 'x-goog-'", k))
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ func validateHttpMethod(v interface{}, k string) (ws []string, errs []error) {
|
||||||
value := v.(string)
|
value := v.(string)
|
||||||
value = strings.ToUpper(value)
|
value = strings.ToUpper(value)
|
||||||
if !regexp.MustCompile(`^(GET|HEAD|PUT|DELETE)$`).MatchString(value) {
|
if !regexp.MustCompile(`^(GET|HEAD|PUT|DELETE)$`).MatchString(value) {
|
||||||
errs = append(errs, errors.New("HTTP method must be one of [GET|HEAD|PUT|DELETE]"))
|
errs = append(errs, errors.New("http_method must be one of [GET|HEAD|PUT|DELETE]"))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,8 @@ func dataSourceGoogleSignedUrlRead(d *schema.ResourceData, meta interface{}) err
|
||||||
urlData := &UrlData{}
|
urlData := &UrlData{}
|
||||||
|
|
||||||
// HTTP Method
|
// HTTP Method
|
||||||
if method, ok := d.GetOk("http_method"); ok && len(method.(string)) >= 3 {
|
if method, ok := d.GetOk("http_method"); ok {
|
||||||
urlData.HttpMethod = method.(string)
|
urlData.HttpMethod = method.(string)
|
||||||
} else {
|
|
||||||
return errors.New("not a valid http method")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert duration to an expiration datetime (unix time in seconds)
|
// convert duration to an expiration datetime (unix time in seconds)
|
||||||
|
|
Loading…
Reference in New Issue