Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into feat_cloud_cost_credentials-#218
  • Loading branch information
samuel-br committed Apr 6, 2022
2 parents 0ca0109 + 15db322 commit 31dc379
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 52 deletions.
13 changes: 7 additions & 6 deletions tests/integration/004_template/expected_outputs.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"tested2_template_type": "terraform",
"tested2_template_name": "tested1-",
"tested2_template_repository": "https://github.com/env0/templates",
"tested1_template_repository": "https://gitlab.com/env0/gitlab-vcs-integration-tests.git",
"tested2_template_path": "second",
"tg_tg_version" : "0.35.0"
"github_template_type": "terraform",
"github_template_name": "Github Test-",
"github_template_repository": "https://github.com/env0/templates",
"gitlab_template_repository": "https://gitlab.com/env0/gitlab-vcs-integration-tests.git",
"github_template_path": "second",
"tg_tg_version" : "0.35.0",
"data_github_template_type": "terraform"
}
68 changes: 22 additions & 46 deletions tests/integration/004_template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ data "env0_template" "gitlab_template" {
name = "Gitlab Integrated Template"
}

resource "env0_template" "tested1" {
name = "tested1-${random_string.random.result}"
description = "Tested 1 description"
resource "env0_template" "github_template" {
name = "Github Test-${random_string.random.result}"
description = "Template description - GitHub"
type = "terraform"
repository = data.env0_template.github_template.repository
github_installation_id = data.env0_template.github_template.github_installation_id
Expand All @@ -31,9 +31,9 @@ resource "env0_template" "tested1" {
terraform_version = "0.15.1"
}

resource "env0_template" "tested2" {
resource "env0_template" "gitlab_template" {
name = "GitLab Test-${random_string.random.result}"
description = "Tested 2 description - Gitlab"
description = "Template description - Gitlab"
type = "terraform"
repository = data.env0_template.gitlab_template.repository
token_id = data.env0_template.gitlab_template.token_id
Expand All @@ -57,62 +57,38 @@ resource "env0_template" "template_tg" {
resource "env0_configuration_variable" "in_a_template" {
name = "fake_key"
value = "fake value"
template_id = env0_template.tested1.id
template_id = env0_template.github_template.id
}

resource "env0_configuration_variable" "in_a_template2" {
name = "fake_key_2"
value = "fake value 2"
template_id = env0_template.tested1.id
template_id = env0_template.github_template.id
type = "terraform"
}

# Temporary - Sleep to avoid eventual consistency issues with the data sources
resource "time_sleep" "wait_for_all_templates" {
depends_on = [env0_template.tested1, env0_template.tested2, env0_template.template_tg]
triggers = {
# Only using depends_on doesn't work on re-apply. This makes sure the sleep happens on re-apply
second_run = var.second_run
}
create_duration = "5s"
output "github_template_id" {
value = env0_template.github_template.id
}

data "env0_template" "tested2" {
depends_on = [time_sleep.wait_for_all_templates]
name = "tested1-${random_string.random.result}"
}
data "env0_template" "tested1" {
depends_on = [time_sleep.wait_for_all_templates]
name = "GitLab Test-${random_string.random.result}"
output "github_template_type" {
value = env0_template.github_template.type
}
data "env0_template" "template_tg" {
depends_on = [time_sleep.wait_for_all_templates]
name = "Template for environment resource - tg-${random_string.random.result}"
}

output "tested2_template_id" {
value = data.env0_template.tested2.id
output "github_template_name" {
value = replace(env0_template.github_template.name, random_string.random.result, "")
}
output "tested2_template_type" {
value = data.env0_template.tested2.type
output "github_template_repository" {
value = env0_template.github_template.repository
}
output "tested2_template_name" {
value = replace(data.env0_template.tested2.name, random_string.random.result, "")
output "gitlab_template_repository" {
value = env0_template.gitlab_template.repository
}
output "tested2_template_repository" {
value = data.env0_template.tested2.repository
}
output "tested1_template_repository" {
value = data.env0_template.tested1.repository
}
output "tested2_template_path" {
value = data.env0_template.tested2.path
output "github_template_path" {
value = env0_template.github_template.path
}
output "tg_tg_version" {
value = data.env0_template.template_tg.terragrunt_version
value = env0_template.template_tg.terragrunt_version
}

data "env0_template" "tested3" {
id = env0_template.tested1.id
output "data_github_template_type" {
value = data.env0_template.github_template.type
}

0 comments on commit 31dc379

Please sign in to comment.