Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/google: New Datasource: Google Storage Object Signed URL (supersedes #8180) #14643

Merged
merged 8 commits into from
May 24, 2017

Conversation

catsby
Copy link
Contributor

@catsby catsby commented May 18, 2017

I took #8180 and did the necessary rebase/merge. Thanks!

Matt Morrison and others added 7 commits September 16, 2016 12:44
- re-add ‘testAccPreCheck()’ to acceptance tests, to ensure necessary GOOGLE_* env vars are set for Acceptance tests.
- remove unused code from datasource
- use URL signature (base64 encoded) as data source ID instead of full URL
Implement content_md5, content_type, extension_headers support.
- 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
@catsby
Copy link
Contributor Author

catsby commented May 18, 2017

@danawillow / @paddycarver if you could take a quick look, I think this is pretty straightforward. I don't know the details of these presigned urls though, but the included docs makes the reading of new/additional creds seem legit. It was reviewed back in Sept. as well, so I think this is good

@paddycarver
Copy link
Contributor

I'll take a look at this today/tomorrow, @catsby. I just want to re-read it again, and it's a bit long. :)

@sl1pm4t
Copy link
Contributor

sl1pm4t commented May 18, 2017

Thanks @catsby - sorry I didn't circle back to this to rebase.

@catsby
Copy link
Contributor Author

catsby commented May 18, 2017

@sl1pm4t no worries! Thanks for all the work you did. The rebase / conflict was just the layout, easy fix 😄

Copy link
Contributor

@paddycarver paddycarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks, one case where I'd like to see error handling, and I have a procedural question I need to bring back to the team.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not crazy about using a regex to check if a string is one of four direct matches. Seems like a simple equality check would do here.
nit: not crazy about compiling the regexp on every run of the function, would rather use a global for that.

Neither of these should block merge.

return errwrap.Wrapf("could not parse duration: {{err}}", err)
}
expires := time.Now().Unix() + int64(duration.Seconds())
urlData.Expires = int(expires)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not crazy about float64 -> int64 -> int, but that feels like a problem for not-today, seeing as this can still represent unix times correctly for the next 20-ish years.

d.Get("bucket").(string),
d.Get("path").(string),
}
objectPath := strings.Join(path, "/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would rather do objectPath := "/"+strings.Join(path, "/") than rely on the empty-string-starts-the-array hack.

Shouldn't block merge.

// 2. `credentials` attribute in the provider definition.
// 3. A JSON file whose path is specified by the
// GOOGLE_APPLICATION_CREDENTIALS environment variable.
func loadJwtConfig(d *schema.ResourceData, meta interface{}) (*jwt.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eek. Another place where our credentials-loading algorithm is being defined. :( I don't see any way around this for the moment; we'll just have to clean up and sweep when credentials get an overhaul.

Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccTestGoogleStorageObjectSingedUrl(bucketName),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Singed -> Signed

// create HTTP request
url := a["signed_url"]
method := a["http_method"]
req, _ := http.NewRequest(method, url, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would really like to see this error handled.

Fix a typo, follow our acceptance test naming guidelines, simplify some
logic, and handle an unhandled error.
@paddycarver paddycarver merged commit c675b9e into master May 24, 2017
@paultyng paultyng deleted the pr-8180 branch June 25, 2019 16:25
@ghost
Copy link

ghost commented Jul 25, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants