From 06715a696ef8b7ff023899be0e627ed1978bdc70 Mon Sep 17 00:00:00 2001 From: Matt Morrison Date: Mon, 5 Sep 2016 14:25:44 +1200 Subject: [PATCH] =?UTF-8?q?Minor=20fixes:=20-=20extension=5Fheaders=20vali?= =?UTF-8?q?dation=20-=20header=20prefix=20must=20be=20=E2=80=98x-goog-?= =?UTF-8?q?=E2=80=98=20(with=20a=20trailing=20hyphen)=20-=20http=5Fmethod?= =?UTF-8?q?=20validate,=20explicitly=20name=20the=20datasource=20attribute?= =?UTF-8?q?=20that=20is=20failing=20validation=20-=20remove=20redundant=20?= =?UTF-8?q?http=5Fmethod=20validation=20that=20is=20no=20longer=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../google/data_source_storage_object_signed_url.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/providers/google/data_source_storage_object_signed_url.go b/builtin/providers/google/data_source_storage_object_signed_url.go index 6813bf950..10a03ff07 100644 --- a/builtin/providers/google/data_source_storage_object_signed_url.go +++ b/builtin/providers/google/data_source_storage_object_signed_url.go @@ -87,7 +87,7 @@ func dataSourceGoogleSignedUrl() *schema.Resource { func validateExtensionHeaders(v interface{}, k string) (ws []string, errors []error) { hdrMap := v.(map[string]interface{}) 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( "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 = strings.ToUpper(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 } @@ -111,10 +111,8 @@ func dataSourceGoogleSignedUrlRead(d *schema.ResourceData, meta interface{}) err urlData := &UrlData{} // 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) - } else { - return errors.New("not a valid http method") } // convert duration to an expiration datetime (unix time in seconds)