From ab5847e984ec38458b83fad507d54413bb1a52a4 Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:58:06 -0400 Subject: [PATCH 1/7] Mention OpenTofu; clean up repo. --- README.md | 41 ++++----- .../.modules}/account_token/main.tf | 0 .../.modules}/account_token/provider.tf | 0 .../.modules}/account_token/vars.tf | 0 .../.modules}/account_tokens/main.tf | 0 .../.modules}/account_tokens/provider.tf | 0 .../.modules}/account_tokens/vars.tf | 0 .../.modules}/accounts_users/main.tf | 0 .../.modules}/accounts_users/output.tf | 0 .../.modules}/accounts_users/provider.tf | 0 .../.modules}/accounts_users/vars.tf | 0 .../.modules}/teams/main.tf | 0 .../.modules}/teams/output.tf | 0 .../.modules}/teams/vars.tf | 0 examples/abac_rules/main.tf | 6 +- examples/abac_rules/provider.tf | 6 +- examples/abac_rules/terraform.tfvars | 4 +- examples/abac_rules/vars.tf | 8 +- examples/abac_rules/versions.tf | 2 +- examples/account_tokens/main.tf | 16 ++-- examples/account_tokens/terraform.tfvars | 2 +- examples/account_tokens/versions.tf | 2 +- examples/account_user_associations/main.tf | 6 +- .../account_user_associations/versions.tf | 2 +- examples/accounts_users/main.tf | 8 +- examples/accounts_users/terraform.tfvars | 84 +++++++++--------- examples/accounts_users/vars.tf | 20 ++--- examples/accounts_users/versions.tf | 2 +- examples/permissions/provider.tf | 4 +- examples/permissions/vars.tf | 6 +- examples/permissions/versions.tf | 2 +- examples/pipelines.md | 86 ------------------- examples/pipelines/main.tf | 24 +++--- examples/pipelines/terraform.tfvars | 2 +- examples/pipelines/vars.tf | 6 +- examples/pipelines/versions.tf | 2 +- examples/registries/main.tf | 20 ++--- examples/registries/terraform.tfvars | 2 +- examples/registries/versions.tf | 2 +- .../main.tf | 14 +-- .../provider.tf | 4 +- examples/storage_integration/vars.tf | 8 ++ .../versions.tf | 2 +- examples/storate_integration/vars.tf | 8 -- examples/teams/main.tf | 14 +-- examples/teams/terraform.tfvars | 4 +- examples/teams/versions.tf | 2 +- examples/triggers/versions.tf | 2 +- scripts/gofmtcheck.sh | 13 --- scripts/gogetcookie.sh | 10 --- 50 files changed, 166 insertions(+), 280 deletions(-) rename {tf_modules => examples/.modules}/account_token/main.tf (100%) rename {tf_modules => examples/.modules}/account_token/provider.tf (100%) rename {tf_modules => examples/.modules}/account_token/vars.tf (100%) rename {tf_modules => examples/.modules}/account_tokens/main.tf (100%) rename {tf_modules => examples/.modules}/account_tokens/provider.tf (100%) rename {tf_modules => examples/.modules}/account_tokens/vars.tf (100%) rename {tf_modules => examples/.modules}/accounts_users/main.tf (100%) rename {tf_modules => examples/.modules}/accounts_users/output.tf (100%) rename {tf_modules => examples/.modules}/accounts_users/provider.tf (100%) rename {tf_modules => examples/.modules}/accounts_users/vars.tf (100%) rename {tf_modules => examples/.modules}/teams/main.tf (100%) rename {tf_modules => examples/.modules}/teams/output.tf (100%) rename {tf_modules => examples/.modules}/teams/vars.tf (100%) delete mode 100644 examples/pipelines.md rename examples/{storate_integration => storage_integration}/main.tf (77%) rename examples/{storate_integration => storage_integration}/provider.tf (56%) create mode 100644 examples/storage_integration/vars.tf rename examples/{storate_integration => storage_integration}/versions.tf (58%) delete mode 100644 examples/storate_integration/vars.tf delete mode 100755 scripts/gofmtcheck.sh delete mode 100755 scripts/gogetcookie.sh diff --git a/README.md b/README.md index 7a368c72..45ebe14b 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,12 @@ # Terraform Provider for Codefresh -This is the official Terraform Provider for Codefresh. +The official Terraform and OpenTofu Provider for [Codefresh](https://codefresh.io/). Terraform Registry: [registry.terraform.io/providers/codefresh-io/codefresh](https://registry.terraform.io/providers/codefresh-io/codefresh/latest) ## Requirements -- [Terraform](https://www.terraform.io/downloads.html) `1.x.x` - -## Download the Provider - -Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases) +- [Terraform](https://www.terraform.io/downloads.html) `1.x.x` or [OpenTofu](https://github.com/opentofu/opentofu/releases/latest) `1.x.x`. ## Using the Provider @@ -21,12 +17,14 @@ terraform { required_providers { codefresh = { version = "x.y.z" # Optional but recommended; replace with latest semantic version - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" # registry.terraform.io/ is optional for Terraform users, but required for OpenTofu users } } } ``` +You can also download and extract the provider binary (`terraform-provider-codefresh`) from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases). + ## Building the Provider Locally ```sh @@ -39,24 +37,13 @@ The documentation is generated using [tfplugindocs](https://github.com/hashicorp See: [CONTRIBUTING.md](./CONTRIBUTING.md#documentation) -## To configure Codefresh provider: +## Provider Configuration: -```hcl -provider "codefresh" { - api_url = "" # Default value - https://g.codefresh.io/api - token = "" # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable -} -``` +See the [Provider Documentation](https://registry.terraform.io/providers/codefresh-io/codefresh/latest/docs#schema). -Get an API key from [Codefresh](https://g.codefresh.io/user/settings) and set the following scopes: +The provider requires a Codefresh API in order to authenticate to the Codefresh API. Generate the API key [here](https://g.codefresh.io/user/settings) and set the scopes [according to the resources you wish to create](https://codefresh.io/docs/docs/integrations/codefresh-api/#access-scopes). Note that some resource require platform admin permissions and hence can only be created for on-prem installations and not our SaaS offering. -- Environments-V2 -- Pipeline -- Project -- Repos -- Step-Type -- Step-Types -- View +The key can be set as an environment variable: ```bash export CODEFRESH_API_KEY='xyz' @@ -64,12 +51,20 @@ export CODEFRESH_API_KEY='xyz' ## Testing the Provider -**NOTE:** Acceptance tests create real resources, including admin resources (accounts, users) so make sure that `CODEFRESH_API_KEY` is set to an account that you are ok with being modified. +**NOTE:** Acceptance tests create real resources, including admin resources (accounts, users) so make sure that `CODEFRESH_API_KEY` is set to a Codefresh installation and an account that you are ok with being modified. ```bash make testacc ``` +## OpenTofu Support + +This provider supports [OpenTofu](https://opentofu.org/). + +[Equivalence Testing](https://github.com/opentofu/equivalence-testing) is performed on the `examples/` directory in order to ensure that the provider behaves identically when used by either `terraform` and `tofu` binaries. + +The [OpenTofu Registry](https://registry.opentofu.org/) seems to be unpublished at time of writing. As of now, the provider is only published to the [Terraform Registry](https://registry.terraform.io/providers/codefresh-io/codefresh/latest). + ## Contributors diff --git a/tf_modules/account_token/main.tf b/examples/.modules/account_token/main.tf similarity index 100% rename from tf_modules/account_token/main.tf rename to examples/.modules/account_token/main.tf diff --git a/tf_modules/account_token/provider.tf b/examples/.modules/account_token/provider.tf similarity index 100% rename from tf_modules/account_token/provider.tf rename to examples/.modules/account_token/provider.tf diff --git a/tf_modules/account_token/vars.tf b/examples/.modules/account_token/vars.tf similarity index 100% rename from tf_modules/account_token/vars.tf rename to examples/.modules/account_token/vars.tf diff --git a/tf_modules/account_tokens/main.tf b/examples/.modules/account_tokens/main.tf similarity index 100% rename from tf_modules/account_tokens/main.tf rename to examples/.modules/account_tokens/main.tf diff --git a/tf_modules/account_tokens/provider.tf b/examples/.modules/account_tokens/provider.tf similarity index 100% rename from tf_modules/account_tokens/provider.tf rename to examples/.modules/account_tokens/provider.tf diff --git a/tf_modules/account_tokens/vars.tf b/examples/.modules/account_tokens/vars.tf similarity index 100% rename from tf_modules/account_tokens/vars.tf rename to examples/.modules/account_tokens/vars.tf diff --git a/tf_modules/accounts_users/main.tf b/examples/.modules/accounts_users/main.tf similarity index 100% rename from tf_modules/accounts_users/main.tf rename to examples/.modules/accounts_users/main.tf diff --git a/tf_modules/accounts_users/output.tf b/examples/.modules/accounts_users/output.tf similarity index 100% rename from tf_modules/accounts_users/output.tf rename to examples/.modules/accounts_users/output.tf diff --git a/tf_modules/accounts_users/provider.tf b/examples/.modules/accounts_users/provider.tf similarity index 100% rename from tf_modules/accounts_users/provider.tf rename to examples/.modules/accounts_users/provider.tf diff --git a/tf_modules/accounts_users/vars.tf b/examples/.modules/accounts_users/vars.tf similarity index 100% rename from tf_modules/accounts_users/vars.tf rename to examples/.modules/accounts_users/vars.tf diff --git a/tf_modules/teams/main.tf b/examples/.modules/teams/main.tf similarity index 100% rename from tf_modules/teams/main.tf rename to examples/.modules/teams/main.tf diff --git a/tf_modules/teams/output.tf b/examples/.modules/teams/output.tf similarity index 100% rename from tf_modules/teams/output.tf rename to examples/.modules/teams/output.tf diff --git a/tf_modules/teams/vars.tf b/examples/.modules/teams/vars.tf similarity index 100% rename from tf_modules/teams/vars.tf rename to examples/.modules/teams/vars.tf diff --git a/examples/abac_rules/main.tf b/examples/abac_rules/main.tf index f60c53b4..b33f599a 100644 --- a/examples/abac_rules/main.tf +++ b/examples/abac_rules/main.tf @@ -12,10 +12,10 @@ resource "codefresh_abac_rules" "app_rule" { actions = ["REFRESH", "SYNC", "TERMINATE_SYNC", "VIEW_POD_LOGS", "APP_ROLLBACK"] attribute { - name = "LABEL" - key = "KEY" + name = "LABEL" + key = "KEY" value = "VALUE" } - tags = ["dev", "untagged"] + tags = ["dev", "untagged"] } diff --git a/examples/abac_rules/provider.tf b/examples/abac_rules/provider.tf index 79fc432c..411f4965 100644 --- a/examples/abac_rules/provider.tf +++ b/examples/abac_rules/provider.tf @@ -1,5 +1,5 @@ provider "codefresh" { - api_url = var.api_url - api_url_v2 = var.api_url_v2 - token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable + api_url = var.api_url + api_url_v2 = var.api_url_v2 + token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable } \ No newline at end of file diff --git a/examples/abac_rules/terraform.tfvars b/examples/abac_rules/terraform.tfvars index 2999903e..d63ad4a7 100644 --- a/examples/abac_rules/terraform.tfvars +++ b/examples/abac_rules/terraform.tfvars @@ -1,3 +1,3 @@ -api_url = "https://my-codefresh.example.com/api" +api_url = "https://my-codefresh.example.com/api" api_url_v2 = "https://my-codefresh.example.com/2.0/api/graphql" -token = "" +token = "" diff --git a/examples/abac_rules/vars.tf b/examples/abac_rules/vars.tf index 578727c4..778f3aed 100644 --- a/examples/abac_rules/vars.tf +++ b/examples/abac_rules/vars.tf @@ -1,12 +1,12 @@ -variable api_url { +variable "api_url" { type = string } -variable api_url_v2 { +variable "api_url_v2" { type = string } -variable token { - type = string +variable "token" { + type = string default = "" } \ No newline at end of file diff --git a/examples/abac_rules/versions.tf b/examples/abac_rules/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/abac_rules/versions.tf +++ b/examples/abac_rules/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/account_tokens/main.tf b/examples/account_tokens/main.tf index 4fe05a59..a65de1aa 100644 --- a/examples/account_tokens/main.tf +++ b/examples/account_tokens/main.tf @@ -1,24 +1,24 @@ -variable api_url { +variable "api_url" { type = string } # -variable token { - type = string +variable "token" { + type = string default = "" } ## Set of account names -variable accounts { +variable "accounts" { type = set(string) } module "account_tokens" { - source = "../../tf_modules/account_tokens" - api_url = var.api_url - accounts = var.accounts + source = "../.modules/account_tokens" + api_url = var.api_url + accounts = var.accounts } output "account_tokens" { - value = module.account_tokens.tokens + value = module.account_tokens.tokens } \ No newline at end of file diff --git a/examples/account_tokens/terraform.tfvars b/examples/account_tokens/terraform.tfvars index 6c09f30f..a395df29 100644 --- a/examples/account_tokens/terraform.tfvars +++ b/examples/account_tokens/terraform.tfvars @@ -1,5 +1,5 @@ api_url = "https://my-codefresh-example.com/api" accounts = [ -"acc1", "acc2" + "acc1", "acc2" ] \ No newline at end of file diff --git a/examples/account_tokens/versions.tf b/examples/account_tokens/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/account_tokens/versions.tf +++ b/examples/account_tokens/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/account_user_associations/main.tf b/examples/account_user_associations/main.tf index c7c06102..87aa4ef3 100644 --- a/examples/account_user_associations/main.tf +++ b/examples/account_user_associations/main.tf @@ -1,8 +1,8 @@ resource "codefresh_account_user_association" "user" { - email = "terraform-test-user+user@codefresh.io" + email = "terraform-test-user+user@codefresh.io" } resource "codefresh_account_user_association" "admin" { - email = "terraform-test-user+admin@codefresh.io" - admin = true + email = "terraform-test-user+admin@codefresh.io" + admin = true } \ No newline at end of file diff --git a/examples/account_user_associations/versions.tf b/examples/account_user_associations/versions.tf index 588936b9..ac97ea7b 100644 --- a/examples/account_user_associations/versions.tf +++ b/examples/account_user_associations/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" } } } \ No newline at end of file diff --git a/examples/accounts_users/main.tf b/examples/accounts_users/main.tf index 574f5a8d..a1f482a9 100644 --- a/examples/accounts_users/main.tf +++ b/examples/accounts_users/main.tf @@ -1,9 +1,9 @@ module "codefresh_access_control" { - source = "../../tf_modules/accounts_users" - api_url = var.api_url + source = "../.modules/accounts_users" + api_url = var.api_url default_idps = var.default_idps - accounts = var.accounts - users = var.users + accounts = var.accounts + users = var.users default_acccount_limits = var.default_acccount_limits } \ No newline at end of file diff --git a/examples/accounts_users/terraform.tfvars b/examples/accounts_users/terraform.tfvars index abffe62f..fcc267a8 100644 --- a/examples/accounts_users/terraform.tfvars +++ b/examples/accounts_users/terraform.tfvars @@ -1,56 +1,56 @@ api_url = "https://my-codefresh.example.com/api" -token = "cfAdmin-token" +token = "cfAdmin-token" default_idps = { - local = { - display_name = "local" - sso = false - } - azure_sso = { - display_name = "azure-sso-1" - sso = true - } + local = { + display_name = "local" + sso = false + } + azure_sso = { + display_name = "azure-sso-1" + sso = true + } } accounts = { - acc1 = {} - acc2 = { - limits = { - collaborators = 50 - parallel_builds = 5 - } + acc1 = {} + acc2 = { + limits = { + collaborators = 50 + parallel_builds = 5 } + } } users = { - user1 = { - email = "user1@example.com" - personal = { - first_name = "John" - last_name = "Smith" - } - accounts = ["acc1", "acc2"] - admin_of_accounts = ["acc1"] - global_admin = true + user1 = { + email = "user1@example.com" + personal = { + first_name = "John" + last_name = "Smith" } - user2 = { - email = "live.com#user2@gmail.com" - personal = { - first_name = "Q" - last_name = "D" - } - accounts = ["acc2"] - admin_of_accounts = [] - global_admin = false + accounts = ["acc1", "acc2"] + admin_of_accounts = ["acc1"] + global_admin = true + } + user2 = { + email = "live.com#user2@gmail.com" + personal = { + first_name = "Q" + last_name = "D" } - user3 = { - email = "user3@example.com" - personal = { - first_name = "Sam" - last_name = "Johnson" - } - accounts = ["acc1", "acc2"] - admin_of_accounts = ["acc1", "acc2"] - global_admin = true + accounts = ["acc2"] + admin_of_accounts = [] + global_admin = false + } + user3 = { + email = "user3@example.com" + personal = { + first_name = "Sam" + last_name = "Johnson" } + accounts = ["acc1", "acc2"] + admin_of_accounts = ["acc1", "acc2"] + global_admin = true + } } \ No newline at end of file diff --git a/examples/accounts_users/vars.tf b/examples/accounts_users/vars.tf index 1d0b2844..c18e3d7c 100644 --- a/examples/accounts_users/vars.tf +++ b/examples/accounts_users/vars.tf @@ -1,22 +1,22 @@ -variable api_url {} +variable "api_url" {} -variable default_acccount_limits { - type = map(any) - default = { - collaborators = 100 - parallel_builds = 10 - } +variable "default_acccount_limits" { + type = map(any) + default = { + collaborators = 100 + parallel_builds = 10 + } } -variable default_idps { +variable "default_idps" { type = map(any) } -variable accounts { +variable "accounts" { type = map(any) } -variable users { +variable "users" { //type = map(any) } diff --git a/examples/accounts_users/versions.tf b/examples/accounts_users/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/accounts_users/versions.tf +++ b/examples/accounts_users/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/permissions/provider.tf b/examples/permissions/provider.tf index 42717d46..b0f062c7 100644 --- a/examples/permissions/provider.tf +++ b/examples/permissions/provider.tf @@ -1,4 +1,4 @@ provider "codefresh" { - api_url = var.api_url - token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable + api_url = var.api_url + token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable } \ No newline at end of file diff --git a/examples/permissions/vars.tf b/examples/permissions/vars.tf index 90f2b988..d0743788 100644 --- a/examples/permissions/vars.tf +++ b/examples/permissions/vars.tf @@ -1,8 +1,8 @@ -variable api_url { +variable "api_url" { type = string } -variable token { - type = string +variable "token" { + type = string default = "" } \ No newline at end of file diff --git a/examples/permissions/versions.tf b/examples/permissions/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/permissions/versions.tf +++ b/examples/permissions/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/pipelines.md b/examples/pipelines.md deleted file mode 100644 index 9ba47b43..00000000 --- a/examples/pipelines.md +++ /dev/null @@ -1,86 +0,0 @@ -# Example - -In the example the Codefresh Provider is configured to authenticate with Codefresh API, and new project and pipeline are created. -Pipeline includes link to the original __codefresh.yml__ spec and two git triggres. - -Run `terraform plan` or `terraform apply` as usual. Note this will modify the actual Codefresh configuration. - -```hcl -provider "codefresh" { - api_url = "https://my.onpremcodefresh.com/api" - token = "xxxxxxxxxxxxxxx.xxxxxxxxxxxxxx" -} - -resource "codefresh_project" "test" { - name = "myproject" - - tags = [ - "docker", - ] - - variables { - go_version = "1.13" - } -} - -resource "codefresh_pipeline" "test" { - name = "${codefresh_project.test.name}/react-sample-app" - - tags = [ - "production", - "docker", - ] - - spec { - concurrency = 1 - priority = 5 - - spec_template { - repo = "codefresh-contrib/react-sample-app" - path = "./codefresh.yml" - revision = "master" - context = "git" - } - - contexts = [ - "context1-name", - "context2-name", - ] - - trigger { - branch_regex = "/.*/gi" - context = "git" - description = "Trigger for commits" - disabled = false - events = [ - "push.heads" - ] - modified_files_glob = "" - name = "commits" - provider = "github" - repo = "codefresh-contrib/react-sample-app" - type = "git" - } - - trigger { - branch_regex = "/.*/gi" - context = "git" - description = "Trigger for tags" - disabled = false - events = [ - "push.tags" - ] - modified_files_glob = "" - name = "tags" - provider = "github" - repo = "codefresh-contrib/react-sample-app" - type = "git" - } - - variables = { - MY_PIP_VAR = "value" - ANOTHER_PIP_VAR = "another_value" - } - } -} -``` diff --git a/examples/pipelines/main.tf b/examples/pipelines/main.tf index 0141f5f7..774c2e27 100644 --- a/examples/pipelines/main.tf +++ b/examples/pipelines/main.tf @@ -1,6 +1,6 @@ provider "codefresh" { api_url = var.api_url - token = var.token + token = var.token } resource "codefresh_project" "test" { @@ -12,7 +12,7 @@ resource "codefresh_project" "test" { } resource "codefresh_pipeline" "test" { - name = "${codefresh_project.test.name}/react-sample-app" + name = "${codefresh_project.test.name}/react-sample-app" tags = [ "production", @@ -65,11 +65,11 @@ steps: ] trigger { - branch_regex = "/.*/gi" - context = "git" - description = "Trigger for commits" - disabled = false - events = [ + branch_regex = "/.*/gi" + context = "git" + description = "Trigger for commits" + disabled = false + events = [ "push.heads" ] modified_files_glob = "" @@ -80,11 +80,11 @@ steps: } trigger { - branch_regex = "/.*/gi" - context = "git" - description = "Trigger for tags" - disabled = false - events = [ + branch_regex = "/.*/gi" + context = "git" + description = "Trigger for tags" + disabled = false + events = [ "push.tags" ] modified_files_glob = "" diff --git a/examples/pipelines/terraform.tfvars b/examples/pipelines/terraform.tfvars index 2923e544..95c5dc08 100644 --- a/examples/pipelines/terraform.tfvars +++ b/examples/pipelines/terraform.tfvars @@ -1,2 +1,2 @@ api_url = "http://g.codefresh.io/api" -token = "" +token = "" diff --git a/examples/pipelines/vars.tf b/examples/pipelines/vars.tf index 90f2b988..d0743788 100644 --- a/examples/pipelines/vars.tf +++ b/examples/pipelines/vars.tf @@ -1,8 +1,8 @@ -variable api_url { +variable "api_url" { type = string } -variable token { - type = string +variable "token" { + type = string default = "" } \ No newline at end of file diff --git a/examples/pipelines/versions.tf b/examples/pipelines/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/pipelines/versions.tf +++ b/examples/pipelines/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/registries/main.tf b/examples/registries/main.tf index 33300230..346c2eee 100644 --- a/examples/registries/main.tf +++ b/examples/registries/main.tf @@ -1,14 +1,14 @@ -variable api_url { +variable "api_url" { type = string } -variable token { +variable "token" { type = string default = "" } -variable test_password { +variable "test_password" { type = string default = "" } @@ -32,7 +32,7 @@ resource "codefresh_registry" "acr" { } resource "codefresh_registry" "gcr" { - name = "gcr" + name = "gcr" # all registries SHOULD be dependent on each other to be created/updated sequentially depends_on = [codefresh_registry.acr] spec { @@ -62,9 +62,9 @@ data "codefresh_registry" "dockerhub" { # example with using data reference to existing registry, not managed by terraform resource "codefresh_registry" "dockerhub1" { - name = "dockerhub1" - primary = !data.codefresh_registry.dockerhub.primary - depends_on = [codefresh_registry.gar] + name = "dockerhub1" + primary = !data.codefresh_registry.dockerhub.primary + depends_on = [codefresh_registry.gar] spec { dockerhub { username = "test" @@ -117,9 +117,9 @@ resource "codefresh_registry" "other1" { } resource "codefresh_registry" "other2" { - name = "other2" - primary = false - depends_on = [codefresh_registry.other1, codefresh_registry.bintray] + name = "other2" + primary = false + depends_on = [codefresh_registry.other1, codefresh_registry.bintray] spec { other { domain = "other.io" diff --git a/examples/registries/terraform.tfvars b/examples/registries/terraform.tfvars index 62a16f34..d629a667 100644 --- a/examples/registries/terraform.tfvars +++ b/examples/registries/terraform.tfvars @@ -1,3 +1,3 @@ api_url = "http://example.com/api" -token = "" +token = "" diff --git a/examples/registries/versions.tf b/examples/registries/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/registries/versions.tf +++ b/examples/registries/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/storate_integration/main.tf b/examples/storage_integration/main.tf similarity index 77% rename from examples/storate_integration/main.tf rename to examples/storage_integration/main.tf index 9870a807..b1810ced 100644 --- a/examples/storate_integration/main.tf +++ b/examples/storage_integration/main.tf @@ -1,13 +1,13 @@ resource "codefresh_context" "gcs" { for_each = toset(["create"]) - name = "gcs" + name = "gcs" spec { storagegc { data { auth { type = "basic" json_config = tomap({ - "config": "cf" + "config" : "cf" }) } } @@ -17,14 +17,14 @@ resource "codefresh_context" "gcs" { resource "codefresh_context" "s3" { for_each = toset(["create"]) - name = "s3" + name = "s3" spec { storages3 { data { auth { type = "basic" json_config = tomap({ - "config": "cf" + "config" : "cf" }) } } @@ -34,14 +34,14 @@ resource "codefresh_context" "s3" { resource "codefresh_context" "azure" { for_each = toset(["create"]) - name = "azure" + name = "azure" spec { storageazuref { data { auth { - type = "basic" + type = "basic" account_name = "accName" - account_key = "accKey" + account_key = "accKey" } } } diff --git a/examples/storate_integration/provider.tf b/examples/storage_integration/provider.tf similarity index 56% rename from examples/storate_integration/provider.tf rename to examples/storage_integration/provider.tf index acdfc9a8..c680ab74 100644 --- a/examples/storate_integration/provider.tf +++ b/examples/storage_integration/provider.tf @@ -8,6 +8,6 @@ terraform { } provider "codefresh" { - api_url = var.api_url - token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable + api_url = var.api_url + token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable } \ No newline at end of file diff --git a/examples/storage_integration/vars.tf b/examples/storage_integration/vars.tf new file mode 100644 index 00000000..d0743788 --- /dev/null +++ b/examples/storage_integration/vars.tf @@ -0,0 +1,8 @@ +variable "api_url" { + type = string +} + +variable "token" { + type = string + default = "" +} \ No newline at end of file diff --git a/examples/storate_integration/versions.tf b/examples/storage_integration/versions.tf similarity index 58% rename from examples/storate_integration/versions.tf rename to examples/storage_integration/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/storate_integration/versions.tf +++ b/examples/storage_integration/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/storate_integration/vars.tf b/examples/storate_integration/vars.tf deleted file mode 100644 index 90f2b988..00000000 --- a/examples/storate_integration/vars.tf +++ /dev/null @@ -1,8 +0,0 @@ -variable api_url { - type = string -} - -variable token { - type = string - default = "" -} \ No newline at end of file diff --git a/examples/teams/main.tf b/examples/teams/main.tf index 887e1c08..87fabc9a 100644 --- a/examples/teams/main.tf +++ b/examples/teams/main.tf @@ -1,21 +1,21 @@ -variable api_url { +variable "api_url" { type = string } -variable token { - type = string +variable "token" { + type = string default = "" } provider "codefresh" { api_url = var.api_url - token = var.token + token = var.token } -variable teams { +variable "teams" { type = map(any) } module "teams" { - source = "../../tf_modules/teams" - teams = var.teams + source = "../.modules/teams" + teams = var.teams } diff --git a/examples/teams/terraform.tfvars b/examples/teams/terraform.tfvars index 126a560c..74b134e4 100644 --- a/examples/teams/terraform.tfvars +++ b/examples/teams/terraform.tfvars @@ -1,7 +1,7 @@ api_url = "https://my-codefresh.example.com/api" -token = "" +token = "" teams = { developers = ["user1", "user3"] - managers = ["user3", "user2"] + managers = ["user3", "user2"] } \ No newline at end of file diff --git a/examples/teams/versions.tf b/examples/teams/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/teams/versions.tf +++ b/examples/teams/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/examples/triggers/versions.tf b/examples/triggers/versions.tf index 9dee49eb..2f55b54c 100644 --- a/examples/triggers/versions.tf +++ b/examples/triggers/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { codefresh = { - source = "codefresh-io/codefresh" + source = "registry.terraform.io/codefresh-io/codefresh" version = "~> 0.1" } } diff --git a/scripts/gofmtcheck.sh b/scripts/gofmtcheck.sh deleted file mode 100755 index dd2307ac..00000000 --- a/scripts/gofmtcheck.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# Check gofmt -echo "==> Checking that code complies with gofmt requirements..." -gofmt_files=$(find . -name '*.go' | grep -v vendor | xargs gofmt -l -s) -if [[ -n ${gofmt_files} ]]; then - echo 'gofmt needs running on the following files:' - echo "${gofmt_files}" - echo "You can use the command: \`make fmt\` to reformat code." - exit 1 -fi - -exit 0 diff --git a/scripts/gogetcookie.sh b/scripts/gogetcookie.sh deleted file mode 100755 index 26c63a64..00000000 --- a/scripts/gogetcookie.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -touch ~/.gitcookies -chmod 0600 ~/.gitcookies - -git config --global http.cookiefile ~/.gitcookies - -tr , \\t <<\__END__ >>~/.gitcookies -.googlesource.com,TRUE,/,TRUE,2147483647,o,git-paul.hashicorp.com=1/z7s05EYPudQ9qoe6dMVfmAVwgZopEkZBb1a2mA5QtHE -__END__ From 2cb11c19a24e5ecbba33efcdd628413b242955d5 Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:25:01 -0400 Subject: [PATCH 2/7] Fix examples. --- .gitignore | 4 +- GNUmakefile | 27 +- codefresh/internal/schemautil/validation.go | 2 +- codefresh/resource_pipeline_test.go | 4 +- codefresh/resource_step_types_test.go | 13 +- examples/abac_rules/main.tf | 4 - examples/abac_rules/provider.tf | 5 - examples/abac_rules/terraform.tfvars | 3 - examples/abac_rules/vars.tf | 12 - examples/accounts_users/terraform.tfvars | 3 - examples/accounts_users/vars.tf | 2 - examples/permissions/provider.tf | 4 - examples/permissions/terraform.tfvars | 1 - examples/permissions/vars.tf | 8 - examples/pipelines/main.tf | 5 - examples/pipelines/terraform.tfvars | 2 - examples/pipelines/vars.tf | 8 - examples/registries/main.tf | 15 - examples/registries/terraform.tfvars | 3 - examples/storage_integration/provider.tf | 13 - examples/storage_integration/vars.tf | 8 - examples/teams/main.tf | 13 - examples/teams/terraform.tfvars | 3 - examples/triggers/main.tf | 7 - examples/triggers/terraform.tfvars | 2 - examples/triggers/vars.tf | 8 - testing/equivalence/README.md | 15 + testing/equivalence/compare-results.sh | 22 ++ testing/equivalence/lib.sh | 22 ++ .../results/opentofu/test_abac_rules/plan | 53 +++ .../opentofu/test_abac_rules/plan.json | 331 ++++++++++++++++++ .../results/opentofu/test_abac_rules/state | 1 + .../opentofu/test_abac_rules/state.json | 3 + .../results/terraform/test_abac_rules/plan | 53 +++ .../terraform/test_abac_rules/plan.json | 331 ++++++++++++++++++ .../results/terraform/test_abac_rules/state | 1 + .../terraform/test_abac_rules/state.json | 3 + testing/equivalence/rewrites.jsonc | 12 + .../test_cases/test_abac_rules/main.tf | 5 + .../test_cases/test_abac_rules/spec.json | 42 +++ testing/equivalence/update-test-cases.sh | 88 +++++ .../fixtures}/testStepTypesOrder.yaml | 0 .../fixtures}/testStepWithRuntimeData.yaml | 0 .../fixtures}/testSteps.yaml | 0 .../fixtures}/testStepsTemplate.yaml | 0 45 files changed, 1019 insertions(+), 142 deletions(-) delete mode 100644 examples/abac_rules/provider.tf delete mode 100644 examples/abac_rules/terraform.tfvars delete mode 100644 examples/abac_rules/vars.tf delete mode 100644 examples/permissions/provider.tf delete mode 100644 examples/permissions/terraform.tfvars delete mode 100644 examples/permissions/vars.tf delete mode 100644 examples/pipelines/terraform.tfvars delete mode 100644 examples/pipelines/vars.tf delete mode 100644 examples/registries/terraform.tfvars delete mode 100644 examples/storage_integration/provider.tf delete mode 100644 examples/storage_integration/vars.tf delete mode 100644 examples/triggers/terraform.tfvars delete mode 100644 examples/triggers/vars.tf create mode 100644 testing/equivalence/README.md create mode 100755 testing/equivalence/compare-results.sh create mode 100644 testing/equivalence/lib.sh create mode 100644 testing/equivalence/results/opentofu/test_abac_rules/plan create mode 100644 testing/equivalence/results/opentofu/test_abac_rules/plan.json create mode 100644 testing/equivalence/results/opentofu/test_abac_rules/state create mode 100644 testing/equivalence/results/opentofu/test_abac_rules/state.json create mode 100644 testing/equivalence/results/terraform/test_abac_rules/plan create mode 100644 testing/equivalence/results/terraform/test_abac_rules/plan.json create mode 100644 testing/equivalence/results/terraform/test_abac_rules/state create mode 100644 testing/equivalence/results/terraform/test_abac_rules/state.json create mode 100644 testing/equivalence/rewrites.jsonc create mode 100644 testing/equivalence/test_cases/test_abac_rules/main.tf create mode 100644 testing/equivalence/test_cases/test_abac_rules/spec.json create mode 100755 testing/equivalence/update-test-cases.sh rename {test_data/step_types => testing/fixtures}/testStepTypesOrder.yaml (100%) rename {test_data/step_types => testing/fixtures}/testStepWithRuntimeData.yaml (100%) rename {test_data/step_types => testing/fixtures}/testSteps.yaml (100%) rename {test_data/step_types => testing/fixtures}/testStepsTemplate.yaml (100%) diff --git a/.gitignore b/.gitignore index 78aae934..66de7737 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,6 @@ tests/ .idea **/*.lock.hcl -**/*.backup \ No newline at end of file +**/*.backup + +.DS_Store \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index fdd0cdfc..d2bdb0b6 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,7 +5,7 @@ HOSTNAME=codefresh.io PKG_NAME=codefresh NAMESPACE=app BINARY=terraform-provider-${PKG_NAME} -OS_ARCH=darwin_amd64 +OS_ARCH=$$(go env GOOS)_$$(go env GOARCH) TFPLUGINDOCS_VERSION=v0.14.1 default: build @@ -22,13 +22,36 @@ build: fmtcheck install: build mv ${BINARY} $(HOME)/go/bin/ +equivalence: build + @echo "==> Preparing equivalence tests" + mkdir -p testing/equivalence/.plugins/registry.terraform.io/codefresh-io/codefresh/0.6.0/${OS_ARCH}/ + cp terraform-provider-codefresh testing/equivalence/.plugins/registry.terraform.io/codefresh-io/codefresh/0.6.0/${OS_ARCH}/ + + cd testing/equivalence;\ + ./update-test-cases.sh;\ + + @echo "==> Running equivalence tests for terraform" + cd testing/equivalence;\ + equivalence-testing update --binary=$$(which terraform) --goldens=results/terraform --tests=test_cases --rewrites=rewrites.jsonc + + @echo "==> Running equivalence tests for opentofu" + cd testing/equivalence;\ + equivalence-testing update --binary=$$(which tofu) --goldens=results/opentofu --tests=test_cases --rewrites=rewrites.jsonc fmt: @echo "==> Fixing source code with gofmt..." gofmt -s -w $(GOFMT_FILES) +fmtcheck: SHELL:=/bin/bash fmtcheck: - @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" + @echo "==> Checking that code complies with gofmt requirements..." + @gofmt_files=$$(find . -name '*.go' | grep -v vendor | xargs gofmt -l -s); \ + if [[ -n $${gofmt_files} ]]; then\ + echo 'gofmt needs running on the following files:';\ + echo "$${gofmt_files}";\ + echo "You can use the command: \`make fmt\` to reformat code.";\ + exit 1;\ + fi; lint: @echo "==> Checking source code against linters..." golangci-lint run ./... diff --git a/codefresh/internal/schemautil/validation.go b/codefresh/internal/schemautil/validation.go index 263ae1fa..3cc188bd 100644 --- a/codefresh/internal/schemautil/validation.go +++ b/codefresh/internal/schemautil/validation.go @@ -89,4 +89,4 @@ func (o *ValidationOptions) setSummary(summary string) *ValidationOptions { func (o *ValidationOptions) setDetailFormat(detailFormat string) *ValidationOptions { o.detailFormat = detailFormat return o -} \ No newline at end of file +} diff --git a/codefresh/resource_pipeline_test.go b/codefresh/resource_pipeline_test.go index 4bfcfdf9..07dff4ad 100644 --- a/codefresh/resource_pipeline_test.go +++ b/codefresh/resource_pipeline_test.go @@ -532,8 +532,8 @@ func TestAccCodefreshPipeline_CronTriggersInvalid(t *testing.T) { var pipeline cfclient.Pipeline resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, Steps: []resource.TestStep{ { Config: testAccCodefreshPipelineBasicConfigCronTriggers( diff --git a/codefresh/resource_step_types_test.go b/codefresh/resource_step_types_test.go index 74857f8f..837b7fbc 100644 --- a/codefresh/resource_step_types_test.go +++ b/codefresh/resource_step_types_test.go @@ -2,7 +2,6 @@ package codefresh import ( "fmt" - "io/ioutil" "log" "os" "regexp" @@ -48,8 +47,8 @@ func TestCleanUpStepFromTransientValues(t *testing.T) { } func TestNormalizeYamlStringStepTypes(t *testing.T) { - testFile := "../test_data/step_types/testStepWithRuntimeData.yaml" - yamlString, err := ioutil.ReadFile(testFile) + testFile := "../testing/fixtures/testStepWithRuntimeData.yaml" + yamlString, err := os.ReadFile(testFile) if err != nil { t.Errorf("Unable to open test file %s. Err: #%v ", testFile, err) } @@ -84,8 +83,8 @@ func TestSortVersions(t *testing.T) { } func TestExtractSteps(t *testing.T) { - testFile := "../test_data/step_types/testStepTypesOrder.yaml" - yamlString, err := ioutil.ReadFile(testFile) + testFile := "../testing/fixtures/testStepTypesOrder.yaml" + yamlString, err := os.ReadFile(testFile) if err != nil { t.Errorf("Unable to read file %s", testFile) } @@ -112,11 +111,11 @@ func TestAccCodefreshStepTypes(t *testing.T) { } name := accountName + "/" + stepTypesNamePrefix + acctest.RandString(10) resourceName := "codefresh_step_types.test" - contentStepsV1, err := ioutil.ReadFile("../test_data/step_types/testSteps.yaml") + contentStepsV1, err := os.ReadFile("../testing/fixtures/testSteps.yaml") if err != nil { log.Fatal(err) } - contentStepsV2, err := ioutil.ReadFile("../test_data/step_types/testStepsTemplate.yaml") + contentStepsV2, err := os.ReadFile("../testing/fixtures/testStepsTemplate.yaml") if err != nil { log.Fatal(err) } diff --git a/examples/abac_rules/main.tf b/examples/abac_rules/main.tf index b33f599a..190d7f81 100644 --- a/examples/abac_rules/main.tf +++ b/examples/abac_rules/main.tf @@ -1,7 +1,3 @@ -data "codefresh_team" "admins" { - name = "admins" -} - data "codefresh_team" "users" { name = "users" } diff --git a/examples/abac_rules/provider.tf b/examples/abac_rules/provider.tf deleted file mode 100644 index 411f4965..00000000 --- a/examples/abac_rules/provider.tf +++ /dev/null @@ -1,5 +0,0 @@ -provider "codefresh" { - api_url = var.api_url - api_url_v2 = var.api_url_v2 - token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable -} \ No newline at end of file diff --git a/examples/abac_rules/terraform.tfvars b/examples/abac_rules/terraform.tfvars deleted file mode 100644 index d63ad4a7..00000000 --- a/examples/abac_rules/terraform.tfvars +++ /dev/null @@ -1,3 +0,0 @@ -api_url = "https://my-codefresh.example.com/api" -api_url_v2 = "https://my-codefresh.example.com/2.0/api/graphql" -token = "" diff --git a/examples/abac_rules/vars.tf b/examples/abac_rules/vars.tf deleted file mode 100644 index 778f3aed..00000000 --- a/examples/abac_rules/vars.tf +++ /dev/null @@ -1,12 +0,0 @@ -variable "api_url" { - type = string -} - -variable "api_url_v2" { - type = string -} - -variable "token" { - type = string - default = "" -} \ No newline at end of file diff --git a/examples/accounts_users/terraform.tfvars b/examples/accounts_users/terraform.tfvars index fcc267a8..9b4e41ff 100644 --- a/examples/accounts_users/terraform.tfvars +++ b/examples/accounts_users/terraform.tfvars @@ -1,6 +1,3 @@ -api_url = "https://my-codefresh.example.com/api" -token = "cfAdmin-token" - default_idps = { local = { display_name = "local" diff --git a/examples/accounts_users/vars.tf b/examples/accounts_users/vars.tf index c18e3d7c..18d78a6c 100644 --- a/examples/accounts_users/vars.tf +++ b/examples/accounts_users/vars.tf @@ -1,5 +1,3 @@ -variable "api_url" {} - variable "default_acccount_limits" { type = map(any) default = { diff --git a/examples/permissions/provider.tf b/examples/permissions/provider.tf deleted file mode 100644 index b0f062c7..00000000 --- a/examples/permissions/provider.tf +++ /dev/null @@ -1,4 +0,0 @@ -provider "codefresh" { - api_url = var.api_url - token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable -} \ No newline at end of file diff --git a/examples/permissions/terraform.tfvars b/examples/permissions/terraform.tfvars deleted file mode 100644 index f1be2951..00000000 --- a/examples/permissions/terraform.tfvars +++ /dev/null @@ -1 +0,0 @@ -api_url = "https://my-codefresh.example.com/api" \ No newline at end of file diff --git a/examples/permissions/vars.tf b/examples/permissions/vars.tf deleted file mode 100644 index d0743788..00000000 --- a/examples/permissions/vars.tf +++ /dev/null @@ -1,8 +0,0 @@ -variable "api_url" { - type = string -} - -variable "token" { - type = string - default = "" -} \ No newline at end of file diff --git a/examples/pipelines/main.tf b/examples/pipelines/main.tf index 774c2e27..8e86576b 100644 --- a/examples/pipelines/main.tf +++ b/examples/pipelines/main.tf @@ -1,8 +1,3 @@ -provider "codefresh" { - api_url = var.api_url - token = var.token -} - resource "codefresh_project" "test" { name = "myproject" diff --git a/examples/pipelines/terraform.tfvars b/examples/pipelines/terraform.tfvars deleted file mode 100644 index 95c5dc08..00000000 --- a/examples/pipelines/terraform.tfvars +++ /dev/null @@ -1,2 +0,0 @@ -api_url = "http://g.codefresh.io/api" -token = "" diff --git a/examples/pipelines/vars.tf b/examples/pipelines/vars.tf deleted file mode 100644 index d0743788..00000000 --- a/examples/pipelines/vars.tf +++ /dev/null @@ -1,8 +0,0 @@ -variable "api_url" { - type = string -} - -variable "token" { - type = string - default = "" -} \ No newline at end of file diff --git a/examples/registries/main.tf b/examples/registries/main.tf index 346c2eee..a0939af1 100644 --- a/examples/registries/main.tf +++ b/examples/registries/main.tf @@ -1,23 +1,8 @@ - -variable "api_url" { - type = string -} - -variable "token" { - type = string - default = "" -} - variable "test_password" { type = string default = "" } -provider "codefresh" { - api_url = var.api_url - token = var.token -} - resource "codefresh_registry" "acr" { name = "acr" default = true diff --git a/examples/registries/terraform.tfvars b/examples/registries/terraform.tfvars deleted file mode 100644 index d629a667..00000000 --- a/examples/registries/terraform.tfvars +++ /dev/null @@ -1,3 +0,0 @@ -api_url = "http://example.com/api" -token = "" - diff --git a/examples/storage_integration/provider.tf b/examples/storage_integration/provider.tf deleted file mode 100644 index c680ab74..00000000 --- a/examples/storage_integration/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - codefresh = { - source = "codefresh.io/app/codefresh" - version = "0.1.0" - } - } -} - -provider "codefresh" { - api_url = var.api_url - token = var.token # If token isn't set the provider expects the $CODEFRESH_API_KEY env variable -} \ No newline at end of file diff --git a/examples/storage_integration/vars.tf b/examples/storage_integration/vars.tf deleted file mode 100644 index d0743788..00000000 --- a/examples/storage_integration/vars.tf +++ /dev/null @@ -1,8 +0,0 @@ -variable "api_url" { - type = string -} - -variable "token" { - type = string - default = "" -} \ No newline at end of file diff --git a/examples/teams/main.tf b/examples/teams/main.tf index 87fabc9a..fb7eb9bb 100644 --- a/examples/teams/main.tf +++ b/examples/teams/main.tf @@ -1,16 +1,3 @@ -variable "api_url" { - type = string -} - -variable "token" { - type = string - default = "" -} -provider "codefresh" { - api_url = var.api_url - token = var.token -} - variable "teams" { type = map(any) } diff --git a/examples/teams/terraform.tfvars b/examples/teams/terraform.tfvars index 74b134e4..e2917e23 100644 --- a/examples/teams/terraform.tfvars +++ b/examples/teams/terraform.tfvars @@ -1,6 +1,3 @@ -api_url = "https://my-codefresh.example.com/api" -token = "" - teams = { developers = ["user1", "user3"] managers = ["user3", "user2"] diff --git a/examples/triggers/main.tf b/examples/triggers/main.tf index 8f764a08..edbc8c93 100644 --- a/examples/triggers/main.tf +++ b/examples/triggers/main.tf @@ -1,12 +1,5 @@ -provider "codefresh" { - api_url = var.api_url - token = var.token -} - module "pipeline" { source = "../pipelines" - api_url = var.api_url - token = var.token } resource "codefresh_pipeline_cron_trigger" "default" { diff --git a/examples/triggers/terraform.tfvars b/examples/triggers/terraform.tfvars deleted file mode 100644 index 95c5dc08..00000000 --- a/examples/triggers/terraform.tfvars +++ /dev/null @@ -1,2 +0,0 @@ -api_url = "http://g.codefresh.io/api" -token = "" diff --git a/examples/triggers/vars.tf b/examples/triggers/vars.tf deleted file mode 100644 index d0743788..00000000 --- a/examples/triggers/vars.tf +++ /dev/null @@ -1,8 +0,0 @@ -variable "api_url" { - type = string -} - -variable "token" { - type = string - default = "" -} \ No newline at end of file diff --git a/testing/equivalence/README.md b/testing/equivalence/README.md new file mode 100644 index 00000000..b03ba005 --- /dev/null +++ b/testing/equivalence/README.md @@ -0,0 +1,15 @@ +# Equivalence Tests + +This directory contains equivalence tests for the provider. + +See: https://github.com/opentofu/equivalence-testing + +## Updating Equivalence Test Cases + +When additional examples are added to [examples/](../../../examples), the equivalence test cases should be updated as well. + +```bash +$ ./update-test-cases.sh +``` + +Then, \ No newline at end of file diff --git a/testing/equivalence/compare-results.sh b/testing/equivalence/compare-results.sh new file mode 100755 index 00000000..df868eda --- /dev/null +++ b/testing/equivalence/compare-results.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +source $(realpath $(dirname $0))/lib.sh + +for i in $(find $(realpath $(dirname $0))/results/terraform -mindepth 1 -not -path '**/*/.*' -type d); do + test_case_name=$(basename ${i}) + print_style "Test case " + print_style "${test_case_name}" "info" + print_style ":\n" + for f in $(find ${i} -type f); do + print_style " * comparing " + print_style "results/terraform/$(basename ${f})" "info" + print_style " and " + print_style "results/opentofu/$(basename ${f})" "info" + print_style ": " + diff \ + $(realpath $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) \ + $(realpath $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) \ + || print_style "FAILED\n" "danger" \ + && print_style "PASS\n" "success" + done +done \ No newline at end of file diff --git a/testing/equivalence/lib.sh b/testing/equivalence/lib.sh new file mode 100644 index 00000000..ea903c98 --- /dev/null +++ b/testing/equivalence/lib.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# prints colored text +print_style () { + + if [ "$2" == "info" ] ; then + COLOR="96m"; + elif [ "$2" == "success" ] ; then + COLOR="92m"; + elif [ "$2" == "warning" ] ; then + COLOR="93m"; + elif [ "$2" == "danger" ] ; then + COLOR="91m"; + else #default color + COLOR="0m"; + fi + + STARTCOLOR="\e[$COLOR"; + ENDCOLOR="\e[0m"; + + printf "$STARTCOLOR%b$ENDCOLOR" "$1"; +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_abac_rules/plan b/testing/equivalence/results/opentofu/test_abac_rules/plan new file mode 100644 index 00000000..a23a8275 --- /dev/null +++ b/testing/equivalence/results/opentofu/test_abac_rules/plan @@ -0,0 +1,53 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. +module.test.data.codefresh_team.users: Reading... +module.test.data.codefresh_team.users: Read complete after 0s [id=64050eece8e7a480941d22b2] + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_abac_rules.app_rule will be created + + resource "codefresh_abac_rules" "app_rule" { + + actions = [ + + "APP_ROLLBACK", + + "REFRESH", + + "SYNC", + + "TERMINATE_SYNC", + + "VIEW_POD_LOGS", + ] + + entity_type = "gitopsApplications" + + id = (known after apply) + + tags = [ + + "dev", + + "untagged", + ] + + teams = [ + + "64050eece8e7a480941d22b2", + ] + + + attribute { + + key = "KEY" + + name = "LABEL" + + value = "VALUE" + } + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/opentofu/test_abac_rules/plan.json b/testing/equivalence/results/opentofu/test_abac_rules/plan.json new file mode 100644 index 00000000..4ad7fbdc --- /dev/null +++ b/testing/equivalence/results/opentofu/test_abac_rules/plan.json @@ -0,0 +1,331 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "resources": [ + { + "address": "codefresh_abac_rules.app_rule", + "expressions": { + "actions": { + "constant_value": [ + "REFRESH", + "SYNC", + "TERMINATE_SYNC", + "VIEW_POD_LOGS", + "APP_ROLLBACK" + ] + }, + "attribute": [ + { + "key": { + "constant_value": "KEY" + }, + "name": { + "constant_value": "LABEL" + }, + "value": { + "constant_value": "VALUE" + } + } + ], + "entity_type": { + "constant_value": "gitopsApplications" + }, + "tags": { + "constant_value": [ + "dev", + "untagged" + ] + }, + "teams": { + "references": [ + "data.codefresh_team.users.id", + "data.codefresh_team.users" + ] + } + }, + "mode": "managed", + "name": "app_rule", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_abac_rules" + }, + { + "address": "data.codefresh_team.users", + "expressions": { + "name": { + "constant_value": "users" + } + }, + "mode": "data", + "name": "users", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_team" + } + ] + }, + "source": "../../../../examples/abac_rules" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_abac_rules.app_rule", + "mode": "managed", + "name": "app_rule", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "actions": [ + false, + false, + false, + false, + false + ], + "attribute": [ + {} + ], + "tags": [ + false, + false + ], + "teams": [ + false + ] + }, + "type": "codefresh_abac_rules", + "values": { + "actions": [ + "APP_ROLLBACK", + "REFRESH", + "SYNC", + "TERMINATE_SYNC", + "VIEW_POD_LOGS" + ], + "attribute": [ + { + "key": "KEY", + "name": "LABEL", + "value": "VALUE" + } + ], + "entity_type": "gitopsApplications", + "tags": [ + "dev", + "untagged" + ], + "teams": [ + "64050eece8e7a480941d22b2" + ] + } + } + ] + } + ] + } + }, + "prior_state": { + "format_version": "1.0", + "values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.data.codefresh_team.users", + "mode": "data", + "name": "users", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "tags": [], + "users": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + }, + "type": "codefresh_team", + "values": { + "_id": "64050eece8e7a480941d22b2", + "account_id": "64050eece8e7a40e1a1d22ae", + "id": "64050eece8e7a480941d22b2", + "name": "users", + "tags": [], + "type": "default", + "users": [ + "640445a0e147e51fa2a635bf", + "64050f978fad134f026be44f", + "6519c24db84a36589aade546", + "651ab21757ae98649b450b3f", + "651c1d58ab78e76d12cfa5e5", + "651c1d5854474574e3daf9af", + "651c207e5447457965db03a6", + "651c2f9c544745dd9adb07a2", + "651c30305447454efddb1039", + "651c33708ed49127b073c300", + "651c435f544745deb2db3ce6", + "651c443d54474506cfdb3e15", + "651c55be8ed491672973f271", + "651c59791761796def0b296c", + "651d275a54474514b5db8915", + "652d843485b74730bfde344b", + "652d84411b31f4453699d658", + "652d844185b747ffc9de3598", + "652d852c1b31f45fd099e4b3", + "652d852e85b7470e2dde43c4", + "652d8c16843ad31a08a9d934", + "652d8c258356a5123a10555e", + "652d8cf557961b5fb7395b38", + "652d8d07843ad355e9a9e69b", + "652d9005e628aa398743807b", + "652d900c52bb9815b634f62f", + "652e7aa71bb3fc905a32e180", + "652e7ac5a830b06416aa55fd", + "652e7ac5582aa8ffb169b02a", + "652e7adae440d45688fe85b2" + ] + } + } + ] + } + ] + } + } + }, + "relevant_attributes": [ + { + "attribute": [ + "id" + ], + "resource": "module.test.data.codefresh_team.users" + } + ], + "resource_changes": [ + { + "address": "module.test.codefresh_abac_rules.app_rule", + "change": { + "actions": [ + "create" + ], + "after": { + "actions": [ + "APP_ROLLBACK", + "REFRESH", + "SYNC", + "TERMINATE_SYNC", + "VIEW_POD_LOGS" + ], + "attribute": [ + { + "key": "KEY", + "name": "LABEL", + "value": "VALUE" + } + ], + "entity_type": "gitopsApplications", + "tags": [ + "dev", + "untagged" + ], + "teams": [ + "64050eece8e7a480941d22b2" + ] + }, + "after_sensitive": { + "actions": [ + false, + false, + false, + false, + false + ], + "attribute": [ + {} + ], + "tags": [ + false, + false + ], + "teams": [ + false + ] + }, + "after_unknown": { + "actions": [ + false, + false, + false, + false, + false + ], + "attribute": [ + {} + ], + "id": true, + "tags": [ + false, + false + ], + "teams": [ + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "app_rule", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_abac_rules" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_abac_rules/state b/testing/equivalence/results/opentofu/test_abac_rules/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/opentofu/test_abac_rules/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/opentofu/test_abac_rules/state.json b/testing/equivalence/results/opentofu/test_abac_rules/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/opentofu/test_abac_rules/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_abac_rules/plan b/testing/equivalence/results/terraform/test_abac_rules/plan new file mode 100644 index 00000000..a23a8275 --- /dev/null +++ b/testing/equivalence/results/terraform/test_abac_rules/plan @@ -0,0 +1,53 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. +module.test.data.codefresh_team.users: Reading... +module.test.data.codefresh_team.users: Read complete after 0s [id=64050eece8e7a480941d22b2] + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_abac_rules.app_rule will be created + + resource "codefresh_abac_rules" "app_rule" { + + actions = [ + + "APP_ROLLBACK", + + "REFRESH", + + "SYNC", + + "TERMINATE_SYNC", + + "VIEW_POD_LOGS", + ] + + entity_type = "gitopsApplications" + + id = (known after apply) + + tags = [ + + "dev", + + "untagged", + ] + + teams = [ + + "64050eece8e7a480941d22b2", + ] + + + attribute { + + key = "KEY" + + name = "LABEL" + + value = "VALUE" + } + } + +Plan: 1 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/terraform/test_abac_rules/plan.json b/testing/equivalence/results/terraform/test_abac_rules/plan.json new file mode 100644 index 00000000..4ad7fbdc --- /dev/null +++ b/testing/equivalence/results/terraform/test_abac_rules/plan.json @@ -0,0 +1,331 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "resources": [ + { + "address": "codefresh_abac_rules.app_rule", + "expressions": { + "actions": { + "constant_value": [ + "REFRESH", + "SYNC", + "TERMINATE_SYNC", + "VIEW_POD_LOGS", + "APP_ROLLBACK" + ] + }, + "attribute": [ + { + "key": { + "constant_value": "KEY" + }, + "name": { + "constant_value": "LABEL" + }, + "value": { + "constant_value": "VALUE" + } + } + ], + "entity_type": { + "constant_value": "gitopsApplications" + }, + "tags": { + "constant_value": [ + "dev", + "untagged" + ] + }, + "teams": { + "references": [ + "data.codefresh_team.users.id", + "data.codefresh_team.users" + ] + } + }, + "mode": "managed", + "name": "app_rule", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_abac_rules" + }, + { + "address": "data.codefresh_team.users", + "expressions": { + "name": { + "constant_value": "users" + } + }, + "mode": "data", + "name": "users", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_team" + } + ] + }, + "source": "../../../../examples/abac_rules" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_abac_rules.app_rule", + "mode": "managed", + "name": "app_rule", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "actions": [ + false, + false, + false, + false, + false + ], + "attribute": [ + {} + ], + "tags": [ + false, + false + ], + "teams": [ + false + ] + }, + "type": "codefresh_abac_rules", + "values": { + "actions": [ + "APP_ROLLBACK", + "REFRESH", + "SYNC", + "TERMINATE_SYNC", + "VIEW_POD_LOGS" + ], + "attribute": [ + { + "key": "KEY", + "name": "LABEL", + "value": "VALUE" + } + ], + "entity_type": "gitopsApplications", + "tags": [ + "dev", + "untagged" + ], + "teams": [ + "64050eece8e7a480941d22b2" + ] + } + } + ] + } + ] + } + }, + "prior_state": { + "format_version": "1.0", + "values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.data.codefresh_team.users", + "mode": "data", + "name": "users", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "tags": [], + "users": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ] + }, + "type": "codefresh_team", + "values": { + "_id": "64050eece8e7a480941d22b2", + "account_id": "64050eece8e7a40e1a1d22ae", + "id": "64050eece8e7a480941d22b2", + "name": "users", + "tags": [], + "type": "default", + "users": [ + "640445a0e147e51fa2a635bf", + "64050f978fad134f026be44f", + "6519c24db84a36589aade546", + "651ab21757ae98649b450b3f", + "651c1d58ab78e76d12cfa5e5", + "651c1d5854474574e3daf9af", + "651c207e5447457965db03a6", + "651c2f9c544745dd9adb07a2", + "651c30305447454efddb1039", + "651c33708ed49127b073c300", + "651c435f544745deb2db3ce6", + "651c443d54474506cfdb3e15", + "651c55be8ed491672973f271", + "651c59791761796def0b296c", + "651d275a54474514b5db8915", + "652d843485b74730bfde344b", + "652d84411b31f4453699d658", + "652d844185b747ffc9de3598", + "652d852c1b31f45fd099e4b3", + "652d852e85b7470e2dde43c4", + "652d8c16843ad31a08a9d934", + "652d8c258356a5123a10555e", + "652d8cf557961b5fb7395b38", + "652d8d07843ad355e9a9e69b", + "652d9005e628aa398743807b", + "652d900c52bb9815b634f62f", + "652e7aa71bb3fc905a32e180", + "652e7ac5a830b06416aa55fd", + "652e7ac5582aa8ffb169b02a", + "652e7adae440d45688fe85b2" + ] + } + } + ] + } + ] + } + } + }, + "relevant_attributes": [ + { + "attribute": [ + "id" + ], + "resource": "module.test.data.codefresh_team.users" + } + ], + "resource_changes": [ + { + "address": "module.test.codefresh_abac_rules.app_rule", + "change": { + "actions": [ + "create" + ], + "after": { + "actions": [ + "APP_ROLLBACK", + "REFRESH", + "SYNC", + "TERMINATE_SYNC", + "VIEW_POD_LOGS" + ], + "attribute": [ + { + "key": "KEY", + "name": "LABEL", + "value": "VALUE" + } + ], + "entity_type": "gitopsApplications", + "tags": [ + "dev", + "untagged" + ], + "teams": [ + "64050eece8e7a480941d22b2" + ] + }, + "after_sensitive": { + "actions": [ + false, + false, + false, + false, + false + ], + "attribute": [ + {} + ], + "tags": [ + false, + false + ], + "teams": [ + false + ] + }, + "after_unknown": { + "actions": [ + false, + false, + false, + false, + false + ], + "attribute": [ + {} + ], + "id": true, + "tags": [ + false, + false + ], + "teams": [ + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "app_rule", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_abac_rules" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_abac_rules/state b/testing/equivalence/results/terraform/test_abac_rules/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/terraform/test_abac_rules/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/terraform/test_abac_rules/state.json b/testing/equivalence/results/terraform/test_abac_rules/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/terraform/test_abac_rules/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/rewrites.jsonc b/testing/equivalence/rewrites.jsonc new file mode 100644 index 00000000..f732fc71 --- /dev/null +++ b/testing/equivalence/rewrites.jsonc @@ -0,0 +1,12 @@ +// https://github.com/opentofu/equivalence-testing/blob/3bc3ca8b5f3761fb23d48220d4c0fe4de0a97c9b/examples/rewrites.jsonc +{ + "plan": { + "Terraform": "OpenTofu", + "terraform": "tofu", + // This rewrite is necessary because the word wrap is different - the + // character count differs between "Terraform" and "OpenTofu" so the lines + // are wrapped slightly differently. In fact, OpenTofu's version is slightly + // more pleasing to the eye. + "execution\nplan. Resource": "execution plan.\nResource" + } +} \ No newline at end of file diff --git a/testing/equivalence/test_cases/test_abac_rules/main.tf b/testing/equivalence/test_cases/test_abac_rules/main.tf new file mode 100644 index 00000000..27f16033 --- /dev/null +++ b/testing/equivalence/test_cases/test_abac_rules/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/abac_rules" +} diff --git a/testing/equivalence/test_cases/test_abac_rules/spec.json b/testing/equivalence/test_cases/test_abac_rules/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_abac_rules/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/update-test-cases.sh b/testing/equivalence/update-test-cases.sh new file mode 100755 index 00000000..b2adb7dc --- /dev/null +++ b/testing/equivalence/update-test-cases.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +source $(realpath $(dirname $0))/lib.sh + +if [[ "$OSTYPE" == "darwin"* ]] && ! command -v grealpath &> /dev/null; +then + print_style "ERROR: This script requires grealpath when run on Mac. Please install it with 'brew install coreutils'\n" "danger" + exit 1 +fi + +test_case_dirname="test_cases" +test_case_prefix="test_" + +if [[ ! -d ${test_case_dirname} ]]; then + print_style "Creating test case directory" + print_style "${test_case_dirname}" "info" + print_style "...\n" + mkdir -p ${test_case_dirname} +fi + +for i in $(find $(dirname $(grealpath $0))/../../examples -mindepth 1 -prune -path '**/*/.*' -type d); do + print_style "Found example directory: " + print_style "${i}\n" + expected_test_dir="$(dirname $(grealpath $0))/${test_case_dirname}/${test_case_prefix}$(basename ${i})" + + if [[ ! -d ${expected_test_dir} ]]; then + print_style " * creating missing directory " + print_sytle "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})\n" "warning" + mkdir -p ${expected_test_dir} + fi + + print_style " * updating " + print_style "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})/main.tf\n" "info" + cat << EOF > ${expected_test_dir}/main.tf +# DO NOT EDIT +# This file is automatically generated by $(basename $0) +module test { + source = "../../../../examples/$(basename ${i})" +} +EOF + + print_style " * updating " + print_style "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})/spec.json\n" "info" + cat << EOF > ${expected_test_dir}/spec.json +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} +EOF +done diff --git a/test_data/step_types/testStepTypesOrder.yaml b/testing/fixtures/testStepTypesOrder.yaml similarity index 100% rename from test_data/step_types/testStepTypesOrder.yaml rename to testing/fixtures/testStepTypesOrder.yaml diff --git a/test_data/step_types/testStepWithRuntimeData.yaml b/testing/fixtures/testStepWithRuntimeData.yaml similarity index 100% rename from test_data/step_types/testStepWithRuntimeData.yaml rename to testing/fixtures/testStepWithRuntimeData.yaml diff --git a/test_data/step_types/testSteps.yaml b/testing/fixtures/testSteps.yaml similarity index 100% rename from test_data/step_types/testSteps.yaml rename to testing/fixtures/testSteps.yaml diff --git a/test_data/step_types/testStepsTemplate.yaml b/testing/fixtures/testStepsTemplate.yaml similarity index 100% rename from test_data/step_types/testStepsTemplate.yaml rename to testing/fixtures/testStepsTemplate.yaml From 65e19233cefa8cf07d4755542354ae668789d31f Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:34:41 -0400 Subject: [PATCH 3/7] Update scripts. --- .../test_cases/test_account_tokens/main.tf | 5 +++ .../test_cases/test_account_tokens/spec.json | 42 +++++++++++++++++++ .../test_account_user_associations/main.tf | 5 +++ .../test_account_user_associations/spec.json | 42 +++++++++++++++++++ .../test_cases/test_accounts_users/main.tf | 5 +++ .../test_cases/test_accounts_users/spec.json | 42 +++++++++++++++++++ .../test_cases/test_permissions/main.tf | 5 +++ .../test_cases/test_permissions/spec.json | 42 +++++++++++++++++++ .../test_cases/test_pipelines/main.tf | 5 +++ .../test_cases/test_pipelines/spec.json | 42 +++++++++++++++++++ .../test_cases/test_registries/main.tf | 5 +++ .../test_cases/test_registries/spec.json | 42 +++++++++++++++++++ .../test_storage_integration/main.tf | 5 +++ .../test_storage_integration/spec.json | 42 +++++++++++++++++++ .../equivalence/test_cases/test_teams/main.tf | 5 +++ .../test_cases/test_teams/spec.json | 42 +++++++++++++++++++ .../test_cases/test_triggers/main.tf | 5 +++ .../test_cases/test_triggers/spec.json | 42 +++++++++++++++++++ testing/equivalence/update-test-cases.sh | 8 ++-- 19 files changed, 427 insertions(+), 4 deletions(-) create mode 100644 testing/equivalence/test_cases/test_account_tokens/main.tf create mode 100644 testing/equivalence/test_cases/test_account_tokens/spec.json create mode 100644 testing/equivalence/test_cases/test_account_user_associations/main.tf create mode 100644 testing/equivalence/test_cases/test_account_user_associations/spec.json create mode 100644 testing/equivalence/test_cases/test_accounts_users/main.tf create mode 100644 testing/equivalence/test_cases/test_accounts_users/spec.json create mode 100644 testing/equivalence/test_cases/test_permissions/main.tf create mode 100644 testing/equivalence/test_cases/test_permissions/spec.json create mode 100644 testing/equivalence/test_cases/test_pipelines/main.tf create mode 100644 testing/equivalence/test_cases/test_pipelines/spec.json create mode 100644 testing/equivalence/test_cases/test_registries/main.tf create mode 100644 testing/equivalence/test_cases/test_registries/spec.json create mode 100644 testing/equivalence/test_cases/test_storage_integration/main.tf create mode 100644 testing/equivalence/test_cases/test_storage_integration/spec.json create mode 100644 testing/equivalence/test_cases/test_teams/main.tf create mode 100644 testing/equivalence/test_cases/test_teams/spec.json create mode 100644 testing/equivalence/test_cases/test_triggers/main.tf create mode 100644 testing/equivalence/test_cases/test_triggers/spec.json diff --git a/testing/equivalence/test_cases/test_account_tokens/main.tf b/testing/equivalence/test_cases/test_account_tokens/main.tf new file mode 100644 index 00000000..84abd031 --- /dev/null +++ b/testing/equivalence/test_cases/test_account_tokens/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/account_tokens" +} diff --git a/testing/equivalence/test_cases/test_account_tokens/spec.json b/testing/equivalence/test_cases/test_account_tokens/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_account_tokens/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_account_user_associations/main.tf b/testing/equivalence/test_cases/test_account_user_associations/main.tf new file mode 100644 index 00000000..ba9eadd8 --- /dev/null +++ b/testing/equivalence/test_cases/test_account_user_associations/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/account_user_associations" +} diff --git a/testing/equivalence/test_cases/test_account_user_associations/spec.json b/testing/equivalence/test_cases/test_account_user_associations/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_account_user_associations/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_accounts_users/main.tf b/testing/equivalence/test_cases/test_accounts_users/main.tf new file mode 100644 index 00000000..c52a8eee --- /dev/null +++ b/testing/equivalence/test_cases/test_accounts_users/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/accounts_users" +} diff --git a/testing/equivalence/test_cases/test_accounts_users/spec.json b/testing/equivalence/test_cases/test_accounts_users/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_accounts_users/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_permissions/main.tf b/testing/equivalence/test_cases/test_permissions/main.tf new file mode 100644 index 00000000..6f42cc1c --- /dev/null +++ b/testing/equivalence/test_cases/test_permissions/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/permissions" +} diff --git a/testing/equivalence/test_cases/test_permissions/spec.json b/testing/equivalence/test_cases/test_permissions/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_permissions/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_pipelines/main.tf b/testing/equivalence/test_cases/test_pipelines/main.tf new file mode 100644 index 00000000..6e7e2f97 --- /dev/null +++ b/testing/equivalence/test_cases/test_pipelines/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/pipelines" +} diff --git a/testing/equivalence/test_cases/test_pipelines/spec.json b/testing/equivalence/test_cases/test_pipelines/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_pipelines/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_registries/main.tf b/testing/equivalence/test_cases/test_registries/main.tf new file mode 100644 index 00000000..5bad0646 --- /dev/null +++ b/testing/equivalence/test_cases/test_registries/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/registries" +} diff --git a/testing/equivalence/test_cases/test_registries/spec.json b/testing/equivalence/test_cases/test_registries/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_registries/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_storage_integration/main.tf b/testing/equivalence/test_cases/test_storage_integration/main.tf new file mode 100644 index 00000000..c0950d3c --- /dev/null +++ b/testing/equivalence/test_cases/test_storage_integration/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/storage_integration" +} diff --git a/testing/equivalence/test_cases/test_storage_integration/spec.json b/testing/equivalence/test_cases/test_storage_integration/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_storage_integration/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_teams/main.tf b/testing/equivalence/test_cases/test_teams/main.tf new file mode 100644 index 00000000..dd480977 --- /dev/null +++ b/testing/equivalence/test_cases/test_teams/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/teams" +} diff --git a/testing/equivalence/test_cases/test_teams/spec.json b/testing/equivalence/test_cases/test_teams/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_teams/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/test_cases/test_triggers/main.tf b/testing/equivalence/test_cases/test_triggers/main.tf new file mode 100644 index 00000000..cf12ac21 --- /dev/null +++ b/testing/equivalence/test_cases/test_triggers/main.tf @@ -0,0 +1,5 @@ +# DO NOT EDIT +# This file is automatically generated by update-test-cases.sh +module test { + source = "../../../../examples/triggers" +} diff --git a/testing/equivalence/test_cases/test_triggers/spec.json b/testing/equivalence/test_cases/test_triggers/spec.json new file mode 100644 index 00000000..194a11b3 --- /dev/null +++ b/testing/equivalence/test_cases/test_triggers/spec.json @@ -0,0 +1,42 @@ +{ + "ignore_fields": { + "plan.json": ["errored"] + }, + "commands": [ + { + "name": "init", + "arguments": ["init", "-plugin-dir=../../.plugins"], + "capture_output": false + }, + { + "name": "plan", + "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], + "capture_output": true, + "output_file_name": "plan", + "has_json_output": false + }, + { + "name": "state", + "arguments": ["show", "-no-color"], + "capture_output": true, + "output_file_name": "state", + "has_json_output": false + }, + { + "name": "show_state", + "arguments": ["show", "-json"], + "capture_output": true, + "output_file_name": "state.json", + "has_json_output": true, + "streams_json_output": false + }, + { + "name": "show_plan", + "arguments": ["show", "-json", "equivalence_test_plan"], + "capture_output": true, + "output_file_name": "plan.json", + "has_json_output": true, + "streams_json_output": false + } + ] +} diff --git a/testing/equivalence/update-test-cases.sh b/testing/equivalence/update-test-cases.sh index b2adb7dc..259c0c5b 100755 --- a/testing/equivalence/update-test-cases.sh +++ b/testing/equivalence/update-test-cases.sh @@ -18,15 +18,15 @@ if [[ ! -d ${test_case_dirname} ]]; then mkdir -p ${test_case_dirname} fi -for i in $(find $(dirname $(grealpath $0))/../../examples -mindepth 1 -prune -path '**/*/.*' -type d); do +for i in $(find $(dirname $(grealpath $0))/../../examples -mindepth 1 -maxdepth 1 -type d -not -path "**/.modules"); do print_style "Found example directory: " - print_style "${i}\n" + print_style "$(grealpath --relative-to=$(dirname $0) ${i})\n" expected_test_dir="$(dirname $(grealpath $0))/${test_case_dirname}/${test_case_prefix}$(basename ${i})" if [[ ! -d ${expected_test_dir} ]]; then - print_style " * creating missing directory " - print_sytle "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})\n" "warning" mkdir -p ${expected_test_dir} + print_style " * created missing directory " + print_style "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})\n" "warning" fi print_style " * updating " From 6743d68c7fd286ab580fd59b079b78f3e187e7b8 Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:08:02 -0400 Subject: [PATCH 4/7] Fix test comparison. --- GNUmakefile | 5 + examples/.modules/account_token/provider.tf | 4 - examples/.modules/account_token/vars.tf | 10 - examples/.modules/account_token/versions.tf | 8 + examples/.modules/account_tokens/provider.tf | 4 - examples/.modules/account_tokens/vars.tf | 11 - examples/.modules/account_tokens/versions.tf | 8 + examples/.modules/accounts_users/provider.tf | 4 - examples/.modules/accounts_users/versions.tf | 8 + examples/.modules/teams/vars.tf | 14 - examples/.modules/teams/versions.tf | 8 + examples/account_tokens/main.tf | 11 - examples/account_tokens/terraform.tfvars | 2 - examples/teams/main.tf | 4 + examples/teams/terraform.tfvars | 4 - testing/equivalence/compare-results.sh | 11 +- .../results/opentofu/test_abac_rules/plan | 2 +- .../test_account_user_associations/plan | 43 ++ .../test_account_user_associations/plan.json | 141 ++++ .../test_account_user_associations/state | 1 + .../test_account_user_associations/state.json | 3 + .../results/opentofu/test_pipelines/plan | 123 ++++ .../results/opentofu/test_pipelines/plan.json | 543 +++++++++++++++ .../results/opentofu/test_pipelines/state | 1 + .../opentofu/test_pipelines/state.json | 3 + .../opentofu/test_storage_integration/plan | 81 +++ .../test_storage_integration/plan.json | 610 +++++++++++++++++ .../opentofu/test_storage_integration/state | 1 + .../test_storage_integration/state.json | 3 + .../results/opentofu/test_triggers/plan | 143 ++++ .../results/opentofu/test_triggers/plan.json | 618 ++++++++++++++++++ .../results/opentofu/test_triggers/state | 1 + .../results/opentofu/test_triggers/state.json | 3 + .../results/terraform/test_abac_rules/plan | 2 +- .../test_account_user_associations/plan | 43 ++ .../test_account_user_associations/plan.json | 141 ++++ .../test_account_user_associations/state | 1 + .../test_account_user_associations/state.json | 3 + .../results/terraform/test_pipelines/plan | 123 ++++ .../terraform/test_pipelines/plan.json | 543 +++++++++++++++ .../results/terraform/test_pipelines/state | 1 + .../terraform/test_pipelines/state.json | 3 + .../terraform/test_storage_integration/plan | 81 +++ .../test_storage_integration/plan.json | 610 +++++++++++++++++ .../terraform/test_storage_integration/state | 1 + .../test_storage_integration/state.json | 3 + .../results/terraform/test_triggers/plan | 143 ++++ .../results/terraform/test_triggers/plan.json | 618 ++++++++++++++++++ .../results/terraform/test_triggers/state | 1 + .../terraform/test_triggers/state.json | 3 + testing/equivalence/rewrites.jsonc | 3 +- .../test_cases/test_account_tokens/main.tf | 5 - .../test_cases/test_account_tokens/spec.json | 42 -- .../test_cases/test_accounts_users/main.tf | 5 - .../test_cases/test_accounts_users/spec.json | 42 -- .../test_cases/test_permissions/main.tf | 5 - .../test_cases/test_permissions/spec.json | 42 -- .../test_cases/test_registries/main.tf | 5 - .../test_cases/test_registries/spec.json | 42 -- .../equivalence/test_cases/test_teams/main.tf | 5 - .../test_cases/test_teams/spec.json | 42 -- testing/equivalence/update-test-cases.sh | 16 + 62 files changed, 4705 insertions(+), 305 deletions(-) delete mode 100644 examples/.modules/account_token/provider.tf create mode 100644 examples/.modules/account_token/versions.tf delete mode 100644 examples/.modules/account_tokens/provider.tf create mode 100644 examples/.modules/account_tokens/versions.tf delete mode 100644 examples/.modules/accounts_users/provider.tf create mode 100644 examples/.modules/accounts_users/versions.tf create mode 100644 examples/.modules/teams/versions.tf delete mode 100644 examples/teams/terraform.tfvars create mode 100644 testing/equivalence/results/opentofu/test_account_user_associations/plan create mode 100644 testing/equivalence/results/opentofu/test_account_user_associations/plan.json create mode 100644 testing/equivalence/results/opentofu/test_account_user_associations/state create mode 100644 testing/equivalence/results/opentofu/test_account_user_associations/state.json create mode 100644 testing/equivalence/results/opentofu/test_pipelines/plan create mode 100644 testing/equivalence/results/opentofu/test_pipelines/plan.json create mode 100644 testing/equivalence/results/opentofu/test_pipelines/state create mode 100644 testing/equivalence/results/opentofu/test_pipelines/state.json create mode 100644 testing/equivalence/results/opentofu/test_storage_integration/plan create mode 100644 testing/equivalence/results/opentofu/test_storage_integration/plan.json create mode 100644 testing/equivalence/results/opentofu/test_storage_integration/state create mode 100644 testing/equivalence/results/opentofu/test_storage_integration/state.json create mode 100644 testing/equivalence/results/opentofu/test_triggers/plan create mode 100644 testing/equivalence/results/opentofu/test_triggers/plan.json create mode 100644 testing/equivalence/results/opentofu/test_triggers/state create mode 100644 testing/equivalence/results/opentofu/test_triggers/state.json create mode 100644 testing/equivalence/results/terraform/test_account_user_associations/plan create mode 100644 testing/equivalence/results/terraform/test_account_user_associations/plan.json create mode 100644 testing/equivalence/results/terraform/test_account_user_associations/state create mode 100644 testing/equivalence/results/terraform/test_account_user_associations/state.json create mode 100644 testing/equivalence/results/terraform/test_pipelines/plan create mode 100644 testing/equivalence/results/terraform/test_pipelines/plan.json create mode 100644 testing/equivalence/results/terraform/test_pipelines/state create mode 100644 testing/equivalence/results/terraform/test_pipelines/state.json create mode 100644 testing/equivalence/results/terraform/test_storage_integration/plan create mode 100644 testing/equivalence/results/terraform/test_storage_integration/plan.json create mode 100644 testing/equivalence/results/terraform/test_storage_integration/state create mode 100644 testing/equivalence/results/terraform/test_storage_integration/state.json create mode 100644 testing/equivalence/results/terraform/test_triggers/plan create mode 100644 testing/equivalence/results/terraform/test_triggers/plan.json create mode 100644 testing/equivalence/results/terraform/test_triggers/state create mode 100644 testing/equivalence/results/terraform/test_triggers/state.json delete mode 100644 testing/equivalence/test_cases/test_account_tokens/main.tf delete mode 100644 testing/equivalence/test_cases/test_account_tokens/spec.json delete mode 100644 testing/equivalence/test_cases/test_accounts_users/main.tf delete mode 100644 testing/equivalence/test_cases/test_accounts_users/spec.json delete mode 100644 testing/equivalence/test_cases/test_permissions/main.tf delete mode 100644 testing/equivalence/test_cases/test_permissions/spec.json delete mode 100644 testing/equivalence/test_cases/test_registries/main.tf delete mode 100644 testing/equivalence/test_cases/test_registries/spec.json delete mode 100644 testing/equivalence/test_cases/test_teams/main.tf delete mode 100644 testing/equivalence/test_cases/test_teams/spec.json diff --git a/GNUmakefile b/GNUmakefile index d2bdb0b6..8fff5f7d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -37,6 +37,11 @@ equivalence: build @echo "==> Running equivalence tests for opentofu" cd testing/equivalence;\ equivalence-testing update --binary=$$(which tofu) --goldens=results/opentofu --tests=test_cases --rewrites=rewrites.jsonc + + @echo "==> Comparing results" + cd testing/equivalence;\ + ./compare-results.sh;\ + fmt: @echo "==> Fixing source code with gofmt..." gofmt -s -w $(GOFMT_FILES) diff --git a/examples/.modules/account_token/provider.tf b/examples/.modules/account_token/provider.tf deleted file mode 100644 index 615d72a3..00000000 --- a/examples/.modules/account_token/provider.tf +++ /dev/null @@ -1,4 +0,0 @@ -provider "codefresh" { - api_url = var.api_url - token = var.token -} \ No newline at end of file diff --git a/examples/.modules/account_token/vars.tf b/examples/.modules/account_token/vars.tf index 94f55e9b..55ae8a04 100644 --- a/examples/.modules/account_token/vars.tf +++ b/examples/.modules/account_token/vars.tf @@ -1,13 +1,3 @@ -variable api_url { - type = string -} - -# -variable token { - type = string - default = "" -} - variable account_id { type = string default = "" diff --git a/examples/.modules/account_token/versions.tf b/examples/.modules/account_token/versions.tf new file mode 100644 index 00000000..2f55b54c --- /dev/null +++ b/examples/.modules/account_token/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + codefresh = { + source = "registry.terraform.io/codefresh-io/codefresh" + version = "~> 0.1" + } + } +} \ No newline at end of file diff --git a/examples/.modules/account_tokens/provider.tf b/examples/.modules/account_tokens/provider.tf deleted file mode 100644 index 45289179..00000000 --- a/examples/.modules/account_tokens/provider.tf +++ /dev/null @@ -1,4 +0,0 @@ -provider "codefresh" { - api_url = var.api_url - token = var.admin_token -} \ No newline at end of file diff --git a/examples/.modules/account_tokens/vars.tf b/examples/.modules/account_tokens/vars.tf index a2370424..0e5aacbf 100644 --- a/examples/.modules/account_tokens/vars.tf +++ b/examples/.modules/account_tokens/vars.tf @@ -1,14 +1,3 @@ -variable api_url { - type = string -} - -# -variable admin_token { - type = string - default = "" -} - - ## Set of account names variable accounts { type = set(string) diff --git a/examples/.modules/account_tokens/versions.tf b/examples/.modules/account_tokens/versions.tf new file mode 100644 index 00000000..2f55b54c --- /dev/null +++ b/examples/.modules/account_tokens/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + codefresh = { + source = "registry.terraform.io/codefresh-io/codefresh" + version = "~> 0.1" + } + } +} \ No newline at end of file diff --git a/examples/.modules/accounts_users/provider.tf b/examples/.modules/accounts_users/provider.tf deleted file mode 100644 index 615d72a3..00000000 --- a/examples/.modules/accounts_users/provider.tf +++ /dev/null @@ -1,4 +0,0 @@ -provider "codefresh" { - api_url = var.api_url - token = var.token -} \ No newline at end of file diff --git a/examples/.modules/accounts_users/versions.tf b/examples/.modules/accounts_users/versions.tf new file mode 100644 index 00000000..2f55b54c --- /dev/null +++ b/examples/.modules/accounts_users/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + codefresh = { + source = "registry.terraform.io/codefresh-io/codefresh" + version = "~> 0.1" + } + } +} \ No newline at end of file diff --git a/examples/.modules/teams/vars.tf b/examples/.modules/teams/vars.tf index a69a9807..9fa74db5 100644 --- a/examples/.modules/teams/vars.tf +++ b/examples/.modules/teams/vars.tf @@ -1,17 +1,3 @@ -# variable api_url { -# type = string -# } - -# variable token { -# type = string -# default = "" -# } - -# teams map[team_name]usersList -# { -# developers = ["user1", "user3"] -# managers = ["user3", "user2"] -# } variable teams { type = map(any) } diff --git a/examples/.modules/teams/versions.tf b/examples/.modules/teams/versions.tf new file mode 100644 index 00000000..2f55b54c --- /dev/null +++ b/examples/.modules/teams/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + codefresh = { + source = "registry.terraform.io/codefresh-io/codefresh" + version = "~> 0.1" + } + } +} \ No newline at end of file diff --git a/examples/account_tokens/main.tf b/examples/account_tokens/main.tf index a65de1aa..66aff2ef 100644 --- a/examples/account_tokens/main.tf +++ b/examples/account_tokens/main.tf @@ -1,13 +1,3 @@ -variable "api_url" { - type = string -} - -# -variable "token" { - type = string - default = "" -} - ## Set of account names variable "accounts" { type = set(string) @@ -15,7 +5,6 @@ variable "accounts" { module "account_tokens" { source = "../.modules/account_tokens" - api_url = var.api_url accounts = var.accounts } diff --git a/examples/account_tokens/terraform.tfvars b/examples/account_tokens/terraform.tfvars index a395df29..c5df65aa 100644 --- a/examples/account_tokens/terraform.tfvars +++ b/examples/account_tokens/terraform.tfvars @@ -1,5 +1,3 @@ -api_url = "https://my-codefresh-example.com/api" - accounts = [ "acc1", "acc2" ] \ No newline at end of file diff --git a/examples/teams/main.tf b/examples/teams/main.tf index fb7eb9bb..5e6cccc9 100644 --- a/examples/teams/main.tf +++ b/examples/teams/main.tf @@ -1,5 +1,9 @@ variable "teams" { type = map(any) + default = { + developers = ["user1", "user3"] + managers = ["user3", "user2"] + } } module "teams" { diff --git a/examples/teams/terraform.tfvars b/examples/teams/terraform.tfvars deleted file mode 100644 index e2917e23..00000000 --- a/examples/teams/terraform.tfvars +++ /dev/null @@ -1,4 +0,0 @@ -teams = { - developers = ["user1", "user3"] - managers = ["user3", "user2"] -} \ No newline at end of file diff --git a/testing/equivalence/compare-results.sh b/testing/equivalence/compare-results.sh index df868eda..9ec393b5 100755 --- a/testing/equivalence/compare-results.sh +++ b/testing/equivalence/compare-results.sh @@ -2,7 +2,7 @@ source $(realpath $(dirname $0))/lib.sh -for i in $(find $(realpath $(dirname $0))/results/terraform -mindepth 1 -not -path '**/*/.*' -type d); do +for i in $(find $(realpath $(dirname $0))/results/terraform -mindepth 1 -maxdepth 1 -type d); do test_case_name=$(basename ${i}) print_style "Test case " print_style "${test_case_name}" "info" @@ -13,9 +13,14 @@ for i in $(find $(realpath $(dirname $0))/results/terraform -mindepth 1 -not -pa print_style " and " print_style "results/opentofu/$(basename ${f})" "info" print_style ": " + + terraform_file=$(realpath $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) + opentofu_file=$(realpath $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) + + # We normalize the JSON output to make them comparable regardless of key order diff \ - $(realpath $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) \ - $(realpath $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) \ + <(cat $terraform_file | jq -reM '""' 2>/dev/null || cat $terraform_file) \ + <(cat $terraform_file | jq -reM '""' 2>/dev/null || cat $opentofu_file) \ || print_style "FAILED\n" "danger" \ && print_style "PASS\n" "success" done diff --git a/testing/equivalence/results/opentofu/test_abac_rules/plan b/testing/equivalence/results/opentofu/test_abac_rules/plan index a23a8275..8ba1aea9 100644 --- a/testing/equivalence/results/opentofu/test_abac_rules/plan +++ b/testing/equivalence/results/opentofu/test_abac_rules/plan @@ -9,7 +9,7 @@ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases. module.test.data.codefresh_team.users: Reading... -module.test.data.codefresh_team.users: Read complete after 0s [id=64050eece8e7a480941d22b2] +module.test.data.codefresh_team.users: Read complete after xs [id=64050eece8e7a480941d22b2] OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: diff --git a/testing/equivalence/results/opentofu/test_account_user_associations/plan b/testing/equivalence/results/opentofu/test_account_user_associations/plan new file mode 100644 index 00000000..29a220ef --- /dev/null +++ b/testing/equivalence/results/opentofu/test_account_user_associations/plan @@ -0,0 +1,43 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_account_user_association.admin will be created + + resource "codefresh_account_user_association" "admin" { + + admin = true + + email = "tofu-test-user+admin@codefresh.io" + + id = (known after apply) + + status = (known after apply) + + username = (known after apply) + } + + # module.test.codefresh_account_user_association.user will be created + + resource "codefresh_account_user_association" "user" { + + admin = false + + email = "tofu-test-user+user@codefresh.io" + + id = (known after apply) + + status = (known after apply) + + username = (known after apply) + } + +Plan: 2 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/opentofu/test_account_user_associations/plan.json b/testing/equivalence/results/opentofu/test_account_user_associations/plan.json new file mode 100644 index 00000000..425f563a --- /dev/null +++ b/testing/equivalence/results/opentofu/test_account_user_associations/plan.json @@ -0,0 +1,141 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "resources": [ + { + "address": "codefresh_account_user_association.admin", + "expressions": { + "admin": { + "constant_value": true + }, + "email": { + "constant_value": "terraform-test-user+admin@codefresh.io" + } + }, + "mode": "managed", + "name": "admin", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_account_user_association" + }, + { + "address": "codefresh_account_user_association.user", + "expressions": { + "email": { + "constant_value": "terraform-test-user+user@codefresh.io" + } + }, + "mode": "managed", + "name": "user", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_account_user_association" + } + ] + }, + "source": "../../../../examples/account_user_associations" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_account_user_association.admin", + "mode": "managed", + "name": "admin", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": {}, + "type": "codefresh_account_user_association", + "values": { + "admin": true, + "email": "terraform-test-user+admin@codefresh.io" + } + }, + { + "address": "module.test.codefresh_account_user_association.user", + "mode": "managed", + "name": "user", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": {}, + "type": "codefresh_account_user_association", + "values": { + "admin": false, + "email": "terraform-test-user+user@codefresh.io" + } + } + ] + } + ] + } + }, + "resource_changes": [ + { + "address": "module.test.codefresh_account_user_association.admin", + "change": { + "actions": [ + "create" + ], + "after": { + "admin": true, + "email": "terraform-test-user+admin@codefresh.io" + }, + "after_sensitive": {}, + "after_unknown": { + "id": true, + "status": true, + "username": true + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "admin", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_account_user_association" + }, + { + "address": "module.test.codefresh_account_user_association.user", + "change": { + "actions": [ + "create" + ], + "after": { + "admin": false, + "email": "terraform-test-user+user@codefresh.io" + }, + "after_sensitive": {}, + "after_unknown": { + "id": true, + "status": true, + "username": true + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "user", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_account_user_association" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_account_user_associations/state b/testing/equivalence/results/opentofu/test_account_user_associations/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/opentofu/test_account_user_associations/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/opentofu/test_account_user_associations/state.json b/testing/equivalence/results/opentofu/test_account_user_associations/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/opentofu/test_account_user_associations/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_pipelines/plan b/testing/equivalence/results/opentofu/test_pipelines/plan new file mode 100644 index 00000000..f9d3d51c --- /dev/null +++ b/testing/equivalence/results/opentofu/test_pipelines/plan @@ -0,0 +1,123 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_pipeline.test will be created + + resource "codefresh_pipeline" "test" { + + id = (known after apply) + + is_public = false + + name = "myproject/react-sample-app" + + original_yaml_string = <<-EOT + version: "1.0" + hooks: + on_finish: + steps: + b: + image: alpine:3.9 + commands: + - echo "echo cleanup step" + a: + image: cloudposse/slack-notifier + commands: + - echo "Notify slack" + steps: + freestyle: + image: alpine + commands: + - sleep 10 + a_freestyle: + image: alpine + commands: + - sleep 10 + - echo Hey! + arguments: + c: 3 + a: 1 + b: 2 + EOT + + project_id = (known after apply) + + revision = (known after apply) + + tags = [ + + "docker", + + "production", + ] + + + spec { + + branch_concurrency = 0 + + concurrency = 1 + + contexts = [ + + "context1-name", + + "context2-name", + ] + + priority = 5 + + trigger_concurrency = 0 + + variables = { + + "ANOTHER_PIP_VAR" = "another_value" + + "MY_PIP_VAR" = "value" + } + + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for commits" + + disabled = false + + events = [ + + "push.heads", + ] + + name = "commits" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for tags" + + disabled = false + + events = [ + + "push.tags", + ] + + name = "tags" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + } + } + + # module.test.codefresh_project.test will be created + + resource "codefresh_project" "test" { + + id = (known after apply) + + name = "myproject" + + tags = [ + + "docker", + ] + } + +Plan: 2 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/opentofu/test_pipelines/plan.json b/testing/equivalence/results/opentofu/test_pipelines/plan.json new file mode 100644 index 00000000..c26d3e95 --- /dev/null +++ b/testing/equivalence/results/opentofu/test_pipelines/plan.json @@ -0,0 +1,543 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "outputs": { + "id": { + "expression": { + "references": [ + "codefresh_pipeline.test.id", + "codefresh_pipeline.test" + ] + } + } + }, + "resources": [ + { + "address": "codefresh_pipeline.test", + "expressions": { + "name": { + "references": [ + "codefresh_project.test.name", + "codefresh_project.test" + ] + }, + "original_yaml_string": { + "constant_value": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n" + }, + "spec": [ + { + "concurrency": { + "constant_value": 1 + }, + "contexts": { + "constant_value": [ + "context1-name", + "context2-name" + ] + }, + "priority": { + "constant_value": 5 + }, + "trigger": [ + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for commits" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.heads" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "commits" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + }, + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for tags" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.tags" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "tags" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + } + ], + "variables": { + "constant_value": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + } + ], + "tags": { + "constant_value": [ + "production", + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_pipeline" + }, + { + "address": "codefresh_project.test", + "expressions": { + "name": { + "constant_value": "myproject" + }, + "tags": { + "constant_value": [ + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_project" + } + ] + }, + "source": "../../../../examples/pipelines" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_pipeline.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "type": "codefresh_pipeline", + "values": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + } + }, + { + "address": "module.test.codefresh_project.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "tags": [ + false + ] + }, + "type": "codefresh_project", + "values": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + } + } + ] + } + ] + } + }, + "relevant_attributes": [ + { + "attribute": [ + "id" + ], + "resource": "module.test.codefresh_pipeline.test" + }, + { + "attribute": [ + "name" + ], + "resource": "module.test.codefresh_project.test" + } + ], + "resource_changes": [ + { + "address": "module.test.codefresh_pipeline.test", + "change": { + "actions": [ + "create" + ], + "after": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + }, + "after_sensitive": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "after_unknown": { + "id": true, + "project_id": true, + "revision": true, + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_pipeline" + }, + { + "address": "module.test.codefresh_project.test", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + }, + "after_sensitive": { + "tags": [ + false + ] + }, + "after_unknown": { + "id": true, + "tags": [ + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_project" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_pipelines/state b/testing/equivalence/results/opentofu/test_pipelines/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/opentofu/test_pipelines/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/opentofu/test_pipelines/state.json b/testing/equivalence/results/opentofu/test_pipelines/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/opentofu/test_pipelines/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_storage_integration/plan b/testing/equivalence/results/opentofu/test_storage_integration/plan new file mode 100644 index 00000000..4c8e26a9 --- /dev/null +++ b/testing/equivalence/results/opentofu/test_storage_integration/plan @@ -0,0 +1,81 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_context.azure["create"] will be created + + resource "codefresh_context" "azure" { + + id = (known after apply) + + name = "azure" + + + spec { + + storageazuref { + + data { + + auth { + + account_key = "accKey" + + account_name = "accName" + + type = "basic" + } + } + } + } + } + + # module.test.codefresh_context.gcs["create"] will be created + + resource "codefresh_context" "gcs" { + + id = (known after apply) + + name = "gcs" + + + spec { + + storagegc { + + data { + + auth { + + json_config = { + + "config" = "cf" + } + + type = "basic" + } + } + } + } + } + + # module.test.codefresh_context.s3["create"] will be created + + resource "codefresh_context" "s3" { + + id = (known after apply) + + name = "s3" + + + spec { + + storages3 { + + data { + + auth { + + json_config = { + + "config" = "cf" + } + + type = "basic" + } + } + } + } + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/opentofu/test_storage_integration/plan.json b/testing/equivalence/results/opentofu/test_storage_integration/plan.json new file mode 100644 index 00000000..f73b8205 --- /dev/null +++ b/testing/equivalence/results/opentofu/test_storage_integration/plan.json @@ -0,0 +1,610 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "resources": [ + { + "address": "codefresh_context.azure", + "expressions": { + "name": { + "constant_value": "azure" + }, + "spec": [ + { + "storageazuref": [ + { + "data": [ + { + "auth": [ + { + "account_key": { + "constant_value": "accKey" + }, + "account_name": { + "constant_value": "accName" + }, + "type": { + "constant_value": "basic" + } + } + ] + } + ] + } + ] + } + ] + }, + "mode": "managed", + "name": "azure", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_context" + }, + { + "address": "codefresh_context.gcs", + "expressions": { + "name": { + "constant_value": "gcs" + }, + "spec": [ + { + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {}, + "type": { + "constant_value": "basic" + } + } + ] + } + ] + } + ] + } + ] + }, + "mode": "managed", + "name": "gcs", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_context" + }, + { + "address": "codefresh_context.s3", + "expressions": { + "name": { + "constant_value": "s3" + }, + "spec": [ + { + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {}, + "type": { + "constant_value": "basic" + } + } + ] + } + ] + } + ] + } + ] + }, + "mode": "managed", + "name": "s3", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_context" + } + ] + }, + "source": "../../../../examples/storage_integration" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_context.azure[\"create\"]", + "index": "create", + "mode": "managed", + "name": "azure", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + {} + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "type": "codefresh_context", + "values": { + "name": "azure", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + { + "account_key": "accKey", + "account_name": "accName", + "type": "basic" + } + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + } + }, + { + "address": "module.test.codefresh_context.gcs[\"create\"]", + "index": "create", + "mode": "managed", + "name": "gcs", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "type": "codefresh_context", + "values": { + "name": "gcs", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + } + }, + { + "address": "module.test.codefresh_context.s3[\"create\"]", + "index": "create", + "mode": "managed", + "name": "s3", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "type": "codefresh_context", + "values": { + "name": "s3", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "yaml": [] + } + ] + } + } + ] + } + ] + } + }, + "resource_changes": [ + { + "address": "module.test.codefresh_context.azure[\"create\"]", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "azure", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + { + "account_key": "accKey", + "account_name": "accName", + "type": "basic" + } + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "after_sensitive": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + {} + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "after_unknown": { + "id": true, + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + {} + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "before": null, + "before_sensitive": false + }, + "index": "create", + "mode": "managed", + "module_address": "module.test", + "name": "azure", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_context" + }, + { + "address": "module.test.codefresh_context.gcs[\"create\"]", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "gcs", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "after_sensitive": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "after_unknown": { + "id": true, + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "before": null, + "before_sensitive": false + }, + "index": "create", + "mode": "managed", + "module_address": "module.test", + "name": "gcs", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_context" + }, + { + "address": "module.test.codefresh_context.s3[\"create\"]", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "s3", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "after_sensitive": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "after_unknown": { + "id": true, + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "before": null, + "before_sensitive": false + }, + "index": "create", + "mode": "managed", + "module_address": "module.test", + "name": "s3", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_context" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_storage_integration/state b/testing/equivalence/results/opentofu/test_storage_integration/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/opentofu/test_storage_integration/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/opentofu/test_storage_integration/state.json b/testing/equivalence/results/opentofu/test_storage_integration/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/opentofu/test_storage_integration/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_triggers/plan b/testing/equivalence/results/opentofu/test_triggers/plan new file mode 100644 index 00000000..99257419 --- /dev/null +++ b/testing/equivalence/results/opentofu/test_triggers/plan @@ -0,0 +1,143 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_pipeline_cron_trigger.default will be created + + resource "codefresh_pipeline_cron_trigger" "default" { + + expression = "0 0 2 ? * MON-FRI" + + id = (known after apply) + + message = "test" + + pipeline_id = (known after apply) + } + + # module.test.module.pipeline.codefresh_pipeline.test will be created + + resource "codefresh_pipeline" "test" { + + id = (known after apply) + + is_public = false + + name = "myproject/react-sample-app" + + original_yaml_string = <<-EOT + version: "1.0" + hooks: + on_finish: + steps: + b: + image: alpine:3.9 + commands: + - echo "echo cleanup step" + a: + image: cloudposse/slack-notifier + commands: + - echo "Notify slack" + steps: + freestyle: + image: alpine + commands: + - sleep 10 + a_freestyle: + image: alpine + commands: + - sleep 10 + - echo Hey! + arguments: + c: 3 + a: 1 + b: 2 + EOT + + project_id = (known after apply) + + revision = (known after apply) + + tags = [ + + "docker", + + "production", + ] + + + spec { + + branch_concurrency = 0 + + concurrency = 1 + + contexts = [ + + "context1-name", + + "context2-name", + ] + + priority = 5 + + trigger_concurrency = 0 + + variables = { + + "ANOTHER_PIP_VAR" = "another_value" + + "MY_PIP_VAR" = "value" + } + + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for commits" + + disabled = false + + events = [ + + "push.heads", + ] + + name = "commits" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for tags" + + disabled = false + + events = [ + + "push.tags", + ] + + name = "tags" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + } + } + + # module.test.module.pipeline.codefresh_project.test will be created + + resource "codefresh_project" "test" { + + id = (known after apply) + + name = "myproject" + + tags = [ + + "docker", + ] + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Warning: Deprecated Resource + + with module.test.codefresh_pipeline_cron_trigger.default, + on ../../../../examples/triggers/main.tf line 5, in resource "codefresh_pipeline_cron_trigger" "default": + 5: resource "codefresh_pipeline_cron_trigger" "default" { + +This resource is deprecated and will be removed in a future version of the +Codefresh OpenTofu provider. Please use the cron_triggers attribute of the +codefresh_pipeline resource instead. + +(and one more similar warning elsewhere) + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/opentofu/test_triggers/plan.json b/testing/equivalence/results/opentofu/test_triggers/plan.json new file mode 100644 index 00000000..acbf8fc1 --- /dev/null +++ b/testing/equivalence/results/opentofu/test_triggers/plan.json @@ -0,0 +1,618 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "module_calls": { + "pipeline": { + "module": { + "outputs": { + "id": { + "expression": { + "references": [ + "codefresh_pipeline.test.id", + "codefresh_pipeline.test" + ] + } + } + }, + "resources": [ + { + "address": "codefresh_pipeline.test", + "expressions": { + "name": { + "references": [ + "codefresh_project.test.name", + "codefresh_project.test" + ] + }, + "original_yaml_string": { + "constant_value": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n" + }, + "spec": [ + { + "concurrency": { + "constant_value": 1 + }, + "contexts": { + "constant_value": [ + "context1-name", + "context2-name" + ] + }, + "priority": { + "constant_value": 5 + }, + "trigger": [ + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for commits" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.heads" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "commits" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + }, + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for tags" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.tags" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "tags" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + } + ], + "variables": { + "constant_value": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + } + ], + "tags": { + "constant_value": [ + "production", + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_pipeline" + }, + { + "address": "codefresh_project.test", + "expressions": { + "name": { + "constant_value": "myproject" + }, + "tags": { + "constant_value": [ + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_project" + } + ] + }, + "source": "../pipelines" + } + }, + "resources": [ + { + "address": "codefresh_pipeline_cron_trigger.default", + "expressions": { + "expression": { + "constant_value": "0 0 2 ? * MON-FRI" + }, + "message": { + "constant_value": "test" + }, + "pipeline_id": { + "references": [ + "module.pipeline.id", + "module.pipeline" + ] + } + }, + "mode": "managed", + "name": "default", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_pipeline_cron_trigger" + } + ] + }, + "source": "../../../../examples/triggers" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "child_modules": [ + { + "address": "module.test.module.pipeline", + "resources": [ + { + "address": "module.test.module.pipeline.codefresh_pipeline.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "type": "codefresh_pipeline", + "values": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + } + }, + { + "address": "module.test.module.pipeline.codefresh_project.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "tags": [ + false + ] + }, + "type": "codefresh_project", + "values": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + } + } + ] + } + ], + "resources": [ + { + "address": "module.test.codefresh_pipeline_cron_trigger.default", + "mode": "managed", + "name": "default", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": {}, + "type": "codefresh_pipeline_cron_trigger", + "values": { + "expression": "0 0 2 ? * MON-FRI", + "message": "test" + } + } + ] + } + ] + } + }, + "relevant_attributes": [ + { + "attribute": [ + "id" + ], + "resource": "module.test.module.pipeline.codefresh_pipeline.test" + }, + { + "attribute": [ + "name" + ], + "resource": "module.test.module.pipeline.codefresh_project.test" + } + ], + "resource_changes": [ + { + "address": "module.test.codefresh_pipeline_cron_trigger.default", + "change": { + "actions": [ + "create" + ], + "after": { + "expression": "0 0 2 ? * MON-FRI", + "message": "test" + }, + "after_sensitive": {}, + "after_unknown": { + "id": true, + "pipeline_id": true + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "default", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_pipeline_cron_trigger" + }, + { + "address": "module.test.module.pipeline.codefresh_pipeline.test", + "change": { + "actions": [ + "create" + ], + "after": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + }, + "after_sensitive": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "after_unknown": { + "id": true, + "project_id": true, + "revision": true, + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test.module.pipeline", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_pipeline" + }, + { + "address": "module.test.module.pipeline.codefresh_project.test", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + }, + "after_sensitive": { + "tags": [ + false + ] + }, + "after_unknown": { + "id": true, + "tags": [ + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test.module.pipeline", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_project" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/opentofu/test_triggers/state b/testing/equivalence/results/opentofu/test_triggers/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/opentofu/test_triggers/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/opentofu/test_triggers/state.json b/testing/equivalence/results/opentofu/test_triggers/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/opentofu/test_triggers/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_abac_rules/plan b/testing/equivalence/results/terraform/test_abac_rules/plan index a23a8275..8ba1aea9 100644 --- a/testing/equivalence/results/terraform/test_abac_rules/plan +++ b/testing/equivalence/results/terraform/test_abac_rules/plan @@ -9,7 +9,7 @@ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases. module.test.data.codefresh_team.users: Reading... -module.test.data.codefresh_team.users: Read complete after 0s [id=64050eece8e7a480941d22b2] +module.test.data.codefresh_team.users: Read complete after xs [id=64050eece8e7a480941d22b2] OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: diff --git a/testing/equivalence/results/terraform/test_account_user_associations/plan b/testing/equivalence/results/terraform/test_account_user_associations/plan new file mode 100644 index 00000000..29a220ef --- /dev/null +++ b/testing/equivalence/results/terraform/test_account_user_associations/plan @@ -0,0 +1,43 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_account_user_association.admin will be created + + resource "codefresh_account_user_association" "admin" { + + admin = true + + email = "tofu-test-user+admin@codefresh.io" + + id = (known after apply) + + status = (known after apply) + + username = (known after apply) + } + + # module.test.codefresh_account_user_association.user will be created + + resource "codefresh_account_user_association" "user" { + + admin = false + + email = "tofu-test-user+user@codefresh.io" + + id = (known after apply) + + status = (known after apply) + + username = (known after apply) + } + +Plan: 2 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/terraform/test_account_user_associations/plan.json b/testing/equivalence/results/terraform/test_account_user_associations/plan.json new file mode 100644 index 00000000..425f563a --- /dev/null +++ b/testing/equivalence/results/terraform/test_account_user_associations/plan.json @@ -0,0 +1,141 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "resources": [ + { + "address": "codefresh_account_user_association.admin", + "expressions": { + "admin": { + "constant_value": true + }, + "email": { + "constant_value": "terraform-test-user+admin@codefresh.io" + } + }, + "mode": "managed", + "name": "admin", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_account_user_association" + }, + { + "address": "codefresh_account_user_association.user", + "expressions": { + "email": { + "constant_value": "terraform-test-user+user@codefresh.io" + } + }, + "mode": "managed", + "name": "user", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_account_user_association" + } + ] + }, + "source": "../../../../examples/account_user_associations" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_account_user_association.admin", + "mode": "managed", + "name": "admin", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": {}, + "type": "codefresh_account_user_association", + "values": { + "admin": true, + "email": "terraform-test-user+admin@codefresh.io" + } + }, + { + "address": "module.test.codefresh_account_user_association.user", + "mode": "managed", + "name": "user", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": {}, + "type": "codefresh_account_user_association", + "values": { + "admin": false, + "email": "terraform-test-user+user@codefresh.io" + } + } + ] + } + ] + } + }, + "resource_changes": [ + { + "address": "module.test.codefresh_account_user_association.admin", + "change": { + "actions": [ + "create" + ], + "after": { + "admin": true, + "email": "terraform-test-user+admin@codefresh.io" + }, + "after_sensitive": {}, + "after_unknown": { + "id": true, + "status": true, + "username": true + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "admin", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_account_user_association" + }, + { + "address": "module.test.codefresh_account_user_association.user", + "change": { + "actions": [ + "create" + ], + "after": { + "admin": false, + "email": "terraform-test-user+user@codefresh.io" + }, + "after_sensitive": {}, + "after_unknown": { + "id": true, + "status": true, + "username": true + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "user", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_account_user_association" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_account_user_associations/state b/testing/equivalence/results/terraform/test_account_user_associations/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/terraform/test_account_user_associations/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/terraform/test_account_user_associations/state.json b/testing/equivalence/results/terraform/test_account_user_associations/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/terraform/test_account_user_associations/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_pipelines/plan b/testing/equivalence/results/terraform/test_pipelines/plan new file mode 100644 index 00000000..f9d3d51c --- /dev/null +++ b/testing/equivalence/results/terraform/test_pipelines/plan @@ -0,0 +1,123 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_pipeline.test will be created + + resource "codefresh_pipeline" "test" { + + id = (known after apply) + + is_public = false + + name = "myproject/react-sample-app" + + original_yaml_string = <<-EOT + version: "1.0" + hooks: + on_finish: + steps: + b: + image: alpine:3.9 + commands: + - echo "echo cleanup step" + a: + image: cloudposse/slack-notifier + commands: + - echo "Notify slack" + steps: + freestyle: + image: alpine + commands: + - sleep 10 + a_freestyle: + image: alpine + commands: + - sleep 10 + - echo Hey! + arguments: + c: 3 + a: 1 + b: 2 + EOT + + project_id = (known after apply) + + revision = (known after apply) + + tags = [ + + "docker", + + "production", + ] + + + spec { + + branch_concurrency = 0 + + concurrency = 1 + + contexts = [ + + "context1-name", + + "context2-name", + ] + + priority = 5 + + trigger_concurrency = 0 + + variables = { + + "ANOTHER_PIP_VAR" = "another_value" + + "MY_PIP_VAR" = "value" + } + + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for commits" + + disabled = false + + events = [ + + "push.heads", + ] + + name = "commits" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for tags" + + disabled = false + + events = [ + + "push.tags", + ] + + name = "tags" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + } + } + + # module.test.codefresh_project.test will be created + + resource "codefresh_project" "test" { + + id = (known after apply) + + name = "myproject" + + tags = [ + + "docker", + ] + } + +Plan: 2 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/terraform/test_pipelines/plan.json b/testing/equivalence/results/terraform/test_pipelines/plan.json new file mode 100644 index 00000000..71eea229 --- /dev/null +++ b/testing/equivalence/results/terraform/test_pipelines/plan.json @@ -0,0 +1,543 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "outputs": { + "id": { + "expression": { + "references": [ + "codefresh_pipeline.test.id", + "codefresh_pipeline.test" + ] + } + } + }, + "resources": [ + { + "address": "codefresh_pipeline.test", + "expressions": { + "name": { + "references": [ + "codefresh_project.test.name", + "codefresh_project.test" + ] + }, + "original_yaml_string": { + "constant_value": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n" + }, + "spec": [ + { + "concurrency": { + "constant_value": 1 + }, + "contexts": { + "constant_value": [ + "context1-name", + "context2-name" + ] + }, + "priority": { + "constant_value": 5 + }, + "trigger": [ + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for commits" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.heads" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "commits" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + }, + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for tags" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.tags" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "tags" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + } + ], + "variables": { + "constant_value": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + } + ], + "tags": { + "constant_value": [ + "production", + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_pipeline" + }, + { + "address": "codefresh_project.test", + "expressions": { + "name": { + "constant_value": "myproject" + }, + "tags": { + "constant_value": [ + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_project" + } + ] + }, + "source": "../../../../examples/pipelines" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_pipeline.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "type": "codefresh_pipeline", + "values": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + } + }, + { + "address": "module.test.codefresh_project.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "tags": [ + false + ] + }, + "type": "codefresh_project", + "values": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + } + } + ] + } + ] + } + }, + "relevant_attributes": [ + { + "attribute": [ + "name" + ], + "resource": "module.test.codefresh_project.test" + }, + { + "attribute": [ + "id" + ], + "resource": "module.test.codefresh_pipeline.test" + } + ], + "resource_changes": [ + { + "address": "module.test.codefresh_pipeline.test", + "change": { + "actions": [ + "create" + ], + "after": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + }, + "after_sensitive": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "after_unknown": { + "id": true, + "project_id": true, + "revision": true, + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_pipeline" + }, + { + "address": "module.test.codefresh_project.test", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + }, + "after_sensitive": { + "tags": [ + false + ] + }, + "after_unknown": { + "id": true, + "tags": [ + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_project" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_pipelines/state b/testing/equivalence/results/terraform/test_pipelines/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/terraform/test_pipelines/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/terraform/test_pipelines/state.json b/testing/equivalence/results/terraform/test_pipelines/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/terraform/test_pipelines/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_storage_integration/plan b/testing/equivalence/results/terraform/test_storage_integration/plan new file mode 100644 index 00000000..4c8e26a9 --- /dev/null +++ b/testing/equivalence/results/terraform/test_storage_integration/plan @@ -0,0 +1,81 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_context.azure["create"] will be created + + resource "codefresh_context" "azure" { + + id = (known after apply) + + name = "azure" + + + spec { + + storageazuref { + + data { + + auth { + + account_key = "accKey" + + account_name = "accName" + + type = "basic" + } + } + } + } + } + + # module.test.codefresh_context.gcs["create"] will be created + + resource "codefresh_context" "gcs" { + + id = (known after apply) + + name = "gcs" + + + spec { + + storagegc { + + data { + + auth { + + json_config = { + + "config" = "cf" + } + + type = "basic" + } + } + } + } + } + + # module.test.codefresh_context.s3["create"] will be created + + resource "codefresh_context" "s3" { + + id = (known after apply) + + name = "s3" + + + spec { + + storages3 { + + data { + + auth { + + json_config = { + + "config" = "cf" + } + + type = "basic" + } + } + } + } + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/terraform/test_storage_integration/plan.json b/testing/equivalence/results/terraform/test_storage_integration/plan.json new file mode 100644 index 00000000..f73b8205 --- /dev/null +++ b/testing/equivalence/results/terraform/test_storage_integration/plan.json @@ -0,0 +1,610 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "resources": [ + { + "address": "codefresh_context.azure", + "expressions": { + "name": { + "constant_value": "azure" + }, + "spec": [ + { + "storageazuref": [ + { + "data": [ + { + "auth": [ + { + "account_key": { + "constant_value": "accKey" + }, + "account_name": { + "constant_value": "accName" + }, + "type": { + "constant_value": "basic" + } + } + ] + } + ] + } + ] + } + ] + }, + "mode": "managed", + "name": "azure", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_context" + }, + { + "address": "codefresh_context.gcs", + "expressions": { + "name": { + "constant_value": "gcs" + }, + "spec": [ + { + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {}, + "type": { + "constant_value": "basic" + } + } + ] + } + ] + } + ] + } + ] + }, + "mode": "managed", + "name": "gcs", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_context" + }, + { + "address": "codefresh_context.s3", + "expressions": { + "name": { + "constant_value": "s3" + }, + "spec": [ + { + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {}, + "type": { + "constant_value": "basic" + } + } + ] + } + ] + } + ] + } + ] + }, + "mode": "managed", + "name": "s3", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_context" + } + ] + }, + "source": "../../../../examples/storage_integration" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "resources": [ + { + "address": "module.test.codefresh_context.azure[\"create\"]", + "index": "create", + "mode": "managed", + "name": "azure", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + {} + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "type": "codefresh_context", + "values": { + "name": "azure", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + { + "account_key": "accKey", + "account_name": "accName", + "type": "basic" + } + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + } + }, + { + "address": "module.test.codefresh_context.gcs[\"create\"]", + "index": "create", + "mode": "managed", + "name": "gcs", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "type": "codefresh_context", + "values": { + "name": "gcs", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + } + }, + { + "address": "module.test.codefresh_context.s3[\"create\"]", + "index": "create", + "mode": "managed", + "name": "s3", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "type": "codefresh_context", + "values": { + "name": "s3", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "yaml": [] + } + ] + } + } + ] + } + ] + } + }, + "resource_changes": [ + { + "address": "module.test.codefresh_context.azure[\"create\"]", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "azure", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + { + "account_key": "accKey", + "account_name": "accName", + "type": "basic" + } + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "after_sensitive": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + {} + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "after_unknown": { + "id": true, + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [ + { + "data": [ + { + "auth": [ + {} + ] + } + ] + } + ], + "storagegc": [], + "storages3": [], + "yaml": [] + } + ] + }, + "before": null, + "before_sensitive": false + }, + "index": "create", + "mode": "managed", + "module_address": "module.test", + "name": "azure", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_context" + }, + { + "address": "module.test.codefresh_context.gcs[\"create\"]", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "gcs", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "after_sensitive": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "after_unknown": { + "id": true, + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "storages3": [], + "yaml": [] + } + ] + }, + "before": null, + "before_sensitive": false + }, + "index": "create", + "mode": "managed", + "module_address": "module.test", + "name": "gcs", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_context" + }, + { + "address": "module.test.codefresh_context.s3[\"create\"]", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "s3", + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": { + "config": "cf" + }, + "type": "basic" + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "after_sensitive": { + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "after_unknown": { + "id": true, + "spec": [ + { + "config": [], + "secret": [], + "secretyaml": [], + "storageazuref": [], + "storagegc": [], + "storages3": [ + { + "data": [ + { + "auth": [ + { + "json_config": {} + } + ] + } + ] + } + ], + "yaml": [] + } + ] + }, + "before": null, + "before_sensitive": false + }, + "index": "create", + "mode": "managed", + "module_address": "module.test", + "name": "s3", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_context" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_storage_integration/state b/testing/equivalence/results/terraform/test_storage_integration/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/terraform/test_storage_integration/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/terraform/test_storage_integration/state.json b/testing/equivalence/results/terraform/test_storage_integration/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/terraform/test_storage_integration/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_triggers/plan b/testing/equivalence/results/terraform/test_triggers/plan new file mode 100644 index 00000000..99257419 --- /dev/null +++ b/testing/equivalence/results/terraform/test_triggers/plan @@ -0,0 +1,143 @@ + +Warning: Provider development overrides are in effect + +The following provider development overrides are set in the CLI +configuration: + - codefresh-io/codefresh in /Users/yonatankoren/software/codefresh-io/tofu-provider-codefresh + +The behavior may therefore not match any released version of the provider and +applying changes may cause the state to become incompatible with published +releases. + +OpenTofu used the selected providers to generate the following execution plan. +Resource actions are indicated with the following symbols: + + create + +OpenTofu will perform the following actions: + + # module.test.codefresh_pipeline_cron_trigger.default will be created + + resource "codefresh_pipeline_cron_trigger" "default" { + + expression = "0 0 2 ? * MON-FRI" + + id = (known after apply) + + message = "test" + + pipeline_id = (known after apply) + } + + # module.test.module.pipeline.codefresh_pipeline.test will be created + + resource "codefresh_pipeline" "test" { + + id = (known after apply) + + is_public = false + + name = "myproject/react-sample-app" + + original_yaml_string = <<-EOT + version: "1.0" + hooks: + on_finish: + steps: + b: + image: alpine:3.9 + commands: + - echo "echo cleanup step" + a: + image: cloudposse/slack-notifier + commands: + - echo "Notify slack" + steps: + freestyle: + image: alpine + commands: + - sleep 10 + a_freestyle: + image: alpine + commands: + - sleep 10 + - echo Hey! + arguments: + c: 3 + a: 1 + b: 2 + EOT + + project_id = (known after apply) + + revision = (known after apply) + + tags = [ + + "docker", + + "production", + ] + + + spec { + + branch_concurrency = 0 + + concurrency = 1 + + contexts = [ + + "context1-name", + + "context2-name", + ] + + priority = 5 + + trigger_concurrency = 0 + + variables = { + + "ANOTHER_PIP_VAR" = "another_value" + + "MY_PIP_VAR" = "value" + } + + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for commits" + + disabled = false + + events = [ + + "push.heads", + ] + + name = "commits" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + + trigger { + + branch_regex = "/.*/gi" + + branch_regex_input = "regex" + + comment_regex = "/.*/gi" + + context = "git" + + description = "Trigger for tags" + + disabled = false + + events = [ + + "push.tags", + ] + + name = "tags" + + provider = "github" + + pull_request_allow_fork_events = false + + repo = "codefresh-contrib/react-sample-app" + + type = "git" + } + } + } + + # module.test.module.pipeline.codefresh_project.test will be created + + resource "codefresh_project" "test" { + + id = (known after apply) + + name = "myproject" + + tags = [ + + "docker", + ] + } + +Plan: 3 to add, 0 to change, 0 to destroy. + +Warning: Deprecated Resource + + with module.test.codefresh_pipeline_cron_trigger.default, + on ../../../../examples/triggers/main.tf line 5, in resource "codefresh_pipeline_cron_trigger" "default": + 5: resource "codefresh_pipeline_cron_trigger" "default" { + +This resource is deprecated and will be removed in a future version of the +Codefresh OpenTofu provider. Please use the cron_triggers attribute of the +codefresh_pipeline resource instead. + +(and one more similar warning elsewhere) + +───────────────────────────────────────────────────────────────────────────── + +Saved the plan to: equivalence_test_plan + +To perform exactly these actions, run the following command to apply: + tofu apply "equivalence_test_plan" diff --git a/testing/equivalence/results/terraform/test_triggers/plan.json b/testing/equivalence/results/terraform/test_triggers/plan.json new file mode 100644 index 00000000..09ba6e20 --- /dev/null +++ b/testing/equivalence/results/terraform/test_triggers/plan.json @@ -0,0 +1,618 @@ +{ + "configuration": { + "provider_config": { + "module.test:codefresh": { + "full_name": "registry.terraform.io/codefresh-io/codefresh", + "module_address": "module.test", + "name": "codefresh", + "version_constraint": "~\u003e 0.1" + } + }, + "root_module": { + "module_calls": { + "test": { + "module": { + "module_calls": { + "pipeline": { + "module": { + "outputs": { + "id": { + "expression": { + "references": [ + "codefresh_pipeline.test.id", + "codefresh_pipeline.test" + ] + } + } + }, + "resources": [ + { + "address": "codefresh_pipeline.test", + "expressions": { + "name": { + "references": [ + "codefresh_project.test.name", + "codefresh_project.test" + ] + }, + "original_yaml_string": { + "constant_value": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n" + }, + "spec": [ + { + "concurrency": { + "constant_value": 1 + }, + "contexts": { + "constant_value": [ + "context1-name", + "context2-name" + ] + }, + "priority": { + "constant_value": 5 + }, + "trigger": [ + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for commits" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.heads" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "commits" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + }, + { + "branch_regex": { + "constant_value": "/.*/gi" + }, + "context": { + "constant_value": "git" + }, + "description": { + "constant_value": "Trigger for tags" + }, + "disabled": { + "constant_value": false + }, + "events": { + "constant_value": [ + "push.tags" + ] + }, + "modified_files_glob": { + "constant_value": "" + }, + "name": { + "constant_value": "tags" + }, + "provider": { + "constant_value": "github" + }, + "repo": { + "constant_value": "codefresh-contrib/react-sample-app" + }, + "type": { + "constant_value": "git" + } + } + ], + "variables": { + "constant_value": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + } + ], + "tags": { + "constant_value": [ + "production", + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_pipeline" + }, + { + "address": "codefresh_project.test", + "expressions": { + "name": { + "constant_value": "myproject" + }, + "tags": { + "constant_value": [ + "docker" + ] + } + }, + "mode": "managed", + "name": "test", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_project" + } + ] + }, + "source": "../pipelines" + } + }, + "resources": [ + { + "address": "codefresh_pipeline_cron_trigger.default", + "expressions": { + "expression": { + "constant_value": "0 0 2 ? * MON-FRI" + }, + "message": { + "constant_value": "test" + }, + "pipeline_id": { + "references": [ + "module.pipeline.id", + "module.pipeline" + ] + } + }, + "mode": "managed", + "name": "default", + "provider_config_key": "module.test:codefresh", + "schema_version": 0, + "type": "codefresh_pipeline_cron_trigger" + } + ] + }, + "source": "../../../../examples/triggers" + } + } + } + }, + "format_version": "1.2", + "planned_values": { + "root_module": { + "child_modules": [ + { + "address": "module.test", + "child_modules": [ + { + "address": "module.test.module.pipeline", + "resources": [ + { + "address": "module.test.module.pipeline.codefresh_pipeline.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "type": "codefresh_pipeline", + "values": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + } + }, + { + "address": "module.test.module.pipeline.codefresh_project.test", + "mode": "managed", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": { + "tags": [ + false + ] + }, + "type": "codefresh_project", + "values": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + } + } + ] + } + ], + "resources": [ + { + "address": "module.test.codefresh_pipeline_cron_trigger.default", + "mode": "managed", + "name": "default", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "schema_version": 0, + "sensitive_values": {}, + "type": "codefresh_pipeline_cron_trigger", + "values": { + "expression": "0 0 2 ? * MON-FRI", + "message": "test" + } + } + ] + } + ] + } + }, + "relevant_attributes": [ + { + "attribute": [ + "name" + ], + "resource": "module.test.module.pipeline.codefresh_project.test" + }, + { + "attribute": [ + "id" + ], + "resource": "module.test.module.pipeline.codefresh_pipeline.test" + } + ], + "resource_changes": [ + { + "address": "module.test.codefresh_pipeline_cron_trigger.default", + "change": { + "actions": [ + "create" + ], + "after": { + "expression": "0 0 2 ? * MON-FRI", + "message": "test" + }, + "after_sensitive": {}, + "after_unknown": { + "id": true, + "pipeline_id": true + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test", + "name": "default", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_pipeline_cron_trigger" + }, + { + "address": "module.test.module.pipeline.codefresh_pipeline.test", + "change": { + "actions": [ + "create" + ], + "after": { + "is_public": false, + "name": "myproject/react-sample-app", + "original_yaml_string": "version: \"1.0\"\nhooks: \n on_finish:\n steps:\n b:\n image: alpine:3.9\n commands:\n - echo \"echo cleanup step\"\n a:\n image: cloudposse/slack-notifier\n commands:\n - echo \"Notify slack\"\nsteps:\n freestyle:\n image: alpine\n commands:\n - sleep 10\n a_freestyle:\n image: alpine\n commands:\n - sleep 10\n - echo Hey!\n arguments:\n c: 3\n a: 1\n b: 2\n", + "spec": [ + { + "branch_concurrency": 0, + "concurrency": 1, + "contexts": [ + "context1-name", + "context2-name" + ], + "cron_trigger": [], + "options": [], + "pack_id": null, + "priority": 5, + "required_available_storage": null, + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for commits", + "disabled": false, + "events": [ + "push.heads" + ], + "modified_files_glob": "", + "name": "commits", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + }, + { + "branch_regex": "/.*/gi", + "branch_regex_input": "regex", + "comment_regex": "/.*/gi", + "commit_status_title": null, + "context": "git", + "contexts": null, + "description": "Trigger for tags", + "disabled": false, + "events": [ + "push.tags" + ], + "modified_files_glob": "", + "name": "tags", + "options": [], + "provider": "github", + "pull_request_allow_fork_events": false, + "pull_request_target_branch_regex": null, + "repo": "codefresh-contrib/react-sample-app", + "runtime_environment": [], + "type": "git", + "variables": null + } + ], + "trigger_concurrency": 0, + "variables": { + "ANOTHER_PIP_VAR": "another_value", + "MY_PIP_VAR": "value" + } + } + ], + "tags": [ + "docker", + "production" + ] + }, + "after_sensitive": { + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "after_unknown": { + "id": true, + "project_id": true, + "revision": true, + "spec": [ + { + "contexts": [ + false, + false + ], + "cron_trigger": [], + "options": [], + "runtime_environment": [], + "spec_template": [], + "termination_policy": [], + "trigger": [ + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + }, + { + "events": [ + false + ], + "options": [], + "runtime_environment": [] + } + ], + "variables": {} + } + ], + "tags": [ + false, + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test.module.pipeline", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_pipeline" + }, + { + "address": "module.test.module.pipeline.codefresh_project.test", + "change": { + "actions": [ + "create" + ], + "after": { + "name": "myproject", + "tags": [ + "docker" + ], + "variables": null + }, + "after_sensitive": { + "tags": [ + false + ] + }, + "after_unknown": { + "id": true, + "tags": [ + false + ] + }, + "before": null, + "before_sensitive": false + }, + "mode": "managed", + "module_address": "module.test.module.pipeline", + "name": "test", + "provider_name": "registry.terraform.io/codefresh-io/codefresh", + "type": "codefresh_project" + } + ] +} \ No newline at end of file diff --git a/testing/equivalence/results/terraform/test_triggers/state b/testing/equivalence/results/terraform/test_triggers/state new file mode 100644 index 00000000..728fbb4d --- /dev/null +++ b/testing/equivalence/results/terraform/test_triggers/state @@ -0,0 +1 @@ +No state. diff --git a/testing/equivalence/results/terraform/test_triggers/state.json b/testing/equivalence/results/terraform/test_triggers/state.json new file mode 100644 index 00000000..00f8f1ca --- /dev/null +++ b/testing/equivalence/results/terraform/test_triggers/state.json @@ -0,0 +1,3 @@ +{ + "format_version": "1.0" +} \ No newline at end of file diff --git a/testing/equivalence/rewrites.jsonc b/testing/equivalence/rewrites.jsonc index f732fc71..dacd0f67 100644 --- a/testing/equivalence/rewrites.jsonc +++ b/testing/equivalence/rewrites.jsonc @@ -7,6 +7,7 @@ // character count differs between "Terraform" and "OpenTofu" so the lines // are wrapped slightly differently. In fact, OpenTofu's version is slightly // more pleasing to the eye. - "execution\nplan. Resource": "execution plan.\nResource" + "execution\nplan. Resource": "execution plan.\nResource", + "complete after .*s": "complete after xs" // completion time may vary } } \ No newline at end of file diff --git a/testing/equivalence/test_cases/test_account_tokens/main.tf b/testing/equivalence/test_cases/test_account_tokens/main.tf deleted file mode 100644 index 84abd031..00000000 --- a/testing/equivalence/test_cases/test_account_tokens/main.tf +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT EDIT -# This file is automatically generated by update-test-cases.sh -module test { - source = "../../../../examples/account_tokens" -} diff --git a/testing/equivalence/test_cases/test_account_tokens/spec.json b/testing/equivalence/test_cases/test_account_tokens/spec.json deleted file mode 100644 index 194a11b3..00000000 --- a/testing/equivalence/test_cases/test_account_tokens/spec.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "ignore_fields": { - "plan.json": ["errored"] - }, - "commands": [ - { - "name": "init", - "arguments": ["init", "-plugin-dir=../../.plugins"], - "capture_output": false - }, - { - "name": "plan", - "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], - "capture_output": true, - "output_file_name": "plan", - "has_json_output": false - }, - { - "name": "state", - "arguments": ["show", "-no-color"], - "capture_output": true, - "output_file_name": "state", - "has_json_output": false - }, - { - "name": "show_state", - "arguments": ["show", "-json"], - "capture_output": true, - "output_file_name": "state.json", - "has_json_output": true, - "streams_json_output": false - }, - { - "name": "show_plan", - "arguments": ["show", "-json", "equivalence_test_plan"], - "capture_output": true, - "output_file_name": "plan.json", - "has_json_output": true, - "streams_json_output": false - } - ] -} diff --git a/testing/equivalence/test_cases/test_accounts_users/main.tf b/testing/equivalence/test_cases/test_accounts_users/main.tf deleted file mode 100644 index c52a8eee..00000000 --- a/testing/equivalence/test_cases/test_accounts_users/main.tf +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT EDIT -# This file is automatically generated by update-test-cases.sh -module test { - source = "../../../../examples/accounts_users" -} diff --git a/testing/equivalence/test_cases/test_accounts_users/spec.json b/testing/equivalence/test_cases/test_accounts_users/spec.json deleted file mode 100644 index 194a11b3..00000000 --- a/testing/equivalence/test_cases/test_accounts_users/spec.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "ignore_fields": { - "plan.json": ["errored"] - }, - "commands": [ - { - "name": "init", - "arguments": ["init", "-plugin-dir=../../.plugins"], - "capture_output": false - }, - { - "name": "plan", - "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], - "capture_output": true, - "output_file_name": "plan", - "has_json_output": false - }, - { - "name": "state", - "arguments": ["show", "-no-color"], - "capture_output": true, - "output_file_name": "state", - "has_json_output": false - }, - { - "name": "show_state", - "arguments": ["show", "-json"], - "capture_output": true, - "output_file_name": "state.json", - "has_json_output": true, - "streams_json_output": false - }, - { - "name": "show_plan", - "arguments": ["show", "-json", "equivalence_test_plan"], - "capture_output": true, - "output_file_name": "plan.json", - "has_json_output": true, - "streams_json_output": false - } - ] -} diff --git a/testing/equivalence/test_cases/test_permissions/main.tf b/testing/equivalence/test_cases/test_permissions/main.tf deleted file mode 100644 index 6f42cc1c..00000000 --- a/testing/equivalence/test_cases/test_permissions/main.tf +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT EDIT -# This file is automatically generated by update-test-cases.sh -module test { - source = "../../../../examples/permissions" -} diff --git a/testing/equivalence/test_cases/test_permissions/spec.json b/testing/equivalence/test_cases/test_permissions/spec.json deleted file mode 100644 index 194a11b3..00000000 --- a/testing/equivalence/test_cases/test_permissions/spec.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "ignore_fields": { - "plan.json": ["errored"] - }, - "commands": [ - { - "name": "init", - "arguments": ["init", "-plugin-dir=../../.plugins"], - "capture_output": false - }, - { - "name": "plan", - "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], - "capture_output": true, - "output_file_name": "plan", - "has_json_output": false - }, - { - "name": "state", - "arguments": ["show", "-no-color"], - "capture_output": true, - "output_file_name": "state", - "has_json_output": false - }, - { - "name": "show_state", - "arguments": ["show", "-json"], - "capture_output": true, - "output_file_name": "state.json", - "has_json_output": true, - "streams_json_output": false - }, - { - "name": "show_plan", - "arguments": ["show", "-json", "equivalence_test_plan"], - "capture_output": true, - "output_file_name": "plan.json", - "has_json_output": true, - "streams_json_output": false - } - ] -} diff --git a/testing/equivalence/test_cases/test_registries/main.tf b/testing/equivalence/test_cases/test_registries/main.tf deleted file mode 100644 index 5bad0646..00000000 --- a/testing/equivalence/test_cases/test_registries/main.tf +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT EDIT -# This file is automatically generated by update-test-cases.sh -module test { - source = "../../../../examples/registries" -} diff --git a/testing/equivalence/test_cases/test_registries/spec.json b/testing/equivalence/test_cases/test_registries/spec.json deleted file mode 100644 index 194a11b3..00000000 --- a/testing/equivalence/test_cases/test_registries/spec.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "ignore_fields": { - "plan.json": ["errored"] - }, - "commands": [ - { - "name": "init", - "arguments": ["init", "-plugin-dir=../../.plugins"], - "capture_output": false - }, - { - "name": "plan", - "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], - "capture_output": true, - "output_file_name": "plan", - "has_json_output": false - }, - { - "name": "state", - "arguments": ["show", "-no-color"], - "capture_output": true, - "output_file_name": "state", - "has_json_output": false - }, - { - "name": "show_state", - "arguments": ["show", "-json"], - "capture_output": true, - "output_file_name": "state.json", - "has_json_output": true, - "streams_json_output": false - }, - { - "name": "show_plan", - "arguments": ["show", "-json", "equivalence_test_plan"], - "capture_output": true, - "output_file_name": "plan.json", - "has_json_output": true, - "streams_json_output": false - } - ] -} diff --git a/testing/equivalence/test_cases/test_teams/main.tf b/testing/equivalence/test_cases/test_teams/main.tf deleted file mode 100644 index dd480977..00000000 --- a/testing/equivalence/test_cases/test_teams/main.tf +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT EDIT -# This file is automatically generated by update-test-cases.sh -module test { - source = "../../../../examples/teams" -} diff --git a/testing/equivalence/test_cases/test_teams/spec.json b/testing/equivalence/test_cases/test_teams/spec.json deleted file mode 100644 index 194a11b3..00000000 --- a/testing/equivalence/test_cases/test_teams/spec.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "ignore_fields": { - "plan.json": ["errored"] - }, - "commands": [ - { - "name": "init", - "arguments": ["init", "-plugin-dir=../../.plugins"], - "capture_output": false - }, - { - "name": "plan", - "arguments": ["plan", "-out=equivalence_test_plan", "-no-color"], - "capture_output": true, - "output_file_name": "plan", - "has_json_output": false - }, - { - "name": "state", - "arguments": ["show", "-no-color"], - "capture_output": true, - "output_file_name": "state", - "has_json_output": false - }, - { - "name": "show_state", - "arguments": ["show", "-json"], - "capture_output": true, - "output_file_name": "state.json", - "has_json_output": true, - "streams_json_output": false - }, - { - "name": "show_plan", - "arguments": ["show", "-json", "equivalence_test_plan"], - "capture_output": true, - "output_file_name": "plan.json", - "has_json_output": true, - "streams_json_output": false - } - ] -} diff --git a/testing/equivalence/update-test-cases.sh b/testing/equivalence/update-test-cases.sh index 259c0c5b..1ce3b58c 100755 --- a/testing/equivalence/update-test-cases.sh +++ b/testing/equivalence/update-test-cases.sh @@ -11,6 +11,16 @@ fi test_case_dirname="test_cases" test_case_prefix="test_" +skip_examples=( + # test environment not set up for the following examples + "registries" + "permissions" + "teams" # needs teams set up beforehand + "accounts_users" # needs idps + # the following examples require additional providers + "account_tokens" # hashicorp/random +) + if [[ ! -d ${test_case_dirname} ]]; then print_style "Creating test case directory" print_style "${test_case_dirname}" "info" @@ -19,6 +29,12 @@ if [[ ! -d ${test_case_dirname} ]]; then fi for i in $(find $(dirname $(grealpath $0))/../../examples -mindepth 1 -maxdepth 1 -type d -not -path "**/.modules"); do + if [[ " ${skip_examples[@]} " =~ " $(basename ${i}) " ]]; then + print_style "Skipping example " + print_style "$(grealpath --relative-to=$(dirname $0) ${i})\n" "warning" + continue + fi + print_style "Found example directory: " print_style "$(grealpath --relative-to=$(dirname $0) ${i})\n" expected_test_dir="$(dirname $(grealpath $0))/${test_case_dirname}/${test_case_prefix}$(basename ${i})" From 4e782fd4fcfe7ba0e70aa0670cec133817fe9279 Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:11:11 -0400 Subject: [PATCH 5/7] Add equivalence test. --- .github/workflows/pull_request.yaml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 5615abbb..8d5ebe20 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -19,7 +19,7 @@ jobs: run: | git diff --exit-code gofmt: - name: "Ensure 'make fmt' has been run" + name: "Ensure 'go fmt' has been run" runs-on: ubuntu-latest steps: - name: Checkout repo @@ -32,3 +32,17 @@ jobs: - name: Validate No Changes run: | git diff --exit-code + equivalence: + name: "Ensure 'make equivalence' has been run" + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run equivalence test + run: | + make equivalence + - name: Validate No Changes + run: | + git diff --exit-code \ No newline at end of file From 7b9693740786b34e9bc5abe08661a04cac0b8382 Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:24:09 -0400 Subject: [PATCH 6/7] Add equivalence test to pipeline. --- .github/workflows/pull_request.yaml | 14 -------------- codefresh.yml | 20 +++++++++++++++++++- testing/equivalence/compare-results.sh | 19 +++++++++++++++---- testing/equivalence/update-test-cases.sh | 11 ++++++++--- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 8d5ebe20..dc8edbd3 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -29,20 +29,6 @@ jobs: - name: Run gofmt run: | go fmt - - name: Validate No Changes - run: | - git diff --exit-code - equivalence: - name: "Ensure 'make equivalence' has been run" - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: Run equivalence test - run: | - make equivalence - name: Validate No Changes run: | git diff --exit-code \ No newline at end of file diff --git a/codefresh.yml b/codefresh.yml index 8e04ef60..d0ceff84 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -37,9 +37,27 @@ steps: matrix: # The following will resolve to their latest patch version environment: - - TF_VERSION=1.3.0 - TF_VERSION=1.4.0 - TF_VERSION=1.5.0 + - TF_VERSION=1.6.0 + + equivalence_tests: + title: "Run tests" + stage: test + image: golang:1.18.10-alpine3.17 + environment: + - TF_VERSION=1.6.0 + commands: + - apk update + - apk add make + - go install github.com/warrensbox/terraform-switcher@0.13.1308 + - terraform-switcher --latest-stable ${TF_VERSION} + - apk add opentofu@1.6.0_alpha2-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ + - make equivalence + retry: + maxAttempts: 3 + delay: 5 + exponentialFactor: 2 prepare_env_vars: title: "Preparing environment variables..." diff --git a/testing/equivalence/compare-results.sh b/testing/equivalence/compare-results.sh index 9ec393b5..4e6ab474 100755 --- a/testing/equivalence/compare-results.sh +++ b/testing/equivalence/compare-results.sh @@ -1,8 +1,19 @@ #!/bin/bash -source $(realpath $(dirname $0))/lib.sh +if [[ "$OSTYPE" == "darwin"* ]]; +then + if ! command -v grealpath &> /dev/null; + then + print_style "ERROR: This script requires grealpath when run on Mac. Please install it with 'brew install coreutils'\n" "danger" + exit 1 + else + alias realpath=grealpath + fi +fi -for i in $(find $(realpath $(dirname $0))/results/terraform -mindepth 1 -maxdepth 1 -type d); do +source $(grealpath $(dirname $0))/lib.sh + +for i in $(find $(grealpath $(dirname $0))/results/terraform -mindepth 1 -maxdepth 1 -type d); do test_case_name=$(basename ${i}) print_style "Test case " print_style "${test_case_name}" "info" @@ -14,8 +25,8 @@ for i in $(find $(realpath $(dirname $0))/results/terraform -mindepth 1 -maxdept print_style "results/opentofu/$(basename ${f})" "info" print_style ": " - terraform_file=$(realpath $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) - opentofu_file=$(realpath $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) + terraform_file=$(grealpath $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) + opentofu_file=$(grealpath $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) # We normalize the JSON output to make them comparable regardless of key order diff \ diff --git a/testing/equivalence/update-test-cases.sh b/testing/equivalence/update-test-cases.sh index 1ce3b58c..17bbf604 100755 --- a/testing/equivalence/update-test-cases.sh +++ b/testing/equivalence/update-test-cases.sh @@ -2,10 +2,15 @@ source $(realpath $(dirname $0))/lib.sh -if [[ "$OSTYPE" == "darwin"* ]] && ! command -v grealpath &> /dev/null; +if [[ "$OSTYPE" == "darwin"* ]]; then - print_style "ERROR: This script requires grealpath when run on Mac. Please install it with 'brew install coreutils'\n" "danger" - exit 1 + if ! command -v grealpath &> /dev/null; + then + print_style "ERROR: This script requires grealpath when run on Mac. Please install it with 'brew install coreutils'\n" "danger" + exit 1 + else + alias realpath=grealpath + fi fi test_case_dirname="test_cases" From f7da9cd6d76ccbcd34963564d733d4cf2b36782e Mon Sep 17 00:00:00 2001 From: Yonatan Koren <10080107+korenyoni@users.noreply.github.com> Date: Thu, 2 Nov 2023 12:34:20 -0400 Subject: [PATCH 7/7] Fix scripts. --- testing/equivalence/compare-results.sh | 11 ++++++----- testing/equivalence/update-test-cases.sh | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/testing/equivalence/compare-results.sh b/testing/equivalence/compare-results.sh index 4e6ab474..6c440a5e 100755 --- a/testing/equivalence/compare-results.sh +++ b/testing/equivalence/compare-results.sh @@ -1,5 +1,6 @@ #!/bin/bash +path=$(which realpath) if [[ "$OSTYPE" == "darwin"* ]]; then if ! command -v grealpath &> /dev/null; @@ -7,13 +8,13 @@ then print_style "ERROR: This script requires grealpath when run on Mac. Please install it with 'brew install coreutils'\n" "danger" exit 1 else - alias realpath=grealpath + path=$(which grealpath) fi fi -source $(grealpath $(dirname $0))/lib.sh +source $($path $(dirname $0))/lib.sh -for i in $(find $(grealpath $(dirname $0))/results/terraform -mindepth 1 -maxdepth 1 -type d); do +for i in $(find $($path $(dirname $0))/results/terraform -mindepth 1 -maxdepth 1 -type d); do test_case_name=$(basename ${i}) print_style "Test case " print_style "${test_case_name}" "info" @@ -25,8 +26,8 @@ for i in $(find $(grealpath $(dirname $0))/results/terraform -mindepth 1 -maxdep print_style "results/opentofu/$(basename ${f})" "info" print_style ": " - terraform_file=$(grealpath $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) - opentofu_file=$(grealpath $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) + terraform_file=$($path $(dirname $0))/results/terraform/$(basename ${i})/$(basename ${f}) + opentofu_file=$($path $(dirname $0))/results/opentofu/$(basename ${i})/$(basename ${f}) # We normalize the JSON output to make them comparable regardless of key order diff \ diff --git a/testing/equivalence/update-test-cases.sh b/testing/equivalence/update-test-cases.sh index 17bbf604..1635de61 100755 --- a/testing/equivalence/update-test-cases.sh +++ b/testing/equivalence/update-test-cases.sh @@ -1,7 +1,6 @@ #!/bin/bash -source $(realpath $(dirname $0))/lib.sh - +path=$(which realpath) if [[ "$OSTYPE" == "darwin"* ]]; then if ! command -v grealpath &> /dev/null; @@ -9,10 +8,12 @@ then print_style "ERROR: This script requires grealpath when run on Mac. Please install it with 'brew install coreutils'\n" "danger" exit 1 else - alias realpath=grealpath + path=$(which grealpath) fi fi +source $(realpath $(dirname $0))/lib.sh + test_case_dirname="test_cases" test_case_prefix="test_" @@ -33,25 +34,25 @@ if [[ ! -d ${test_case_dirname} ]]; then mkdir -p ${test_case_dirname} fi -for i in $(find $(dirname $(grealpath $0))/../../examples -mindepth 1 -maxdepth 1 -type d -not -path "**/.modules"); do +for i in $(find $(dirname $($path $0))/../../examples -mindepth 1 -maxdepth 1 -type d -not -path "**/.modules"); do if [[ " ${skip_examples[@]} " =~ " $(basename ${i}) " ]]; then print_style "Skipping example " - print_style "$(grealpath --relative-to=$(dirname $0) ${i})\n" "warning" + print_style "$($path --relative-to=$(dirname $0) ${i})\n" "warning" continue fi print_style "Found example directory: " - print_style "$(grealpath --relative-to=$(dirname $0) ${i})\n" - expected_test_dir="$(dirname $(grealpath $0))/${test_case_dirname}/${test_case_prefix}$(basename ${i})" + print_style "$($path --relative-to=$(dirname $0) ${i})\n" + expected_test_dir="$(dirname $($path $0))/${test_case_dirname}/${test_case_prefix}$(basename ${i})" if [[ ! -d ${expected_test_dir} ]]; then mkdir -p ${expected_test_dir} print_style " * created missing directory " - print_style "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})\n" "warning" + print_style "$($path --relative-to=$(dirname $0) ${expected_test_dir})\n" "warning" fi print_style " * updating " - print_style "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})/main.tf\n" "info" + print_style "$($path --relative-to=$(dirname $0) ${expected_test_dir})/main.tf\n" "info" cat << EOF > ${expected_test_dir}/main.tf # DO NOT EDIT # This file is automatically generated by $(basename $0) @@ -61,7 +62,7 @@ module test { EOF print_style " * updating " - print_style "$(grealpath --relative-to=$(dirname $0) ${expected_test_dir})/spec.json\n" "info" + print_style "$($path --relative-to=$(dirname $0) ${expected_test_dir})/spec.json\n" "info" cat << EOF > ${expected_test_dir}/spec.json { "ignore_fields": {