Skip to content

Commit

Permalink
Allow people to override the sourceURL in the basic config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Stump committed May 7, 2018
1 parent 22e8140 commit 9abbc82
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions aws/resource_aws_codebuild_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aws

import (
"fmt"
"os"
"regexp"
"strings"
"testing"
Expand Down Expand Up @@ -290,6 +291,18 @@ func testAccCheckAWSCodeBuildProjectDestroy(s *terraform.State) error {
}

func testAccAWSCodeBuildProjectConfig_basic(rName, vpcConfig, vpcResources string) string {
// This is used for testing aws_codebuild_webhook as well as aws_codebuild_project.
// In order for that resource to work the Terraform AWS user must have done a GitHub
// OAuth dance.
//
// Additionally, the GitHub user that the Terraform AWS user logs in as must have
// access to the GitHub repository. This allows others to run tests for the webhook
// without having to have access to the Packer GitHub repository.
sourceURL, ok := os.LookupEnv("CODEBUILD_GITHUB_SOURCE_URL")
if !ok {
sourceURL = "https://github.com/hashicorp/packer.git"
}

return fmt.Sprintf(`
resource "aws_iam_role" "codebuild_role" {
name = "codebuild-role-%s"
Expand Down Expand Up @@ -375,7 +388,7 @@ resource "aws_codebuild_project" "foo" {
source {
type = "GITHUB"
location = "https://github.com/hashicorp/packer.git"
location = "%s"
}
tags {
Expand All @@ -384,7 +397,7 @@ resource "aws_codebuild_project" "foo" {
%s
}
%s
`, rName, rName, rName, rName, vpcConfig, vpcResources)
`, rName, rName, rName, rName, sourceURL, vpcConfig, vpcResources)
}

func testAccAWSCodeBuildProjectConfig_basicUpdated(rName string) string {
Expand Down

0 comments on commit 9abbc82

Please sign in to comment.