From 973b45f186ecf9711ba1c657ae8215ec4e160117 Mon Sep 17 00:00:00 2001 From: Jacob White Date: Thu, 20 Oct 2022 18:03:26 -0400 Subject: [PATCH 01/13] Add pages_project generator and importer --- .gitignore | 5 +- README.md | 3 +- internal/app/cf-terraforming/cmd/generate.go | 19 ++ internal/app/cf-terraforming/cmd/import.go | 14 + internal/app/cf-terraforming/cmd/root.go | 2 +- lint.yml | 35 --- .../cloudflare/cloudflare_pages_project.yml | 266 ++++++++++++++++++ .../cloudflare_pages_project/provider.tf | 8 + .../cloudflare_pages_project/test.tf | 72 +++++ testing/main.tf | 0 10 files changed, 386 insertions(+), 38 deletions(-) delete mode 100644 lint.yml create mode 100644 testdata/cloudflare/cloudflare_pages_project.yml create mode 100644 testdata/terraform/cloudflare_pages_project/provider.tf create mode 100644 testdata/terraform/cloudflare_pages_project/test.tf create mode 100644 testing/main.tf diff --git a/.gitignore b/.gitignore index 922a0dbe2..1168d0b37 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,7 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -.idea/ \ No newline at end of file +.idea/ + +.terraform.lock.hcl +.terraform \ No newline at end of file diff --git a/README.md b/README.md index 2cd23e1fc..b17b0571a 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ Any resources not listed are currently not supported. Last updated Apr 13, 2021 | Resource | Resource Scope | Generate Supported | Import Supported | -|----------|-----------|----------|----------| +|----------|-----------|----------|---------| | [cloudflare_access_application](https://www.terraform.io/docs/providers/cloudflare/r/access_application) | Account | ✅ | ❌ | | [cloudflare_access_group](https://www.terraform.io/docs/providers/cloudflare/r/access_group) | Account | ✅ | ❌ | | [cloudflare_access_identity_provider](https://www.terraform.io/docs/providers/cloudflare/r/access_identity_provider) | Account | ✅ | ❌ | @@ -187,6 +187,7 @@ Last updated Apr 13, 2021 | [cloudflare_magic_firewall_ruleset](https://www.terraform.io/docs/providers/cloudflare/r/magic_firewall_ruleset) | Account | ❌ | ❌ | | [cloudflare_origin_ca_certificate](https://www.terraform.io/docs/providers/cloudflare/r/origin_ca_certificate) | Zone | ✅ | ✅ | | [cloudflare_page_rule](https://www.terraform.io/docs/providers/cloudflare/r/page_rule) | Zone | ✅ | ✅ | +| [cloudflare_pages_project](https://www.terraform.io/docs/providers/cloudflare/r/pages_project) | Account | ✅ | ✅ | | [cloudflare_rate_limit](https://www.terraform.io/docs/providers/cloudflare/r/rate_limit) | Zone | ✅ | ✅ | | [cloudflare_record](https://www.terraform.io/docs/providers/cloudflare/r/record) | Zone | ✅ | ✅ | | [cloudflare_ruleset](https://www.terraform.io/docs/providers/cloudflare/r/ruleset) | Account or Zone | ✅ | ❌ | diff --git a/internal/app/cf-terraforming/cmd/generate.go b/internal/app/cf-terraforming/cmd/generate.go index 2a85b55b7..f8b22f8f5 100644 --- a/internal/app/cf-terraforming/cmd/generate.go +++ b/internal/app/cf-terraforming/cmd/generate.go @@ -685,6 +685,25 @@ func generateResources() func(cmd *cobra.Command, args []string) { } } } + + //case "cloudflare_pages_domain": + // jsonPayload, err := api.GetPagesDomain(context.Background(), cloudflare.PagesDomainParameters{AccountID: accountID}) + case "cloudflare_pages_project": + jsonPayload, _, err := api.ListPagesProjects(context.Background(), accountID, cloudflare.PaginationOptions{}) + if err != nil { + log.Fatal(err) + } + resourceCount = len(jsonPayload) + m, _ := json.Marshal(jsonPayload) + err = json.Unmarshal(m, &jsonStructData) + if err != nil { + log.Fatal(err) + } + for i := 0; i < resourceCount; i++ { + jsonStructData[i].(map[string]interface{})["latest_deployment"] = nil + jsonStructData[i].(map[string]interface{})["canonical_deployment"] = nil + } + case "cloudflare_rate_limit": jsonPayload, err := api.ListAllRateLimits(context.Background(), zoneID) if err != nil { diff --git a/internal/app/cf-terraforming/cmd/import.go b/internal/app/cf-terraforming/cmd/import.go index ed9dbc032..be084bcd0 100644 --- a/internal/app/cf-terraforming/cmd/import.go +++ b/internal/app/cf-terraforming/cmd/import.go @@ -31,6 +31,7 @@ var resourceImportStringFormats = map[string]string{ "cloudflare_ip_list": ":account_id/:id", "cloudflare_origin_ca_certificate": ":id", "cloudflare_page_rule": ":zone_id/:id", + "cloudflare_pages_project": ":account_id/:id", "cloudflare_rate_limit": ":zone_id/:id", "cloudflare_record": ":zone_id/:id", "cloudflare_spectrum_application": ":zone_id/:id", @@ -257,6 +258,19 @@ func runImport() func(cmd *cobra.Command, args []string) { if err != nil { log.Fatal(err) } + case "cloudflare_pages_project": + jsonPayload, _, err := api.ListPagesProjects(context.Background(), accountID, cloudflare.PaginationOptions{}) + if err != nil { + log.Fatal(err) + } + m, _ := json.Marshal(jsonPayload) + err = json.Unmarshal(m, &jsonStructData) + if err != nil { + log.Fatal(err) + } + for i, _ := range jsonStructData { + jsonStructData[i].(map[string]interface{})["id"] = jsonStructData[i].(map[string]interface{})["name"] + } case "cloudflare_rate_limit": jsonPayload, err := api.ListAllRateLimits(context.Background(), zoneID) if err != nil { diff --git a/internal/app/cf-terraforming/cmd/root.go b/internal/app/cf-terraforming/cmd/root.go index f24974d60..7fb7c03f7 100644 --- a/internal/app/cf-terraforming/cmd/root.go +++ b/internal/app/cf-terraforming/cmd/root.go @@ -74,7 +74,7 @@ func init() { log.Fatal(err) } - rootCmd.PersistentFlags().StringVarP(&apiKey, "key", "k", "", "API Key generated on the 'My Profile' page. See: https://dash.cloudflare.com/profile") + rootCmd.PersistentFlags().StringVarP(&apiKey, "key", "k", "", "API Key generated on the 'My Profile' page. See: https://dash.cloudflare.com/profile/api-tokens") if err = viper.BindPFlag("key", rootCmd.PersistentFlags().Lookup("key")); err != nil { log.Fatal(err) } diff --git a/lint.yml b/lint.yml deleted file mode 100644 index 04cc5c660..000000000 --- a/lint.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Lint -on: [pull_request] - -permissions: - contents: read - pull-requests: read - -jobs: - golangci: - name: golangci-lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # needed for `only-new-issues` to compare diffs - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: "--config .golintci.yml" - only-new-issues: true - - tfproviderlint: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: ^1.17 - - run: make terraform-provider-lint diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yml new file mode 100644 index 000000000..6bfb0cdb8 --- /dev/null +++ b/testdata/cloudflare/cloudflare_pages_project.yml @@ -0,0 +1,266 @@ +--- +version: 1 +interactions: + - request: + body: "" + form: {} + headers: + Content-Type: + - application/json + url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects + method: GET + response: + body: | + { + "name": "Test Pages Project", + "id": "5a321fc7-3162-7d36-adce-1213996a7", + "created_on": "2021-01-01T00:00:00Z", + "subdomain": "test.pages.dev", + "domains": [ + "testdomain.com", + "testdomain.org" + ], + "production_branch": "main", + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] + } + }, + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" + }, + "deployment_configs": { + "preview": { + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "preview" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": ["preview_flag"] + }, + "production": { + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "production" + } + }, + "d1_databases": { + "D1_BINDING": { + "id": "a94509c6-0757-43f3-b053-474b0ab10935" + } + }, + "kv_namespaces": { + "KV_BINDING": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + }, + "durable_object_namespaces": { + "DO_BINDING": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + }, + "r2_buckets": { + "R2_BINDING": { + "name": "some-bucket" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": ["production_flag"] + } + }, + "latest_deployment": { + "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", + "short_id": "c35216d1", + "project_id": "5a321fc7-3162-7d36-adce-1213996a7", + "project_name": "pages-test", + "environment": "preview", + "production_branch": "main", + "url": "https://c35216d1.pages-test.pages.dev", + "created_on": "2021-03-09T00:55:03.923456Z", + "modified_on": "2021-03-09T00:58:59.045655Z", + "aliases": [ + "https://branchname.pages-test.pages.dev" + ], + "latest_stage": { + "name": "deploy", + "started_on": "2021-03-09T00:55:03.923456Z", + "ended_on": "2021-03-09T00:58:59.045655Z", + "status": "success" + }, + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "STAGING" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": ["deployment_flag"], + "deployment_trigger": { + "type": "ad_hoc", + "metadata": { + "branch": "main", + "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", + "commit_message": "Update index.html" + } + }, + "stages": [ + { + "name": "queued", + "started_on": "2021-06-03T15:38:15.608194Z", + "ended_on": "2021-06-03T15:39:03.134378Z", + "status": "active" + }, + { + "name": "test_stage_1", + "started_on": null, + "ended_on": null, + "status": "idle" + } + ], + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" + }, + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] + } + } + }, + "canonical_deployment": { + "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", + "short_id": "c35216d1", + "project_id": "5a321fc7-3162-7d36-adce-1213996a7", + "project_name": "pages-test", + "environment": "preview", + "url": "https://c35216d1.pages-test.pages.dev", + "created_on": "2021-03-09T00:55:03.923456Z", + "modified_on": "2021-03-09T00:58:59.045655Z", + "production_branch": "main", + "aliases": [ + "https://branchname.pages-test.pages.dev" + ], + "latest_stage": { + "name": "deploy", + "started_on": "2021-03-09T00:55:03.923456Z", + "ended_on": "2021-03-09T00:58:59.045655Z", + "status": "success" + }, + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "STAGING" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": ["deployment_flag"], + "deployment_trigger": { + "type": "ad_hoc", + "metadata": { + "branch": "main", + "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", + "commit_message": "Update index.html" + } + }, + "stages": [ + { + "name": "queued", + "started_on": "2021-06-03T15:38:15.608194Z", + "ended_on": "2021-06-03T15:39:03.134378Z", + "status": "active" + }, + { + "name": "test_stage_1", + "started_on": null, + "ended_on": null, + "status": "idle" + } + ], + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" + }, + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] + } + } + } + } + headers: + Content-Type: + - application/json + Vary: + - Accept-Encoding + status: 200 OK + code: 200 + duration: "" diff --git a/testdata/terraform/cloudflare_pages_project/provider.tf b/testdata/terraform/cloudflare_pages_project/provider.tf new file mode 100644 index 000000000..d2272866e --- /dev/null +++ b/testdata/terraform/cloudflare_pages_project/provider.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + cloudflare = { + source = "cloudflare/cloudflare" + } + } +} + diff --git a/testdata/terraform/cloudflare_pages_project/test.tf b/testdata/terraform/cloudflare_pages_project/test.tf new file mode 100644 index 000000000..3ab6eac29 --- /dev/null +++ b/testdata/terraform/cloudflare_pages_project/test.tf @@ -0,0 +1,72 @@ +resource "cloudflare_pages_project" "terraform_managed_resource" { + account_id = "f037e56e89293a057740de681ac9abbe" + name = "Test Pages Project" + production_branch = "main" + build_config { + build_command = "npm run build" + destination_dir = "build" + root_dir = "/" + web_analytics_tag = "0ee1d926cd60d2618a108d4232a75b73" + web_analytics_token = "c05bb382259183db3a0a822b64c11459" + } + source { + type = "github" + config { + owner = "cloudflare" + repo_name = "pages-test" + production_branch = "main" + pr_comments_enabled = true + deployments_enabled = true + production_deployment_enabled = true + preview_deployment_setting = "custom" + preview_branch_includes = [ "release/*", "production", "main"] + preview_branch_excludes = ["dependabot/*", "dev", "*/ignore"] + } + } + deployment_configs { + preview { + environment_variables = { + ENVIRONMENT = "preview" + BUILD_VERSION = "1.2" + } + kv_namespaces = { + KV_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + durable_object_namespaces = { + DO_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + r2_buckets = { + R2_BINDING = "some-bucket" + } + d1_databases = { + D1_BINDING = "a94509c6-0757-43f3-b053-474b0ab10935" + } + compatibility_date = "2022-08-16" + compatibility_flags = ["preview_flag"] + } + production { + environment_variables = { + ENVIRONMENT = "production" + BUILD_VERSION = "1.2" + } + kv_namespaces = { + KV_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3" + KV_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5" + } + durable_object_namespaces = { + DO_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3" + DO_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5" + } + r2_buckets = { + R2_BINDING_1 = "some-bucket" + R2_BINDING_2 = "other-bucket" + } + d1_databases = { + D1_BINDING_1 = "445e2955-951a-4358-a35b-a4d0c813f63" + D1_BINDING_2 = "a399414b-c697-409a-a688-377db6433cd9" + } + compatibility_date = "2022-08-15" + compatibility_flags = ["production_flag", "second flag"] + } + } +} \ No newline at end of file diff --git a/testing/main.tf b/testing/main.tf new file mode 100644 index 000000000..e69de29bb From c2b012a3a1839bba510167481ca1cb1b095b4fb8 Mon Sep 17 00:00:00 2001 From: Jacob White Date: Thu, 20 Oct 2022 20:01:39 -0400 Subject: [PATCH 02/13] Add pages domain generator --- README.md | 107 ++++++++++--------- internal/app/cf-terraforming/cmd/generate.go | 36 ++++++- 2 files changed, 88 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index b17b0571a..3b9d9a94a 100644 --- a/README.md +++ b/README.md @@ -152,60 +152,61 @@ Any resources not listed are currently not supported. Last updated Apr 13, 2021 -| Resource | Resource Scope | Generate Supported | Import Supported | -|----------|-----------|----------|---------| -| [cloudflare_access_application](https://www.terraform.io/docs/providers/cloudflare/r/access_application) | Account | ✅ | ❌ | -| [cloudflare_access_group](https://www.terraform.io/docs/providers/cloudflare/r/access_group) | Account | ✅ | ❌ | -| [cloudflare_access_identity_provider](https://www.terraform.io/docs/providers/cloudflare/r/access_identity_provider) | Account | ✅ | ❌ | -| [cloudflare_access_mutual_tls_certificate](https://www.terraform.io/docs/providers/cloudflare/r/access_mutual_tls_certificate) | Account | ✅ | ❌ | -| [cloudflare_access_policy](https://www.terraform.io/docs/providers/cloudflare/r/access_policy) | Account | ❌ | ❌ | -| [cloudflare_access_rule](https://www.terraform.io/docs/providers/cloudflare/r/access_rule) | Account | ✅ | ✅ | -| [cloudflare_access_service_token](https://www.terraform.io/docs/providers/cloudflare/r/access_service_token) | Account | ✅ | ❌ | -| [cloudflare_account_member](https://www.terraform.io/docs/providers/cloudflare/r/account_member) | Account | ✅ | ✅ | -| [cloudflare_api_shield](https://www.terraform.io/docs/providers/cloudflare/r/api_shield) | Zone | ✅ | ❌ | -| [cloudflare_api_token](https://www.terraform.io/docs/providers/cloudflare/r/api_token) | User | ❌ | ❌ | -| [cloudflare_argo](https://www.terraform.io/docs/providers/cloudflare/r/argo) | Zone | ✅ | ✅ | -| [cloudflare_argo_tunnel](https://www.terraform.io/docs/providers/cloudflare/r/argo_tunnel) | Account | ✅ | ✅ | -| [cloudflare_authenticated_origin_pulls](https://www.terraform.io/docs/providers/cloudflare/r/authenticated_origin_pulls) | Zone | ❌ | ❌ | +| Resource | Resource Scope | Generate Supported | Import Supported | +|--------------------------------------------------------------------------------------------------------------------------------------------------|-----------|----------|--------| +| [cloudflare_access_application](https://www.terraform.io/docs/providers/cloudflare/r/access_application) | Account | ✅ | ❌ | +| [cloudflare_access_group](https://www.terraform.io/docs/providers/cloudflare/r/access_group) | Account | ✅ | ❌ | +| [cloudflare_access_identity_provider](https://www.terraform.io/docs/providers/cloudflare/r/access_identity_provider) | Account | ✅ | ❌ | +| [cloudflare_access_mutual_tls_certificate](https://www.terraform.io/docs/providers/cloudflare/r/access_mutual_tls_certificate) | Account | ✅ | ❌ | +| [cloudflare_access_policy](https://www.terraform.io/docs/providers/cloudflare/r/access_policy) | Account | ❌ | ❌ | +| [cloudflare_access_rule](https://www.terraform.io/docs/providers/cloudflare/r/access_rule) | Account | ✅ | ✅ | +| [cloudflare_access_service_token](https://www.terraform.io/docs/providers/cloudflare/r/access_service_token) | Account | ✅ | ❌ | +| [cloudflare_account_member](https://www.terraform.io/docs/providers/cloudflare/r/account_member) | Account | ✅ | ✅ | +| [cloudflare_api_shield](https://www.terraform.io/docs/providers/cloudflare/r/api_shield) | Zone | ✅ | ❌ | +| [cloudflare_api_token](https://www.terraform.io/docs/providers/cloudflare/r/api_token) | User | ❌ | ❌ | +| [cloudflare_argo](https://www.terraform.io/docs/providers/cloudflare/r/argo) | Zone | ✅ | ✅ | +| [cloudflare_argo_tunnel](https://www.terraform.io/docs/providers/cloudflare/r/argo_tunnel) | Account | ✅ | ✅ | +| [cloudflare_authenticated_origin_pulls](https://www.terraform.io/docs/providers/cloudflare/r/authenticated_origin_pulls) | Zone | ❌ | ❌ | | [cloudflare_authenticated_origin_pulls_certificate](https://www.terraform.io/docs/providers/cloudflare/r/authenticated_origin_pulls_certificate) | Zone | ❌ | ❌ | -| [cloudflare_byo_ip_prefix](https://www.terraform.io/docs/providers/cloudflare/r/byo_ip_prefix) | Account | ✅ | ✅ | -| [cloudflare_certificate_pack](https://www.terraform.io/docs/providers/cloudflare/r/certificate_pack) | Zone | ✅ | ✅ | -| [cloudflare_custom_hostname](https://www.terraform.io/docs/providers/cloudflare/r/custom_hostname) | Zone | ✅ | ✅ | -| [cloudflare_custom_hostname_fallback_origin](https://www.terraform.io/docs/providers/cloudflare/r/custom_hostname_fallback_origin) | Account | ✅ | ❌ | -| [cloudflare_custom_pages](https://www.terraform.io/docs/providers/cloudflare/r/custom_pages) | Account or Zone | ✅ | ✅ | -| [cloudflare_custom_ssl](https://www.terraform.io/docs/providers/cloudflare/r/custom_ssl) | Zone | ✅ | ✅ | -| [cloudflare_filter](https://www.terraform.io/docs/providers/cloudflare/r/filter) | Zone | ✅ | ✅ | -| [cloudflare_firewall_rule](https://www.terraform.io/docs/providers/cloudflare/r/firewall_rule) | Zone | ✅ | ✅ | -| [cloudflare_healthcheck](https://www.terraform.io/docs/providers/cloudflare/r/healthcheck) | Zone | ✅ | ✅ | -| [cloudflare_ip_list](https://www.terraform.io/docs/providers/cloudflare/r/ip_list) | Account | ❌ | ✅ | -| [cloudflare_load_balancer](https://www.terraform.io/docs/providers/cloudflare/r/load_balancer) | Zone | ✅ | ❌ | -| [cloudflare_load_balancer_monitor](https://www.terraform.io/docs/providers/cloudflare/r/load_balancer_monitor) | Account | ✅ | ❌ | -| [cloudflare_load_balancer_pool](https://www.terraform.io/docs/providers/cloudflare/r/load_balancer_pool) | Account | ✅ | ❌ | -| [cloudflare_logpull_retention](https://www.terraform.io/docs/providers/cloudflare/r/logpull_retention) | Zone | ❌ | ❌ | -| [cloudflare_logpush_job](https://www.terraform.io/docs/providers/cloudflare/r/logpush_job) | Zone | ✅ | ❌ | -| [cloudflare_logpush_ownership_challenge](https://www.terraform.io/docs/providers/cloudflare/r/logpush_ownership_challenge) | Zone | ❌ | ❌ | -| [cloudflare_magic_firewall_ruleset](https://www.terraform.io/docs/providers/cloudflare/r/magic_firewall_ruleset) | Account | ❌ | ❌ | -| [cloudflare_origin_ca_certificate](https://www.terraform.io/docs/providers/cloudflare/r/origin_ca_certificate) | Zone | ✅ | ✅ | -| [cloudflare_page_rule](https://www.terraform.io/docs/providers/cloudflare/r/page_rule) | Zone | ✅ | ✅ | -| [cloudflare_pages_project](https://www.terraform.io/docs/providers/cloudflare/r/pages_project) | Account | ✅ | ✅ | -| [cloudflare_rate_limit](https://www.terraform.io/docs/providers/cloudflare/r/rate_limit) | Zone | ✅ | ✅ | -| [cloudflare_record](https://www.terraform.io/docs/providers/cloudflare/r/record) | Zone | ✅ | ✅ | -| [cloudflare_ruleset](https://www.terraform.io/docs/providers/cloudflare/r/ruleset) | Account or Zone | ✅ | ❌ | -| [cloudflare_spectrum_application](https://www.terraform.io/docs/providers/cloudflare/r/spectrum_application) | Zone | ✅ | ✅ | -| [cloudflare_waf_group](https://www.terraform.io/docs/providers/cloudflare/r/waf_group) | Zone | ❌ | ❌ | -| [cloudflare_waf_override](https://www.terraform.io/docs/providers/cloudflare/r/waf_override) | Zone | ✅ | ✅ | -| [cloudflare_waf_package](https://www.terraform.io/docs/providers/cloudflare/r/waf_package) | Zone | ✅ | ❌ | -| [cloudflare_waf_rule](https://www.terraform.io/docs/providers/cloudflare/r/waf_rule) | Zone | ❌ | ❌ | -| [cloudflare_waiting_room](https://www.terraform.io/docs/providers/cloudflare/r/waiting_room) | Zone | ✅ | ✅ | -| [cloudflare_worker_cron_trigger](https://www.terraform.io/docs/providers/cloudflare/r/worker_cron_trigger) | Account | ❌ | ❌ | -| [cloudflare_worker_route](https://www.terraform.io/docs/providers/cloudflare/r/worker_route) | Zone | ✅ | ✅ | -| [cloudflare_worker_script](https://www.terraform.io/docs/providers/cloudflare/r/worker_script) | Account | ❌ | ❌ | -| [cloudflare_workers_kv](https://www.terraform.io/docs/providers/cloudflare/r/workers_kv) | Account | ❌ | ❌ | -| [cloudflare_workers_kv_namespace](https://www.terraform.io/docs/providers/cloudflare/r/workers_kv_namespace) | Account | ✅ | ✅ | -| [cloudflare_zone](https://www.terraform.io/docs/providers/cloudflare/r/zone) | Account | ✅ | ✅ | -| [cloudflare_zone_dnssec](https://www.terraform.io/docs/providers/cloudflare/r/zone_dnssec) | Zone | ❌ | ❌ | -| [cloudflare_zone_lockdown](https://www.terraform.io/docs/providers/cloudflare/r/zone_lockdown) | Zone | ✅ | ✅ | -| [cloudflare_zone_settings_override](https://www.terraform.io/docs/providers/cloudflare/r/zone_settings_override) | Zone | ✅ | ❌ | +| [cloudflare_byo_ip_prefix](https://www.terraform.io/docs/providers/cloudflare/r/byo_ip_prefix) | Account | ✅ | ✅ | +| [cloudflare_certificate_pack](https://www.terraform.io/docs/providers/cloudflare/r/certificate_pack) | Zone | ✅ | ✅ | +| [cloudflare_custom_hostname](https://www.terraform.io/docs/providers/cloudflare/r/custom_hostname) | Zone | ✅ | ✅ | +| [cloudflare_custom_hostname_fallback_origin](https://www.terraform.io/docs/providers/cloudflare/r/custom_hostname_fallback_origin) | Account | ✅ | ❌ | +| [cloudflare_custom_pages](https://www.terraform.io/docs/providers/cloudflare/r/custom_pages) | Account or Zone | ✅ | ✅ | +| [cloudflare_custom_ssl](https://www.terraform.io/docs/providers/cloudflare/r/custom_ssl) | Zone | ✅ | ✅ | +| [cloudflare_filter](https://www.terraform.io/docs/providers/cloudflare/r/filter) | Zone | ✅ | ✅ | +| [cloudflare_firewall_rule](https://www.terraform.io/docs/providers/cloudflare/r/firewall_rule) | Zone | ✅ | ✅ | +| [cloudflare_healthcheck](https://www.terraform.io/docs/providers/cloudflare/r/healthcheck) | Zone | ✅ | ✅ | +| [cloudflare_ip_list](https://www.terraform.io/docs/providers/cloudflare/r/ip_list) | Account | ❌ | ✅ | +| [cloudflare_load_balancer](https://www.terraform.io/docs/providers/cloudflare/r/load_balancer) | Zone | ✅ | ❌ | +| [cloudflare_load_balancer_monitor](https://www.terraform.io/docs/providers/cloudflare/r/load_balancer_monitor) | Account | ✅ | ❌ | +| [cloudflare_load_balancer_pool](https://www.terraform.io/docs/providers/cloudflare/r/load_balancer_pool) | Account | ✅ | ❌ | +| [cloudflare_logpull_retention](https://www.terraform.io/docs/providers/cloudflare/r/logpull_retention) | Zone | ❌ | ❌ | +| [cloudflare_logpush_job](https://www.terraform.io/docs/providers/cloudflare/r/logpush_job) | Zone | ✅ | ❌ | +| [cloudflare_logpush_ownership_challenge](https://www.terraform.io/docs/providers/cloudflare/r/logpush_ownership_challenge) | Zone | ❌ | ❌ | +| [cloudflare_magic_firewall_ruleset](https://www.terraform.io/docs/providers/cloudflare/r/magic_firewall_ruleset) | Account | ❌ | ❌ | +| [cloudflare_origin_ca_certificate](https://www.terraform.io/docs/providers/cloudflare/r/origin_ca_certificate) | Zone | ✅ | ✅ | +| [cloudflare_page_rule](https://www.terraform.io/docs/providers/cloudflare/r/page_rule) | Zone | ✅ | ✅ | +| [cloudflare_pages_domain](https://www.terraform.io/docs/providers/cloudflare/r/pages_domain) | Account | ✅ | ❌ | +| [cloudflare_pages_project](https://www.terraform.io/docs/providers/cloudflare/r/pages_project) | Account | ✅ | ✅ | +| [cloudflare_rate_limit](https://www.terraform.io/docs/providers/cloudflare/r/rate_limit) | Zone | ✅ | ✅ | +| [cloudflare_record](https://www.terraform.io/docs/providers/cloudflare/r/record) | Zone | ✅ | ✅ | +| [cloudflare_ruleset](https://www.terraform.io/docs/providers/cloudflare/r/ruleset) | Account or Zone | ✅ | ❌ | +| [cloudflare_spectrum_application](https://www.terraform.io/docs/providers/cloudflare/r/spectrum_application) | Zone | ✅ | ✅ | +| [cloudflare_waf_group](https://www.terraform.io/docs/providers/cloudflare/r/waf_group) | Zone | ❌ | ❌ | +| [cloudflare_waf_override](https://www.terraform.io/docs/providers/cloudflare/r/waf_override) | Zone | ✅ | ✅ | +| [cloudflare_waf_package](https://www.terraform.io/docs/providers/cloudflare/r/waf_package) | Zone | ✅ | ❌ | +| [cloudflare_waf_rule](https://www.terraform.io/docs/providers/cloudflare/r/waf_rule) | Zone | ❌ | ❌ | +| [cloudflare_waiting_room](https://www.terraform.io/docs/providers/cloudflare/r/waiting_room) | Zone | ✅ | ✅ | +| [cloudflare_worker_cron_trigger](https://www.terraform.io/docs/providers/cloudflare/r/worker_cron_trigger) | Account | ❌ | ❌ | +| [cloudflare_worker_route](https://www.terraform.io/docs/providers/cloudflare/r/worker_route) | Zone | ✅ | ✅ | +| [cloudflare_worker_script](https://www.terraform.io/docs/providers/cloudflare/r/worker_script) | Account | ❌ | ❌ | +| [cloudflare_workers_kv](https://www.terraform.io/docs/providers/cloudflare/r/workers_kv) | Account | ❌ | ❌ | +| [cloudflare_workers_kv_namespace](https://www.terraform.io/docs/providers/cloudflare/r/workers_kv_namespace) | Account | ✅ | ✅ | +| [cloudflare_zone](https://www.terraform.io/docs/providers/cloudflare/r/zone) | Account | ✅ | ✅ | +| [cloudflare_zone_dnssec](https://www.terraform.io/docs/providers/cloudflare/r/zone_dnssec) | Zone | ❌ | ❌ | +| [cloudflare_zone_lockdown](https://www.terraform.io/docs/providers/cloudflare/r/zone_lockdown) | Zone | ✅ | ✅ | +| [cloudflare_zone_settings_override](https://www.terraform.io/docs/providers/cloudflare/r/zone_settings_override) | Zone | ✅ | ❌ | ## Testing diff --git a/internal/app/cf-terraforming/cmd/generate.go b/internal/app/cf-terraforming/cmd/generate.go index f8b22f8f5..3f9bf92f2 100644 --- a/internal/app/cf-terraforming/cmd/generate.go +++ b/internal/app/cf-terraforming/cmd/generate.go @@ -686,8 +686,40 @@ func generateResources() func(cmd *cobra.Command, args []string) { } } - //case "cloudflare_pages_domain": - // jsonPayload, err := api.GetPagesDomain(context.Background(), cloudflare.PagesDomainParameters{AccountID: accountID}) + case "cloudflare_pages_domain": + pagesProjectsPayload, _, err := api.ListPagesProjects(context.Background(), accountID, cloudflare.PaginationOptions{}) + if err != nil { + log.Fatal(err) + } + type pagesDomainInfo struct { + ID string `json:"id"` + Domain string `json:"domain"` + ProjectName string `json:"project_name"` + } + var domains []pagesDomainInfo + for _, project := range pagesProjectsPayload { + jsonPayload, err := api.GetPagesDomains(context.Background(), cloudflare.PagesDomainsParameters{ + AccountID: accountID, + ProjectName: project.Name, + }) + if err != nil { + log.Fatal(err) + } + for _, domain := range jsonPayload { + domains = append(domains, pagesDomainInfo{ + ID: domain.ID, + Domain: domain.Name, + ProjectName: project.Name, + }) + } + } + resourceCount = len(domains) + m, _ := json.Marshal(domains) + err = json.Unmarshal(m, &jsonStructData) + if err != nil { + log.Fatal(err) + } + case "cloudflare_pages_project": jsonPayload, _, err := api.ListPagesProjects(context.Background(), accountID, cloudflare.PaginationOptions{}) if err != nil { From b07f049ebdbd3e0764a4571c70f16e1dcaf46526 Mon Sep 17 00:00:00 2001 From: Jacob White Date: Thu, 20 Oct 2022 20:05:20 -0400 Subject: [PATCH 03/13] Remove testing file --- testing/main.tf | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 testing/main.tf diff --git a/testing/main.tf b/testing/main.tf deleted file mode 100644 index e69de29bb..000000000 From b4b49dbd3340856643b4d1e03b008bd498fa1731 Mon Sep 17 00:00:00 2001 From: Jacob White Date: Thu, 20 Oct 2022 23:53:58 -0400 Subject: [PATCH 04/13] Fix formatting on import file --- internal/app/cf-terraforming/cmd/import.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/app/cf-terraforming/cmd/import.go b/internal/app/cf-terraforming/cmd/import.go index be084bcd0..a7b73cdd8 100644 --- a/internal/app/cf-terraforming/cmd/import.go +++ b/internal/app/cf-terraforming/cmd/import.go @@ -268,7 +268,7 @@ func runImport() func(cmd *cobra.Command, args []string) { if err != nil { log.Fatal(err) } - for i, _ := range jsonStructData { + for i := range jsonStructData { jsonStructData[i].(map[string]interface{})["id"] = jsonStructData[i].(map[string]interface{})["name"] } case "cloudflare_rate_limit": From b9d97129f2d631dd16953219eef235cae133aa6c Mon Sep 17 00:00:00 2001 From: Jacob White Date: Fri, 21 Oct 2022 17:21:07 -0400 Subject: [PATCH 05/13] Update test data --- .../app/cf-terraforming/cmd/generate_test.go | 1 + .../cloudflare/cloudflare_pages_project.yml | 418 ++++++++++-------- 2 files changed, 230 insertions(+), 189 deletions(-) diff --git a/internal/app/cf-terraforming/cmd/generate_test.go b/internal/app/cf-terraforming/cmd/generate_test.go index a9d569e49..88dd4907b 100644 --- a/internal/app/cf-terraforming/cmd/generate_test.go +++ b/internal/app/cf-terraforming/cmd/generate_test.go @@ -107,6 +107,7 @@ func TestResourceGeneration(t *testing.T) { "cloudflare managed headers": {identiferType: "zone", resourceType: "cloudflare_managed_headers", testdataFilename: "cloudflare_managed_headers"}, "cloudflare origin CA certificate": {identiferType: "zone", resourceType: "cloudflare_origin_ca_certificate", testdataFilename: "cloudflare_origin_ca_certificate"}, "cloudflare page rule": {identiferType: "zone", resourceType: "cloudflare_page_rule", testdataFilename: "cloudflare_page_rule"}, + "cloudflare pages project": {identiferType: "account", resourceType: "cloudflared_pages_project", testdataFilename: "cloudflare_pages_project"}, "cloudflare rate limit": {identiferType: "zone", resourceType: "cloudflare_rate_limit", testdataFilename: "cloudflare_rate_limit"}, "cloudflare record CAA": {identiferType: "zone", resourceType: "cloudflare_record", testdataFilename: "cloudflare_record_caa"}, "cloudflare record PTR": {identiferType: "zone", resourceType: "cloudflare_record", testdataFilename: "cloudflare_record_ptr"}, diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yml index 6bfb0cdb8..e32fb0cfd 100644 --- a/testdata/cloudflare/cloudflare_pages_project.yml +++ b/testdata/cloudflare/cloudflare_pages_project.yml @@ -29,17 +29,17 @@ interactions: "production_branch": "main", "pr_comments_enabled": true, "deployments_enabled": true, - "preview_deployment_setting": "custom", - "preview_branch_includes": [ - "release/*", - "production", - "main" - ], - "preview_branch_excludes": [ - "dependabot/*", - "dev", - "*/ignore" - ] + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] } }, "build_config": { @@ -48,214 +48,254 @@ interactions: "root_dir": "/", "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", "web_analytics_token": "c05bb382259183db3a0a822b64c11459" - }, + }, "deployment_configs": { "preview": { "env_vars": { "BUILD_VERSION": { "value": "1.2" }, - "ENV": { + "ENVIRONMENT": { "value": "preview" } }, - "compatibility_date": "2022-08-15", - "compatibility_flags": ["preview_flag"] + "d1_databases": { + "D1_BINDING": { + "id": "a94509c6-0757-43f3-b053-474b0ab10935" + } + }, + "kv_namespaces": { + "KV_BINDING": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + } }, + "durable_object_namespaces": { + "DO_BINDING": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + }, + "r2_buckets": { + "R2_BINDING": { + "name": "some-bucket" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "preview_flag" + ] + }, "production": { "env_vars": { "BUILD_VERSION": { "value": "1.2" - }, - "ENV": { - "value": "production" - } }, - "d1_databases": { - "D1_BINDING": { - "id": "a94509c6-0757-43f3-b053-474b0ab10935" - } - }, - "kv_namespaces": { - "KV_BINDING": { - "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" - } - }, - "durable_object_namespaces": { - "DO_BINDING": { - "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" - } - }, - "r2_buckets": { - "R2_BINDING": { - "name": "some-bucket" - } - }, - "compatibility_date": "2022-08-15", - "compatibility_flags": ["production_flag"] - } - }, - "latest_deployment": { - "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", - "short_id": "c35216d1", - "project_id": "5a321fc7-3162-7d36-adce-1213996a7", - "project_name": "pages-test", - "environment": "preview", - "production_branch": "main", - "url": "https://c35216d1.pages-test.pages.dev", - "created_on": "2021-03-09T00:55:03.923456Z", - "modified_on": "2021-03-09T00:58:59.045655Z", - "aliases": [ - "https://branchname.pages-test.pages.dev" - ], - "latest_stage": { - "name": "deploy", - "started_on": "2021-03-09T00:55:03.923456Z", - "ended_on": "2021-03-09T00:58:59.045655Z", - "status": "success" + "ENV": { + "value": "production" + } }, - "env_vars": { - "BUILD_VERSION": { - "value": "1.2" + "d1_databases": { + "D1_BINDING_1": { + "id": "a94509c6-0757-43f3-b053-474b0ab10935" }, - "ENV": { - "value": "STAGING" + "D1_BINDING_2": { + "id": "a399414b-c697-409a-a688-377db6433cd9" } }, - "compatibility_date": "2022-08-15", - "compatibility_flags": ["deployment_flag"], - "deployment_trigger": { - "type": "ad_hoc", - "metadata": { - "branch": "main", - "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", - "commit_message": "Update index.html" - } + "kv_namespaces": { + "KV_BINDING_1": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" }, - "stages": [ - { - "name": "queued", - "started_on": "2021-06-03T15:38:15.608194Z", - "ended_on": "2021-06-03T15:39:03.134378Z", - "status": "active" + "KV_BINDING_2": { + "namespace_id": "3cdca5f8bb22bc390deee10ebbb36be5" + } + }, + "durable_object_namespaces": { + "DO_BINDING_1": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" }, - { - "name": "test_stage_1", - "started_on": null, - "ended_on": null, - "status": "idle" + "DO_BINDING_2": { + "namespace_id": "3cdca5f8bb22bc390deee10ebbb36be5" } - ], - "build_config": { - "build_command": "npm run build", - "destination_dir": "build", - "root_dir": "/", - "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", - "web_analytics_token": "c05bb382259183db3a0a822b64c11459" }, - "source": { - "type": "github", - "config": { - "owner": "cloudflare", - "repo_name": "pages-test", - "production_branch": "main", - "pr_comments_enabled": true, - "deployments_enabled": true, - "preview_deployment_setting": "custom", - "preview_branch_includes": [ - "release/*", - "production", - "main" - ], - "preview_branch_excludes": [ - "dependabot/*", - "dev", - "*/ignore" - ] + "r2_buckets": { + "R2_BINDING_1": { + "name": "some-bucket" + }, + "R2_BINDING_2": { + "name": "other-bucket" } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "production_flag" + ] + } + }, + "latest_deployment": { + "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", + "short_id": "c35216d1", + "project_id": "5a321fc7-3162-7d36-adce-1213996a7", + "project_name": "pages-test", + "environment": "preview", + "production_branch": "main", + "url": "https://c35216d1.pages-test.pages.dev", + "created_on": "2021-03-09T00:55:03.923456Z", + "modified_on": "2021-03-09T00:58:59.045655Z", + "aliases": [ + "https://branchname.pages-test.pages.dev" + ], + "latest_stage": { + "name": "deploy", + "started_on": "2021-03-09T00:55:03.923456Z", + "ended_on": "2021-03-09T00:58:59.045655Z", + "status": "success" + }, + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "STAGING" } }, - "canonical_deployment": { - "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", - "short_id": "c35216d1", - "project_id": "5a321fc7-3162-7d36-adce-1213996a7", - "project_name": "pages-test", - "environment": "preview", - "url": "https://c35216d1.pages-test.pages.dev", - "created_on": "2021-03-09T00:55:03.923456Z", - "modified_on": "2021-03-09T00:58:59.045655Z", - "production_branch": "main", - "aliases": [ - "https://branchname.pages-test.pages.dev" + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "deployment_flag" + ], + "deployment_trigger": { + "type": "ad_hoc", + "metadata": { + "branch": "main", + "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", + "commit_message": "Update index.html" + } + }, + "stages": [ + { + "name": "queued", + "started_on": "2021-06-03T15:38:15.608194Z", + "ended_on": "2021-06-03T15:39:03.134378Z", + "status": "active" + }, + { + "name": "test_stage_1", + "started_on": null, + "ended_on": null, + "status": "idle" + } + ], + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" + }, + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" ], - "latest_stage": { - "name": "deploy", - "started_on": "2021-03-09T00:55:03.923456Z", - "ended_on": "2021-03-09T00:58:59.045655Z", - "status": "success" - }, - "env_vars": { - "BUILD_VERSION": { - "value": "1.2" - }, - "ENV": { - "value": "STAGING" - } - }, - "compatibility_date": "2022-08-15", - "compatibility_flags": ["deployment_flag"], - "deployment_trigger": { - "type": "ad_hoc", - "metadata": { - "branch": "main", - "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", - "commit_message": "Update index.html" - } - }, - "stages": [ - { - "name": "queued", - "started_on": "2021-06-03T15:38:15.608194Z", - "ended_on": "2021-06-03T15:39:03.134378Z", - "status": "active" - }, - { - "name": "test_stage_1", - "started_on": null, - "ended_on": null, - "status": "idle" - } + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] + } + } + }, + "canonical_deployment": { + "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", + "short_id": "c35216d1", + "project_id": "5a321fc7-3162-7d36-adce-1213996a7", + "project_name": "pages-test", + "environment": "preview", + "url": "https://c35216d1.pages-test.pages.dev", + "created_on": "2021-03-09T00:55:03.923456Z", + "modified_on": "2021-03-09T00:58:59.045655Z", + "production_branch": "main", + "aliases": [ + "https://branchname.pages-test.pages.dev" + ], + "latest_stage": { + "name": "deploy", + "started_on": "2021-03-09T00:55:03.923456Z", + "ended_on": "2021-03-09T00:58:59.045655Z", + "status": "success" + }, + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "STAGING" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "deployment_flag" + ], + "deployment_trigger": { + "type": "ad_hoc", + "metadata": { + "branch": "main", + "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", + "commit_message": "Update index.html" + } + }, + "stages": [ + { + "name": "queued", + "started_on": "2021-06-03T15:38:15.608194Z", + "ended_on": "2021-06-03T15:39:03.134378Z", + "status": "active" + }, + { + "name": "test_stage_1", + "started_on": null, + "ended_on": null, + "status": "idle" + } + ], + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" + }, + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" ], - "build_config": { - "build_command": "npm run build", - "destination_dir": "build", - "root_dir": "/", - "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", - "web_analytics_token": "c05bb382259183db3a0a822b64c11459" - }, - "source": { - "type": "github", - "config": { - "owner": "cloudflare", - "repo_name": "pages-test", - "production_branch": "main", - "pr_comments_enabled": true, - "deployments_enabled": true, - "preview_deployment_setting": "custom", - "preview_branch_includes": [ - "release/*", - "production", - "main" - ], - "preview_branch_excludes": [ - "dependabot/*", - "dev", - "*/ignore" - ] - } - } + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] } } + } + } headers: Content-Type: - application/json From 439eaa3c168822cf94f5152716b3df236674b7a6 Mon Sep 17 00:00:00 2001 From: Jacob White Date: Fri, 21 Oct 2022 17:25:41 -0400 Subject: [PATCH 06/13] Fix typo of resource name --- internal/app/cf-terraforming/cmd/generate_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/app/cf-terraforming/cmd/generate_test.go b/internal/app/cf-terraforming/cmd/generate_test.go index 88dd4907b..61995f138 100644 --- a/internal/app/cf-terraforming/cmd/generate_test.go +++ b/internal/app/cf-terraforming/cmd/generate_test.go @@ -107,7 +107,7 @@ func TestResourceGeneration(t *testing.T) { "cloudflare managed headers": {identiferType: "zone", resourceType: "cloudflare_managed_headers", testdataFilename: "cloudflare_managed_headers"}, "cloudflare origin CA certificate": {identiferType: "zone", resourceType: "cloudflare_origin_ca_certificate", testdataFilename: "cloudflare_origin_ca_certificate"}, "cloudflare page rule": {identiferType: "zone", resourceType: "cloudflare_page_rule", testdataFilename: "cloudflare_page_rule"}, - "cloudflare pages project": {identiferType: "account", resourceType: "cloudflared_pages_project", testdataFilename: "cloudflare_pages_project"}, + "cloudflare pages project": {identiferType: "account", resourceType: "cloudflare_pages_project", testdataFilename: "cloudflare_pages_project"}, "cloudflare rate limit": {identiferType: "zone", resourceType: "cloudflare_rate_limit", testdataFilename: "cloudflare_rate_limit"}, "cloudflare record CAA": {identiferType: "zone", resourceType: "cloudflare_record", testdataFilename: "cloudflare_record_caa"}, "cloudflare record PTR": {identiferType: "zone", resourceType: "cloudflare_record", testdataFilename: "cloudflare_record_ptr"}, From b8e0246e66fe88abec9237aeaa4b2bf03185d2fd Mon Sep 17 00:00:00 2001 From: Jacob White Date: Fri, 21 Oct 2022 17:33:01 -0400 Subject: [PATCH 07/13] Fix URL used with test --- testdata/cloudflare/cloudflare_pages_project.yml | 2 +- testdata/terraform/cloudflare_pages_project/test.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yml index e32fb0cfd..7c140cd08 100644 --- a/testdata/cloudflare/cloudflare_pages_project.yml +++ b/testdata/cloudflare/cloudflare_pages_project.yml @@ -7,7 +7,7 @@ interactions: headers: Content-Type: - application/json - url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects + url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects/test_project method: GET response: body: | diff --git a/testdata/terraform/cloudflare_pages_project/test.tf b/testdata/terraform/cloudflare_pages_project/test.tf index 3ab6eac29..6e7c577b6 100644 --- a/testdata/terraform/cloudflare_pages_project/test.tf +++ b/testdata/terraform/cloudflare_pages_project/test.tf @@ -1,6 +1,6 @@ resource "cloudflare_pages_project" "terraform_managed_resource" { account_id = "f037e56e89293a057740de681ac9abbe" - name = "Test Pages Project" + name = "test_project" production_branch = "main" build_config { build_command = "npm run build" From 6436e45dc8944d4b23dca26aefac0d014e6407ec Mon Sep 17 00:00:00 2001 From: Jacob White Date: Fri, 21 Oct 2022 23:29:49 -0400 Subject: [PATCH 08/13] Fix test response body --- .../cloudflare/cloudflare_pages_project.yml | 539 +++++++++--------- 1 file changed, 273 insertions(+), 266 deletions(-) diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yml index 7c140cd08..89936e564 100644 --- a/testdata/cloudflare/cloudflare_pages_project.yml +++ b/testdata/cloudflare/cloudflare_pages_project.yml @@ -7,294 +7,301 @@ interactions: headers: Content-Type: - application/json - url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects/test_project + url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects method: GET response: body: | { - "name": "Test Pages Project", - "id": "5a321fc7-3162-7d36-adce-1213996a7", - "created_on": "2021-01-01T00:00:00Z", - "subdomain": "test.pages.dev", - "domains": [ - "testdomain.com", - "testdomain.org" - ], - "production_branch": "main", - "source": { - "type": "github", - "config": { - "owner": "cloudflare", - "repo_name": "pages-test", - "production_branch": "main", - "pr_comments_enabled": true, - "deployments_enabled": true, - "preview_deployment_setting": "custom", - "preview_branch_includes": [ - "release/*", - "production", - "main" + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "name": "Test Pages Project", + "id": "5a321fc7-3162-7d36-adce-1213996a7", + "created_on": "2021-01-01T00:00:00Z", + "subdomain": "test.pages.dev", + "domains": [ + "testdomain.com", + "testdomain.org" ], - "preview_branch_excludes": [ - "dependabot/*", - "dev", - "*/ignore" - ] - } - }, - "build_config": { - "build_command": "npm run build", - "destination_dir": "build", - "root_dir": "/", - "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", - "web_analytics_token": "c05bb382259183db3a0a822b64c11459" - }, - "deployment_configs": { - "preview": { - "env_vars": { - "BUILD_VERSION": { - "value": "1.2" - }, - "ENVIRONMENT": { - "value": "preview" - } - }, - "d1_databases": { - "D1_BINDING": { - "id": "a94509c6-0757-43f3-b053-474b0ab10935" - } - }, - "kv_namespaces": { - "KV_BINDING": { - "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" - } - }, - "durable_object_namespaces": { - "DO_BINDING": { - "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + "production_branch": "main", + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] } }, - "r2_buckets": { - "R2_BINDING": { - "name": "some-bucket" - } + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" }, - "compatibility_date": "2022-08-15", - "compatibility_flags": [ - "preview_flag" - ] - }, - "production": { - "env_vars": { - "BUILD_VERSION": { - "value": "1.2" + "deployment_configs": { + "preview": { + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENVIRONMENT": { + "value": "preview" + } + }, + "d1_databases": { + "D1_BINDING": { + "id": "a94509c6-0757-43f3-b053-474b0ab10935" + } + }, + "kv_namespaces": { + "KV_BINDING": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + }, + "durable_object_namespaces": { + "DO_BINDING": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + }, + "r2_buckets": { + "R2_BINDING": { + "name": "some-bucket" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "preview_flag" + ] }, - "ENV": { - "value": "production" + "production": { + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "production" + } + }, + "d1_databases": { + "D1_BINDING_1": { + "id": "a94509c6-0757-43f3-b053-474b0ab10935" + }, + "D1_BINDING_2": { + "id": "a399414b-c697-409a-a688-377db6433cd9" + } + }, + "kv_namespaces": { + "KV_BINDING_1": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + }, + "KV_BINDING_2": { + "namespace_id": "3cdca5f8bb22bc390deee10ebbb36be5" + } + }, + "durable_object_namespaces": { + "DO_BINDING_1": { + "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + }, + "DO_BINDING_2": { + "namespace_id": "3cdca5f8bb22bc390deee10ebbb36be5" + } + }, + "r2_buckets": { + "R2_BINDING_1": { + "name": "some-bucket" + }, + "R2_BINDING_2": { + "name": "other-bucket" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "production_flag" + ] } }, - "d1_databases": { - "D1_BINDING_1": { - "id": "a94509c6-0757-43f3-b053-474b0ab10935" + "latest_deployment": { + "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", + "short_id": "c35216d1", + "project_id": "5a321fc7-3162-7d36-adce-1213996a7", + "project_name": "pages-test", + "environment": "preview", + "production_branch": "main", + "url": "https://c35216d1.pages-test.pages.dev", + "created_on": "2021-03-09T00:55:03.923456Z", + "modified_on": "2021-03-09T00:58:59.045655Z", + "aliases": [ + "https://branchname.pages-test.pages.dev" + ], + "latest_stage": { + "name": "deploy", + "started_on": "2021-03-09T00:55:03.923456Z", + "ended_on": "2021-03-09T00:58:59.045655Z", + "status": "success" }, - "D1_BINDING_2": { - "id": "a399414b-c697-409a-a688-377db6433cd9" - } - }, - "kv_namespaces": { - "KV_BINDING_1": { - "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "STAGING" + } }, - "KV_BINDING_2": { - "namespace_id": "3cdca5f8bb22bc390deee10ebbb36be5" - } - }, - "durable_object_namespaces": { - "DO_BINDING_1": { - "namespace_id": "5eb63bbbe01eeed093cb22bb8f5acdc3" + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "deployment_flag" + ], + "deployment_trigger": { + "type": "ad_hoc", + "metadata": { + "branch": "main", + "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", + "commit_message": "Update index.html" + } }, - "DO_BINDING_2": { - "namespace_id": "3cdca5f8bb22bc390deee10ebbb36be5" - } - }, - "r2_buckets": { - "R2_BINDING_1": { - "name": "some-bucket" + "stages": [ + { + "name": "queued", + "started_on": "2021-06-03T15:38:15.608194Z", + "ended_on": "2021-06-03T15:39:03.134378Z", + "status": "active" + }, + { + "name": "test_stage_1", + "started_on": null, + "ended_on": null, + "status": "idle" + } + ], + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" }, - "R2_BINDING_2": { - "name": "other-bucket" + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] + } } }, - "compatibility_date": "2022-08-15", - "compatibility_flags": [ - "production_flag" - ] - } - }, - "latest_deployment": { - "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", - "short_id": "c35216d1", - "project_id": "5a321fc7-3162-7d36-adce-1213996a7", - "project_name": "pages-test", - "environment": "preview", - "production_branch": "main", - "url": "https://c35216d1.pages-test.pages.dev", - "created_on": "2021-03-09T00:55:03.923456Z", - "modified_on": "2021-03-09T00:58:59.045655Z", - "aliases": [ - "https://branchname.pages-test.pages.dev" - ], - "latest_stage": { - "name": "deploy", - "started_on": "2021-03-09T00:55:03.923456Z", - "ended_on": "2021-03-09T00:58:59.045655Z", - "status": "success" - }, - "env_vars": { - "BUILD_VERSION": { - "value": "1.2" - }, - "ENV": { - "value": "STAGING" - } - }, - "compatibility_date": "2022-08-15", - "compatibility_flags": [ - "deployment_flag" - ], - "deployment_trigger": { - "type": "ad_hoc", - "metadata": { - "branch": "main", - "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", - "commit_message": "Update index.html" - } - }, - "stages": [ - { - "name": "queued", - "started_on": "2021-06-03T15:38:15.608194Z", - "ended_on": "2021-06-03T15:39:03.134378Z", - "status": "active" - }, - { - "name": "test_stage_1", - "started_on": null, - "ended_on": null, - "status": "idle" - } - ], - "build_config": { - "build_command": "npm run build", - "destination_dir": "build", - "root_dir": "/", - "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", - "web_analytics_token": "c05bb382259183db3a0a822b64c11459" - }, - "source": { - "type": "github", - "config": { - "owner": "cloudflare", - "repo_name": "pages-test", + "canonical_deployment": { + "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", + "short_id": "c35216d1", + "project_id": "5a321fc7-3162-7d36-adce-1213996a7", + "project_name": "pages-test", + "environment": "preview", + "url": "https://c35216d1.pages-test.pages.dev", + "created_on": "2021-03-09T00:55:03.923456Z", + "modified_on": "2021-03-09T00:58:59.045655Z", "production_branch": "main", - "pr_comments_enabled": true, - "deployments_enabled": true, - "preview_deployment_setting": "custom", - "preview_branch_includes": [ - "release/*", - "production", - "main" + "aliases": [ + "https://branchname.pages-test.pages.dev" ], - "preview_branch_excludes": [ - "dependabot/*", - "dev", - "*/ignore" - ] - } - } - }, - "canonical_deployment": { - "id": "c35216d1-ebac-1a3a-d56c-ad74e54e5", - "short_id": "c35216d1", - "project_id": "5a321fc7-3162-7d36-adce-1213996a7", - "project_name": "pages-test", - "environment": "preview", - "url": "https://c35216d1.pages-test.pages.dev", - "created_on": "2021-03-09T00:55:03.923456Z", - "modified_on": "2021-03-09T00:58:59.045655Z", - "production_branch": "main", - "aliases": [ - "https://branchname.pages-test.pages.dev" - ], - "latest_stage": { - "name": "deploy", - "started_on": "2021-03-09T00:55:03.923456Z", - "ended_on": "2021-03-09T00:58:59.045655Z", - "status": "success" - }, - "env_vars": { - "BUILD_VERSION": { - "value": "1.2" - }, - "ENV": { - "value": "STAGING" - } - }, - "compatibility_date": "2022-08-15", - "compatibility_flags": [ - "deployment_flag" - ], - "deployment_trigger": { - "type": "ad_hoc", - "metadata": { - "branch": "main", - "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", - "commit_message": "Update index.html" - } - }, - "stages": [ - { - "name": "queued", - "started_on": "2021-06-03T15:38:15.608194Z", - "ended_on": "2021-06-03T15:39:03.134378Z", - "status": "active" - }, - { - "name": "test_stage_1", - "started_on": null, - "ended_on": null, - "status": "idle" - } - ], - "build_config": { - "build_command": "npm run build", - "destination_dir": "build", - "root_dir": "/", - "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", - "web_analytics_token": "c05bb382259183db3a0a822b64c11459" - }, - "source": { - "type": "github", - "config": { - "owner": "cloudflare", - "repo_name": "pages-test", - "production_branch": "main", - "pr_comments_enabled": true, - "deployments_enabled": true, - "preview_deployment_setting": "custom", - "preview_branch_includes": [ - "release/*", - "production", - "main" + "latest_stage": { + "name": "deploy", + "started_on": "2021-03-09T00:55:03.923456Z", + "ended_on": "2021-03-09T00:58:59.045655Z", + "status": "success" + }, + "env_vars": { + "BUILD_VERSION": { + "value": "1.2" + }, + "ENV": { + "value": "STAGING" + } + }, + "compatibility_date": "2022-08-15", + "compatibility_flags": [ + "deployment_flag" + ], + "deployment_trigger": { + "type": "ad_hoc", + "metadata": { + "branch": "main", + "commit_hash": "fa26be19de6bff93f70bc2308434e4a440bbad02", + "commit_message": "Update index.html" + } + }, + "stages": [ + { + "name": "queued", + "started_on": "2021-06-03T15:38:15.608194Z", + "ended_on": "2021-06-03T15:39:03.134378Z", + "status": "active" + }, + { + "name": "test_stage_1", + "started_on": null, + "ended_on": null, + "status": "idle" + } ], - "preview_branch_excludes": [ - "dependabot/*", - "dev", - "*/ignore" - ] + "build_config": { + "build_command": "npm run build", + "destination_dir": "build", + "root_dir": "/", + "web_analytics_tag": "0ee1d926cd60d2618a108d4232a75b73", + "web_analytics_token": "c05bb382259183db3a0a822b64c11459" + }, + "source": { + "type": "github", + "config": { + "owner": "cloudflare", + "repo_name": "pages-test", + "production_branch": "main", + "pr_comments_enabled": true, + "deployments_enabled": true, + "preview_deployment_setting": "custom", + "preview_branch_includes": [ + "release/*", + "production", + "main" + ], + "preview_branch_excludes": [ + "dependabot/*", + "dev", + "*/ignore" + ] + } + } } } - } + ] } headers: Content-Type: From dce9aab560c9a0b4031055956084f505c5795432 Mon Sep 17 00:00:00 2001 From: Jacob White Date: Sat, 22 Oct 2022 14:56:24 -0400 Subject: [PATCH 09/13] Update actions versions --- .github/workflows/lint.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index e9e9b79a6..37a7ca47f 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -17,7 +17,7 @@ jobs: uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - - uses: actions/cache@v2.1.3 + - uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 347200962..202460a01 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 # needed for `only-new-issues` to compare diffs - - uses: actions/cache@v2.1.3 + - uses: actions/cache@v3 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} From 8f1907c24c007659b635533d950ef2e3995c096e Mon Sep 17 00:00:00 2001 From: Jacob White Date: Sat, 22 Oct 2022 15:15:42 -0400 Subject: [PATCH 10/13] Add verbose default to debug for testing --- internal/app/cf-terraforming/cmd/root.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/app/cf-terraforming/cmd/root.go b/internal/app/cf-terraforming/cmd/root.go index 7fb7c03f7..e2e762a52 100644 --- a/internal/app/cf-terraforming/cmd/root.go +++ b/internal/app/cf-terraforming/cmd/root.go @@ -137,11 +137,13 @@ func initConfig() { log.Debug("using config file:", viper.ConfigFileUsed()) } - var cfgLogLevel = logrus.InfoLevel + // var cfgLogLevel = logrus.InfoLevel - if verbose { - cfgLogLevel = logrus.DebugLevel - } + // if verbose { + // cfgLogLevel = logrus.DebugLevel + // } + var cfgLogLevel = logrus.InfoLevel + cfgLogLevel = logrus.DebugLevel log.SetLevel(cfgLogLevel) } From ac406cc6e51b4bb327049cc5e09d2c21fa45a72e Mon Sep 17 00:00:00 2001 From: Jacob White Date: Mon, 24 Oct 2022 18:13:27 -0400 Subject: [PATCH 11/13] Change test data path --- internal/app/cf-terraforming/cmd/root.go | 10 ++++------ testdata/cloudflare/cloudflare_pages_project.yml | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/app/cf-terraforming/cmd/root.go b/internal/app/cf-terraforming/cmd/root.go index e2e762a52..7fb7c03f7 100644 --- a/internal/app/cf-terraforming/cmd/root.go +++ b/internal/app/cf-terraforming/cmd/root.go @@ -137,13 +137,11 @@ func initConfig() { log.Debug("using config file:", viper.ConfigFileUsed()) } - // var cfgLogLevel = logrus.InfoLevel - - // if verbose { - // cfgLogLevel = logrus.DebugLevel - // } var cfgLogLevel = logrus.InfoLevel - cfgLogLevel = logrus.DebugLevel + + if verbose { + cfgLogLevel = logrus.DebugLevel + } log.SetLevel(cfgLogLevel) } diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yml index 89936e564..584e8138c 100644 --- a/testdata/cloudflare/cloudflare_pages_project.yml +++ b/testdata/cloudflare/cloudflare_pages_project.yml @@ -7,7 +7,7 @@ interactions: headers: Content-Type: - application/json - url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects + url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects/test_project method: GET response: body: | From 3cc36825c13fb0f7c13e567d13d3a77feae7955f Mon Sep 17 00:00:00 2001 From: Jacob White Date: Tue, 25 Oct 2022 21:43:12 -0400 Subject: [PATCH 12/13] Fix URL --- testdata/cloudflare/cloudflare_pages_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yml index 584e8138c..89936e564 100644 --- a/testdata/cloudflare/cloudflare_pages_project.yml +++ b/testdata/cloudflare/cloudflare_pages_project.yml @@ -7,7 +7,7 @@ interactions: headers: Content-Type: - application/json - url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects/test_project + url: https://api.cloudflare.com/client/v4/accounts/f037e56e89293a057740de681ac9abbe/pages/projects method: GET response: body: | From b84eed0753b3f0cae4720d4aad30d80444dc5e1e Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Mon, 31 Oct 2022 15:31:46 +1100 Subject: [PATCH 13/13] fix file extension to mock correctly --- ...cloudflare_pages_project.yml => cloudflare_pages_project.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename testdata/cloudflare/{cloudflare_pages_project.yml => cloudflare_pages_project.yaml} (100%) diff --git a/testdata/cloudflare/cloudflare_pages_project.yml b/testdata/cloudflare/cloudflare_pages_project.yaml similarity index 100% rename from testdata/cloudflare/cloudflare_pages_project.yml rename to testdata/cloudflare/cloudflare_pages_project.yaml