GH-144 - New Data Source: Github release#356
GH-144 - New Data Source: Github release#356jcudit merged 10 commits intointegrations:masterfrom crederauk:gh-144-releases-data-source
Conversation
jcudit
left a comment
There was a problem hiding this comment.
This is looking good and is nearing the finish line. See my comment inline around fixes to TestAccGithubReleaseDataSource_fetchByTagExisting.
| resource.TestMatchResourceAttr("data.github_release.test", "url", regexp.MustCompile(`hashicorp/terraform`)), | ||
| resource.TestMatchResourceAttr("data.github_release.test", "tarball_url", regexp.MustCompile(`hashicorp/terraform/tarball`)), |
There was a problem hiding this comment.
nit: to keep this within some margins, I would extract the third arguments here into their own variables above
There was a problem hiding this comment.
Good shout, will update this.
| Steps: []resource.TestStep{ | ||
| { | ||
| Config: testAccCheckGithubReleaseDataSourceConfig("", "", retrieveBy, "", 0), | ||
| ExpectError: regexp.MustCompile("release_id` must be set when `retrieve_by` = `id`"), |
There was a problem hiding this comment.
Missing a leading character here.
There was a problem hiding this comment.
Good catch! I'll add that in
| func TestAccGithubReleaseDataSource_fetchByTagExisting(t *testing.T) { | ||
| repo := "terraform" | ||
| owner := "hashicorp" | ||
| retrieveBy := "tag" | ||
| tag := "v0.12.20" | ||
| resource.ParallelTest(t, resource.TestCase{ | ||
| PreCheck: func() { | ||
| testAccPreCheck(t) | ||
| }, | ||
| Providers: testAccProviders, | ||
| Steps: []resource.TestStep{ | ||
| { | ||
| Config: testAccCheckGithubReleaseDataSourceConfig(repo, owner, retrieveBy, tag, 0), | ||
| Check: resource.ComposeTestCheckFunc( | ||
| resource.TestCheckResourceAttr("data.github_release.test", "release_tag", tag), | ||
| resource.TestMatchResourceAttr("data.github_release.test", "url", regexp.MustCompile(`hashicorp/terraform`)), | ||
| resource.TestMatchResourceAttr("data.github_release.test", "tarball_url", regexp.MustCompile(`hashicorp/terraform/tarball`)), | ||
| ), | ||
| }, | ||
| }, | ||
| }) | ||
| } |
There was a problem hiding this comment.
The convention within this repository I've observed so far has been to not hard-code values such as the repository and tag as was done in this test. I think this test is stable but would like to see an attempt to obtain these values from the environment before proceeding with the hard-coded defaults. See here for prior art.
There was a problem hiding this comment.
Thanks for referring to this. I was unsure how to proceed since we don't have an associated resource to create / delete a release. Have a look at my changes - adding another environment variable with the tag and sourcing it from the template repo.
In future, if added, I think it would be good to manage this release test object via a release resource as well, making it fully isolated.
|
Tests are passing: |
|
Thanks for the review @jcudit! I have pushed up some changes that I think address your concerns and have replied inline to each comment. Can I request a re-review please? |
|
Sorry! Realised the tests wouldn't work in that state so have pushed ^^. That's what I get for not running the tests before a push... |
jcudit
left a comment
There was a problem hiding this comment.
This looks great!
My next steps are to run this through a final pass of our acceptance tests. If all is good, I think this is safe to merge.
…releases-data-source integrationsGH-144 - New Data Source: Github release
|
How can I access the assets? |
This PR covers functionality described in GH-144.
The following functionality has been provided by this new data source:
Things not covered by this data source:
The following constraints apply to this data source:
Required properties:
repository: Name of the repository to retrieve the release fromowner: Owner of the repository (can be org / user)retrieve_by: Describes how to fetch the release. Valid values areid,tag,latestrelease_id: ID of the release to retrieve. Must be specified whenretrieve_by=idrelease_tag: Tag of the release to retrieve. Must be specified whenretrieve_by=tagI would like to say that this is my first real foray with Go, so any styling / syntax / best practice tips would be appreciated!