From b16071894ded54423c1fec6a9ba0d8ec5e6f098e Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Fri, 15 Sep 2023 08:13:14 -0400 Subject: [PATCH] DXCDT-539: Miscellaneous `tf generate` cleanup ahead of release (#845) * Allowing relationship resources to be included in resource argument flag * Changing provider version to 1.0.0-beta.4 * Removing auth0_log_stream from default list * Adding experimental designation * Adding reference to guide, examples * Updating changelog * Doc tweaks * Fixing example indentation * Fixing flaky unit test * Changing note to warning * Removing export alias, adding abbreviated args --------- Co-authored-by: Will Vedder --- CHANGELOG.md | 18 ++++++++++++++++++ docs/auth0_terraform_generate.md | 15 ++++++++++----- internal/cli/actions_test.go | 2 +- internal/cli/terraform.go | 23 ++++++++++++++--------- internal/cli/terraform_fetcher.go | 2 +- internal/cli/terraform_test.go | 2 +- 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56e5a0afd..03d0c6e9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v1.1.0](https://github.com/auth0/auth0-cli/tree/v1.0.1) (Sept 15, 2023) + +[Full Changelog](https://github.com/auth0/auth0-cli/compare/v1.0.1...v1.1.0) + +### Added + +- `terraform generate` command for auto-generating Terraform configuration from your Auth0 tenant. Refer to the [Generate Terraform Config guide](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/generate_terraform_config) for instructions on how to use. [#792] +- Retry for select HTTP error codes [#839] + +### Fixed + +- Passing of multiple secrets for `auth0 action` commands [#844] +- Show non-ready custom domains with `auth0 domains list` command [#781] + ## [v1.0.1](https://github.com/auth0/auth0-cli/tree/v1.0.1) (Apr 20, 2023) [Full Changelog](https://github.com/auth0/auth0-cli/compare/v1.0.0...v1.0.1) @@ -182,6 +196,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updating of action triggers which inevitably results in error [#597] [unreleased]: https://github.com/auth0/auth0-cli/compare/v1.0.0...HEAD +[#792]: https://github.com/auth0/auth0-cli/issues/792 +[#839]: https://github.com/auth0/auth0-cli/issues/839 +[#844]: https://github.com/auth0/auth0-cli/issues/844 +[#781]: https://github.com/auth0/auth0-cli/issues/781 [#743]: https://github.com/auth0/auth0-cli/issues/743 [#747]: https://github.com/auth0/auth0-cli/issues/747 [#745]: https://github.com/auth0/auth0-cli/issues/745 diff --git a/docs/auth0_terraform_generate.md b/docs/auth0_terraform_generate.md index e88693ad9..b3f8f89e5 100644 --- a/docs/auth0_terraform_generate.md +++ b/docs/auth0_terraform_generate.md @@ -5,11 +5,13 @@ has_toc: false --- # auth0 terraform generate -This command is designed to streamline the process of generating Terraform configuration files for your Auth0 resources, serving as a bridge between the two. +(Experimental) This command is designed to streamline the process of generating Terraform configuration files for your Auth0 resources, serving as a bridge between the two. -It automatically scans your Auth0 Tenant and compiles a set of Terraform configuration files based on the existing resources and configurations. +It automatically scans your Auth0 Tenant and compiles a set of Terraform configuration files (HCL) based on the existing resources and configurations. -The generated Terraform files are written in HashiCorp Configuration Language (HCL). +Refer to the [instructional guide](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/generate_terraform_config) for specific details on how to use this command. + +**Warning:** This command is experimental and is subject to change in future versions. ## Usage ``` @@ -19,7 +21,10 @@ auth0 terraform generate [flags] ## Examples ``` - + auth0 tf generate + auth0 tf generate -o tmp-auth0-tf + auth0 tf generate -o tmp-auth0-tf -r auth0_client + auth0 tf generate --output-dir tmp-auth0-tf --resources auth0_action,auth0_tenant,auth0_client ``` @@ -28,7 +33,7 @@ auth0 terraform generate [flags] ``` --force Skip confirmation. -o, --output-dir string Output directory for the generated Terraform config files. If not provided, the files will be saved in the current working directory. (default "./") - -r, --resources strings Resource types to generate Terraform config for. If not provided, config files for all available resources will be generated. (default [auth0_action,auth0_attack_protection,auth0_branding,auth0_client,auth0_client_grant,auth0_connection,auth0_custom_domain,auth0_email_provider,auth0_guardian,auth0_log_stream,auth0_organization,auth0_pages,auth0_prompt,auth0_prompt_custom_text,auth0_resource_server,auth0_role,auth0_tenant,auth0_trigger_actions]) + -r, --resources strings Resource types to generate Terraform config for. If not provided, config files for all available resources will be generated. (default [auth0_action,auth0_attack_protection,auth0_branding,auth0_client,auth0_client_grant,auth0_connection,auth0_custom_domain,auth0_email_provider,auth0_guardian,auth0_organization,auth0_pages,auth0_prompt,auth0_prompt_custom_text,auth0_resource_server,auth0_role,auth0_tenant,auth0_trigger_actions]) ``` diff --git a/internal/cli/actions_test.go b/internal/cli/actions_test.go index 15e3882c9..b92ed7e63 100644 --- a/internal/cli/actions_test.go +++ b/internal/cli/actions_test.go @@ -233,7 +233,7 @@ func TestActionsInputSecretsToActionSecrets(t *testing.T) { }, } assert.Len(t, *res, 3) - assert.Equal(t, res, &expected) + assert.Equal(t, *res, expected) }) t.Run("it should handle empty input secrets", func(t *testing.T) { diff --git a/internal/cli/terraform.go b/internal/cli/terraform.go index d451cc372..130ae6cd1 100644 --- a/internal/cli/terraform.go +++ b/internal/cli/terraform.go @@ -68,7 +68,7 @@ func (i *terraformInputs) parseResourceFetchers(api *auth0.API) ([]resourceDataF fetchers = append(fetchers, &clientResourceFetcher{api}) case "auth0_client_grant": fetchers = append(fetchers, &clientGrantResourceFetcher{api}) - case "auth0_connection": + case "auth0_connection", "auth0_connection_clients": fetchers = append(fetchers, &connectionResourceFetcher{api}) case "auth0_custom_domain": fetchers = append(fetchers, &customDomainResourceFetcher{api}) @@ -78,7 +78,7 @@ func (i *terraformInputs) parseResourceFetchers(api *auth0.API) ([]resourceDataF fetchers = append(fetchers, &guardianResourceFetcher{}) case "auth0_log_stream": fetchers = append(fetchers, &logStreamResourceFetcher{api}) - case "auth0_organization": + case "auth0_organization", "auth0_organization_connections": fetchers = append(fetchers, &organizationResourceFetcher{api}) case "auth0_pages": fetchers = append(fetchers, &pagesResourceFetcher{}) @@ -86,9 +86,9 @@ func (i *terraformInputs) parseResourceFetchers(api *auth0.API) ([]resourceDataF fetchers = append(fetchers, &promptResourceFetcher{}) case "auth0_prompt_custom_text": fetchers = append(fetchers, &promptCustomTextResourceFetcherResourceFetcher{api}) - case "auth0_resource_server": + case "auth0_resource_server", "auth0_resource_server_scopes": fetchers = append(fetchers, &resourceServerResourceFetcher{api}) - case "auth0_role": + case "auth0_role", "auth0_role_permissions": fetchers = append(fetchers, &roleResourceFetcher{api}) case "auth0_tenant": fetchers = append(fetchers, &tenantResourceFetcher{}) @@ -122,12 +122,17 @@ func generateTerraformCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "generate", - Aliases: []string{"gen", "export"}, // Reconsider aliases and command name before releasing. + Aliases: []string{"gen"}, Short: "Generate terraform configuration for your Auth0 Tenant", - Long: "This command is designed to streamline the process of generating Terraform configuration files for " + + Long: "(Experimental) This command is designed to streamline the process of generating Terraform configuration files for " + "your Auth0 resources, serving as a bridge between the two.\n\nIt automatically scans your Auth0 Tenant " + - "and compiles a set of Terraform configuration files based on the existing resources and configurations." + - "\n\nThe generated Terraform files are written in HashiCorp Configuration Language (HCL).", + "and compiles a set of Terraform configuration files (HCL) based on the existing resources and configurations." + + "\n\nRefer to the [instructional guide](https://registry.terraform.io/providers/auth0/auth0/latest/docs/guides/generate_terraform_config) for specific details on how to use this command." + + "\n\n**Warning:** This command is experimental and is subject to change in future versions.", + Example: ` auth0 tf generate + auth0 tf generate -o tmp-auth0-tf + auth0 tf generate -o tmp-auth0-tf -r auth0_client + auth0 tf generate --output-dir tmp-auth0-tf --resources auth0_action,auth0_tenant,auth0_client `, RunE: generateTerraformCmdRun(cli, &inputs), } @@ -263,7 +268,7 @@ func createMainFile(outputDIR string) error { required_providers { auth0 = { source = "auth0/auth0" - version = "1.0.0-beta.1" + version = "1.0.0-beta.4" } } } diff --git a/internal/cli/terraform_fetcher.go b/internal/cli/terraform_fetcher.go index 126718b01..f28a411af 100644 --- a/internal/cli/terraform_fetcher.go +++ b/internal/cli/terraform_fetcher.go @@ -9,7 +9,7 @@ import ( "github.com/auth0/auth0-cli/internal/auth0" ) -var defaultResources = []string{"auth0_action", "auth0_attack_protection", "auth0_branding", "auth0_client", "auth0_client_grant", "auth0_connection", "auth0_custom_domain", "auth0_email_provider", "auth0_guardian", "auth0_log_stream", "auth0_organization", "auth0_pages", "auth0_prompt", "auth0_prompt_custom_text", "auth0_resource_server", "auth0_role", "auth0_tenant", "auth0_trigger_actions"} +var defaultResources = []string{"auth0_action", "auth0_attack_protection", "auth0_branding", "auth0_client", "auth0_client_grant", "auth0_connection", "auth0_custom_domain", "auth0_email_provider", "auth0_guardian", "auth0_organization", "auth0_pages", "auth0_prompt", "auth0_prompt_custom_text", "auth0_resource_server", "auth0_role", "auth0_tenant", "auth0_trigger_actions"} type ( importDataList []importDataItem diff --git a/internal/cli/terraform_test.go b/internal/cli/terraform_test.go index cfd0324fc..19cea74b4 100644 --- a/internal/cli/terraform_test.go +++ b/internal/cli/terraform_test.go @@ -197,7 +197,7 @@ func assertTerraformMainFileWasGeneratedCorrectly(t *testing.T, outputDIR string required_providers { auth0 = { source = "auth0/auth0" - version = "1.0.0-beta.1" + version = "1.0.0-beta.4" } } }