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

Issue #4785: New Datasource aws_codecommit_repository #4934

Merged
merged 4 commits into from
Jun 22, 2018

Conversation

saravanan30erd
Copy link
Contributor

Fixes #4785

Output from acceptance testing:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSCodeCommitRepositoryDataSource_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAWSCodeCommitRepositoryDataSource_basic -timeout 120m
=== RUN   TestAccAWSCodeCommitRepositoryDataSource_basic
--- PASS: TestAccAWSCodeCommitRepositoryDataSource_basic (49.71s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	49.751s
...

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jun 21, 2018
@bflad bflad added new-data-source Introduces a new data source. service/codecommit Issues and PRs that pertain to the codecommit service. labels Jun 21, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

This is off to a great start per usual @saravanan30erd! A few things below and we should be able to get this in shortly!

FYI we are hanging out in https://gitter.im/hashicorp-terraform/gardening/ today for the gardening event if you'd like to chat in realtime

if isAWSErr(err, codecommit.ErrCodeRepositoryDoesNotExistException, "") {
log.Printf("[WARN] CodeCommit Repository (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently, data sources should return a direct error instead of silently failing returning no results and likely returning a resource data.XXX.XXX not found for error later on. 😄

return fmt.Errorf("Error reading CodeCommit Repository: %s", err.Error())
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent potential panics, we should perform a nil check for out.RepositoryMetadata before referencing it below.

Config: testAccCheckAwsCodeCommitRepositoryDataSourceConfig(rName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_codecommit_repository.default", "repository_name", rName),
resource.TestMatchResourceAttr("data.aws_codecommit_repository.default", "arn",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we switch these to use resource.TestCheckResourceAttrPair() where possible? This helps us ensure that the data source definitely matched the correct resource. Thanks! 👍

website/aws.erb Outdated
@@ -103,6 +103,9 @@
<li<%= sidebar_current("docs-aws-datasource-cloudwatch-log-group") %>>
<a href="/docs/providers/aws/d/cloudwatch_log_group.html">aws_cloudwatch_log_group</a>
</li>
<li<%= sidebar_current("docs-aws-datasource-codecommit-repository") %>>
<a href="/docs/providers/aws/d/codecommit_repository.html">aws_cloudwatch_log_group</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Copypasta typo 🍝 here 😉

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jun 21, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Jun 21, 2018
@saravanan30erd
Copy link
Contributor Author

@bflad Done all the changes.

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSCodeCommitRepositoryDataSource_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAWSCodeCommitRepositoryDataSource_basic -timeout 120m
=== RUN TestAccAWSCodeCommitRepositoryDataSource_basic
--- PASS: TestAccAWSCodeCommitRepositoryDataSource_basic (46.63s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 46.684s

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Jun 22, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks great, @saravanan30erd! Thanks! 🚀

1 test passed (all tests)
=== RUN   TestAccAWSCodeCommitRepositoryDataSource_basic
--- PASS: TestAccAWSCodeCommitRepositoryDataSource_basic (8.56s)

Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair("data.aws_codecommit_repository.default", "repository_name",
"aws_codecommit_repository.default", "repository_name"),
resource.TestMatchResourceAttr("data.aws_codecommit_repository.default", "arn",
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick: I will update the rest of the checks to resource.TestCheckResourceAttrPair() post merge.

@bflad bflad merged commit 00ba359 into hashicorp:master Jun 22, 2018
@bflad bflad added this to the v1.25.0 milestone Jun 22, 2018
bflad added a commit that referenced this pull request Jun 22, 2018
@bflad
Copy link
Contributor

bflad commented Jun 27, 2018

This has been released in version 1.25.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 5, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-data-source Introduces a new data source. service/codecommit Issues and PRs that pertain to the codecommit service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New datasouce: aws_codecommit_repository
2 participants