-
Notifications
You must be signed in to change notification settings - Fork 763
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
GH-144 - New Data Source: Github release #356
GH-144 - New Data Source: Github release #356
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a leading character here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
,latest
release_id
: ID of the release to retrieve. Must be specified whenretrieve_by
=id
release_tag
: Tag of the release to retrieve. Must be specified whenretrieve_by
=tag
I would like to say that this is my first real foray with Go, so any styling / syntax / best practice tips would be appreciated!