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

Unmarshal link members; Add Upload() for registry module version slugs #221

Merged
merged 2 commits into from
May 18, 2021

Conversation

chrisarcand
Copy link
Member

Description

With hashicorp/jsonapi#10, we're now able to do something often-requested for this client: Fetch upload URLs for policy sets and registry modules (which differ from configuration versions in that they provide upload links in the links member of a response, not a standard attribute).

Here I've included registry module uploads; policy set versions can be handled separately.

Closes #159

Output from tests

» go test -v ./... -timeout=30m -run TestRegistryModulesUpload
=== RUN   TestRegistryModulesUpload
=== RUN   TestRegistryModulesUpload/with_valid_upload_URL
=== RUN   TestRegistryModulesUpload/with_missing_upload_URL
--- PASS: TestRegistryModulesUpload (1.84s)
    --- PASS: TestRegistryModulesUpload/with_valid_upload_URL (0.11s)
    --- PASS: TestRegistryModulesUpload/with_missing_upload_URL (0.00s)
PASS
ok      github.com/hashicorp/go-tfe     2.634s
...

Includes support for unmarshaling link members
Similar to configuration versions, with the slight modification that I
don't believe client users should care about piping the correct upload
link to Upload(), or it's little more than syntatic sugar for a simple
PUT request.

With this, just provide a newly created RMV to Upload() with a path to
your module files and away you go.
@chrisarcand chrisarcand added the enhancement New feature or request label May 18, 2021
@chrisarcand chrisarcand marked this pull request as ready for review May 18, 2021 05:20
@chrisarcand chrisarcand requested a review from a team May 18, 2021 05:20
Copy link
Member

@radditude radditude left a comment

Choose a reason for hiding this comment

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

Looks good! I'm curious if we want to leave the default .terraformignore behavior of go-slug enabled, though.


body := bytes.NewBuffer(nil)

_, err = slug.Pack(path, body, true)
Copy link
Member

@radditude radditude May 18, 2021

Choose a reason for hiding this comment

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

I think slug.Pack here will respect the settings in a .terraformignore file if the user has one, which seems like it could possibly lead to this having confusing behavior if that's something the user wasn't expecting.

On the other hand, since this is a Terraform module, maybe that's actually the more intuitive behavior! Either way, I wanted to call it out in case it's something you hadn't considered.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh good call out! No, I hadn't thought of that at all.

I'm not sure if it should respect the ignore file or not (my gut reaction is 'it should' but honestly I dunno), but regardless in the name of consistency I'll leave it as is - this is identical to how configuration versions currently work.

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense!

@chrisarcand chrisarcand merged commit 0f08d6b into master May 18, 2021
@chrisarcand chrisarcand deleted the unmarshal-links-part-deux branch May 18, 2021 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I am unable to get the upload link when creating a TF Module version
2 participants