Skip to content

Commit

Permalink
fix: [CDS-73704]: use env vars for test (#642)
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@harness.io>
  • Loading branch information
mteodor committed Aug 8, 2023
1 parent b4631b0 commit ae45c3d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/resources/platform_gitops_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ resource "harness_platform_gitops_repository" "example" {
org_id = "org_id"
agent_id = "agent_id"
repo {
repo = "ghcr.io/wings-software"
repo = "ghcr.io/test-repo"
name = "repo_name"
insecure = false
username = "username"
Expand All @@ -72,7 +72,7 @@ resource "harness_platform_gitops_repository" "example" {
org_id = "org_id"
agent_id = "agent_id"
repo {
repo = "806630305776.dkr.ecr.us-west-1.amazonaws.com"
repo = "111222333444.dkr.ecr.us-west-1.amazonaws.com"
name = "repo_name"
insecure = false
username = "AWS"
Expand Down Expand Up @@ -100,7 +100,7 @@ resource "harness_platform_gitops_repository" "example" {
org_id = "org_id"
agent_id = "agent_id"
repo {
repo = "806630305776.dkr.ecr.us-west-1.amazonaws.com"
repo = "111222333444.dkr.ecr.us-west-1.amazonaws.com"
name = "repo_name"
insecure = false
username = "AWS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ resource "harness_platform_gitops_repository" "example" {
org_id = "org_id"
agent_id = "agent_id"
repo {
repo = "ghcr.io/wings-software"
repo = "ghcr.io/test-repo"
name = "repo_name"
insecure = false
username = "username"
Expand All @@ -57,7 +57,7 @@ resource "harness_platform_gitops_repository" "example" {
org_id = "org_id"
agent_id = "agent_id"
repo {
repo = "806630305776.dkr.ecr.us-west-1.amazonaws.com"
repo = "111222333444.dkr.ecr.us-west-1.amazonaws.com"
name = "repo_name"
insecure = false
username = "AWS"
Expand Down Expand Up @@ -85,7 +85,7 @@ resource "harness_platform_gitops_repository" "example" {
org_id = "org_id"
agent_id = "agent_id"
repo {
repo = "806630305776.dkr.ecr.us-west-1.amazonaws.com"
repo = "111222333444.dkr.ecr.us-west-1.amazonaws.com"
name = "repo_name"
insecure = false
username = "AWS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestHelmRepoOCIECR(t *testing.T) {
id := fmt.Sprintf("%s_%s", t.Name(), utils.RandStringBytes(5))
id = strings.ReplaceAll(id, "_", "")
name := id
repo := "806630305776.dkr.ecr.us-west-1.amazonaws.com"
repo := os.Getenv("HARNESS_TEST_ECR_REPO")
agentId := os.Getenv("HARNESS_TEST_GITOPS_AGENT_ID")
repoName := id
resourceName := "harness_platform_gitops_repository.test"
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestHelmRepoOCIECRJwt(t *testing.T) {
id := fmt.Sprintf("%s_%s", t.Name(), utils.RandStringBytes(5))
id = strings.ReplaceAll(id, "_", "")
name := id
repo := "806630305776.dkr.ecr.us-west-1.amazonaws.com"
repo := os.Getenv("HARNESS_TEST_ECR_REPO")
agentId := os.Getenv("HARNESS_TEST_GITOPS_AGENT_ID")
repoName := id
resourceName := "harness_platform_gitops_repository.test"
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestHelmRepoOCIGCRWorkload(t *testing.T) {
id := fmt.Sprintf("%s_%s", t.Name(), utils.RandStringBytes(5))
id = strings.ReplaceAll(id, "_", "")
name := id
repo := "us.gcr.io/qa-setup/harness-devops"
repo := os.Getenv("HARNESS_TEST_GITOPS_GCR_REPO")
agentId := os.Getenv("HARNESS_TEST_GITOPS_AGENT_ID")
repoName := id
resourceName := "harness_platform_gitops_repository.test"
Expand Down Expand Up @@ -265,8 +265,9 @@ func TestHelmRepoOCIGCRServiceAccount(t *testing.T) {
id := fmt.Sprintf("%s_%s", t.Name(), utils.RandStringBytes(5))
id = strings.ReplaceAll(id, "_", "")
name := id
repo := "us.gcr.io/qa-setup/harness-devops"
repo := os.Getenv("HARNESS_TEST_GITOPS_GCR_REPO")
agentId := os.Getenv("HARNESS_TEST_GITOPS_AGENT_ID")
gcrAccountKey := os.Getenv("HARNESS_TEST_GITOPS_GCR_ACCOUNT_KEY")
repoName := id
resourceName := "harness_platform_gitops_repository.test"
accountId := os.Getenv("HARNESS_ACCOUNT_ID")
Expand All @@ -277,7 +278,7 @@ func TestHelmRepoOCIGCRServiceAccount(t *testing.T) {
ProviderFactories: acctest.ProviderFactories,
Steps: []resource.TestStep{
{
Config: testHelmRepoOCIGCRServiceAccount(id, name, repo, repoName, agentId, accountId, awsAccessId, awsAccessKey),
Config: testHelmRepoOCIGCRServiceAccount(id, name, repo, repoName, agentId, accountId, gcrAccountKey, awsAccessId, awsAccessKey),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "id", id),
resource.TestCheckResourceAttr(resourceName, "identifier", id),
Expand Down Expand Up @@ -405,7 +406,7 @@ func testHelmRepoOCIGCRWorkload(id string, name string, repo string, repoName st
`, id, name, repo, repoName, agentId, accountId, awsAccessId, awsAccessKey)
}

func testHelmRepoOCIGCRServiceAccount(id string, name string, repo string, repoName string, agentId string, accountId string, awsAccessId, awsAccessKey string) string {
func testHelmRepoOCIGCRServiceAccount(id string, name string, repo string, repoName string, agentId string, accountId string, gcrAccountKey, awsAccessId, awsAccessKey string) string {
return fmt.Sprintf(`
resource "harness_platform_gitops_repository" "test" {
identifier = "%[1]s"
Expand All @@ -424,7 +425,7 @@ func testHelmRepoOCIGCRServiceAccount(id string, name string, repo string, repoN
gen_type = "GOOGLE_GCR"
gcr_gen {
project_id = "projectID"
access_key = "{ \"type\": \"service_account\", \"project_id\": \"gitops-play-338013\", \"private_key_id\": \"5ef370c719dd12674be7be090083caaabd85eca6\", \"private_key\": \"-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDQXwd7zfou3NDB\nP9TwgQMWyHYpWRJENC7RTpCaQ1KqBElEHPUBzPpv2L/ayn50qpsmtxYTWdQwR7OL\n8qK+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0Rk0W+h8AVpy/KzFbpBcQsX+VQLkri2wHu1pPonT+\nI9/yRsHWvzYMAFzEinOfmYGxl9BmbH1GRIGN/xOTn6+voilh4iO/qHocLwKBgCNy\n7pJFwmCBQME+GBSZ4DrrFYYjCIQ7CPunaoJwX9i5eFucXau650fFBOlMwnCiQ6j2\n+J2/elJQgtuvb/WSkwSJFyYskY5KgAcEtcfT/J5PYNarvWMqmFAS2n6Vjtu1Y2Bm\n8Mf6AJGTlsf6LFL6JjSrOH0PAUyjCkvyyfZTwg8BAoGBAOrOYrOC6zigjC5Kmve3\nORnw318hPOV5oo7a7NpztSwwY1/7xZuOJXLaflZXnYCO1BXY+PosshI1ckcrv6PT\niEr+SQ+mbaaxcFxtJUP6Y4GBI4ayeHnmgkfuVwPEd//rnPD6YA5RRFF/GRI619Hu\nAt9fAayERhb7ipMxMQw6wpbF\n-----END PRIVATE KEY-----\n\", \"client_email\": \"570436793911-compute@developer.gserviceaccount.com\", \"client_id\": \"114979827506890161940\", \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\", \"token_uri\": \"https://oauth2.googleapis.com/token\", \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\", \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/570436793911-compute@eveloper.gserviceaccount.com\", \"universe_domain\": \"googleapis.com\" }"
access_key = "%[7]s",
}
upsert = true
}
Expand All @@ -435,5 +436,5 @@ func testHelmRepoOCIGCRServiceAccount(id string, name string, repo string, repoN
account_id = "%[3]s"
agent_id = harness_platform_gitops_repository.test.agent_id
}
`, id, name, repo, repoName, agentId, accountId, awsAccessId, awsAccessKey)
`, id, name, repo, repoName, agentId, accountId, gcrAccountKey, awsAccessId, awsAccessKey)
}

0 comments on commit ae45c3d

Please sign in to comment.