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

resource/codebuild_project: support git_clone_depth #3467

Conversation

loivis
Copy link
Contributor

@loivis loivis commented Feb 21, 2018

Fix #3457

Also did little cleanup to drop custom validation functions.

The error below doesn't matter, I think?

⎇  echo > aws/debug.log ; and make testacc TEST=./aws TESTARGS='-run=TestAccAWSCodeBuildProject_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCodeBuildProject_ -timeout 120m
=== RUN   TestAccAWSCodeBuildProject_basic
--- PASS: TestAccAWSCodeBuildProject_basic (56.12s)
=== RUN   TestAccAWSCodeBuildProject_sourceAuth
--- FAIL: TestAccAWSCodeBuildProject_sourceAuth (18.01s)
	testing.go:513: Step 1 error: Error applying: 1 error(s) occurred:

		* aws_codebuild_project.foo: 1 error(s) occurred:

		* aws_codebuild_project.foo: [ERROR] Error creating CodeBuild project: InvalidInputException: No Access token found, please visit AWS CodeBuild console to connect to GitHub
			status code: 400, request id: 9f26ba07-169a-11e8-b903-894ab4f5539f
	testing.go:573: Error destroying resource! WARNING: Dangling resources
		may exist. The full state and error is shown below.

		Error: Check failed: Default error in CodeBuild Test

		State: <no state>
=== RUN   TestAccAWSCodeBuildProject_default_build_timeout
--- PASS: TestAccAWSCodeBuildProject_default_build_timeout (58.74s)
FAIL
exit status 1
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	132.912s
make: *** [testacc] Error 1

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Feb 21, 2018
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/codebuild Issues and PRs that pertain to the codebuild service. labels Feb 21, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 97b371d to 4d3f92e Compare March 15, 2018 16:16
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Mar 15, 2018
@loivis
Copy link
Contributor Author

loivis commented Mar 15, 2018

resolve conflicts.

@bflad
Copy link
Contributor

bflad commented Mar 16, 2018

@loivis sorry your ValidateFunc replacement PR made this one unhappy. 🙁 Do you mind sync'ing this up again or let me know if you don't have time? Should be a lot smaller. 😄

@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 4d3f92e to 8da7532 Compare March 16, 2018 20:31
@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 8da7532 to 0345474 Compare March 16, 2018 20:32
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 0345474 to 50b0c25 Compare March 16, 2018 20:34
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 50b0c25 to 39648e0 Compare March 16, 2018 20:35
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 39648e0 to 8029423 Compare March 16, 2018 20:36
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 8029423 to 3f962de Compare March 16, 2018 20:42
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 3f962de to 3132fcb Compare March 16, 2018 20:49
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 3132fcb to 53bddf6 Compare March 16, 2018 20:58
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 53bddf6 to 58fbe6c Compare March 16, 2018 21:02
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from 58fbe6c to de61ddf Compare March 16, 2018 21:04
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis loivis force-pushed the 3457-codebuild-project-support-git-clone-depth branch from de61ddf to 191f3fb Compare March 16, 2018 21:07
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 16, 2018
@loivis
Copy link
Contributor Author

loivis commented Mar 16, 2018

should be ok now.

⎇  make fmt; and echo > aws/debug.log ; and make testacc TEST=./aws TESTARGS='-run=TestAccAWSCodeBuildProject_'
gofmt -w $(find . -name '*.go' |grep -v vendor)
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCodeBuildProject_ -timeout 120m
=== RUN   TestAccAWSCodeBuildProject_basic
--- PASS: TestAccAWSCodeBuildProject_basic (41.23s)
=== RUN   TestAccAWSCodeBuildProject_vpc
--- PASS: TestAccAWSCodeBuildProject_vpc (71.79s)
=== RUN   TestAccAWSCodeBuildProject_sourceAuth
--- FAIL: TestAccAWSCodeBuildProject_sourceAuth (15.09s)
	testing.go:518: Step 1 error: Error applying: 1 error(s) occurred:

		* aws_codebuild_project.foo: 1 error(s) occurred:

		* aws_codebuild_project.foo: [ERROR] Error creating CodeBuild project: InvalidInputException: No Access token found, please visit AWS CodeBuild console to connect to GitHub
			status code: 400, request id: ab4541cd-295d-11e8-b403-6b748104e4b1
	testing.go:579: Error destroying resource! WARNING: Dangling resources
		may exist. The full state and error is shown below.

		Error: Check failed: Default error in CodeBuild Test

		State: <no state>
=== RUN   TestAccAWSCodeBuildProject_default_build_timeout
--- PASS: TestAccAWSCodeBuildProject_default_build_timeout (57.71s)
FAIL
exit status 1
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	185.866s
make: *** [testacc] Error 1

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.

Left an initial review below, please let me know if you have any questions. 😄

@@ -619,6 +625,10 @@ func flattenAwsCodeBuildProjectSource(source *codebuild.ProjectSource) []interfa
m["buildspec"] = *source.Buildspec
}

if source.GitCloneDepth != nil {
m["git_clone_depth"] = *source.GitCloneDepth
Copy link
Contributor

Choose a reason for hiding this comment

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

Two things:

  • If the source.GitCloneDepth value is always returned, this will change the TypeSet hash when folks upgrade their AWS provider and it will show a diff. We'll need to implement a state migration if that's the case to prevent the diff.
  • We should convert this from int64 to int to match the Terraform schema: int(aws.Int64Value(source.GitCloneDepth))

@@ -683,6 +693,9 @@ func resourceAwsCodeBuildProjectSourceHash(v interface{}) int {
if v, ok := m["buildspec"]; ok {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}
if v, ok := m["git_clone_depth"]; ok {
buf.WriteString(fmt.Sprintf("%d-", v.(int)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar note here, if git_clone_depth defaults to 0, this will change the TypeSet hash when folks upgrade their AWS provider and it will show a diff. We'll need to implement a state migration if that's the case to prevent the diff.

@@ -403,6 +403,7 @@ resource "aws_codebuild_project" "foo" {
source {
type = "GITHUB"
location = "https://github.com/hashicorp/packer.git"
git_clone_depth = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably move this to its own test and ensure it can be updated 👍

@bflad
Copy link
Contributor

bflad commented Mar 19, 2018

FYI I think you can get rid of this Error creating CodeBuild project: InvalidInputException: No Access token found, please visit AWS CodeBuild console to connect to GitHub by creating a Github OAuth token (it only needs public read permissions) and setting it in your environment: export GITHUB_TOKEN=...

@bflad
Copy link
Contributor

bflad commented Mar 27, 2018

Semi-duplicate PR behind this one: #3929

@loivis do you have any questions or need any help implementing this? If Git clone depth is always returned I think the best route forward here is going to be performing a state migration of source from TypeSet to TypeList so we do not need to worry anymore about the hashing and unexpected diffs when adding this or other new attributes.

@loivis
Copy link
Contributor Author

loivis commented Mar 27, 2018

Sorry for days of silence. I didn't really have time to check. I'm happy to see it's included in #3929. We can close this PR if #3929 goes well.

@kwent
Copy link
Contributor

kwent commented Mar 30, 2018

Looking forward to this !

@loivis
Copy link
Contributor Author

loivis commented Apr 5, 2018

close in favor of #3929

@loivis loivis closed this Apr 5, 2018
@loivis loivis deleted the 3457-codebuild-project-support-git-clone-depth branch March 14, 2020 15:47
@ghost
Copy link

ghost commented Mar 15, 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 Mar 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/codebuild Issues and PRs that pertain to the codebuild service. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gitCloneDepth to aws_codebuild_project
3 participants