From f69e38071f3fbf3cd697c6e7aee8ab966bf852d1 Mon Sep 17 00:00:00 2001 From: Kunal Dawar Date: Thu, 27 Jun 2024 15:28:02 +0530 Subject: [PATCH] include auth0_client_credentials in auth0_import.tf generation --- internal/cli/terraform.go | 2 +- internal/cli/terraform_fetcher.go | 5 +++++ internal/cli/terraform_fetcher_test.go | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/internal/cli/terraform.go b/internal/cli/terraform.go index 9f71b661d..7e556be2d 100644 --- a/internal/cli/terraform.go +++ b/internal/cli/terraform.go @@ -64,7 +64,7 @@ func (i *terraformInputs) parseResourceFetchers(api *auth0.API) ([]resourceDataF fetchers = append(fetchers, &attackProtectionResourceFetcher{}) case "auth0_branding": fetchers = append(fetchers, &brandingResourceFetcher{}) - case "auth0_client": + case "auth0_client", "auth0_client_credentials": fetchers = append(fetchers, &clientResourceFetcher{api}) case "auth0_client_grant": fetchers = append(fetchers, &clientGrantResourceFetcher{api}) diff --git a/internal/cli/terraform_fetcher.go b/internal/cli/terraform_fetcher.go index 94a2e3839..5356f3692 100644 --- a/internal/cli/terraform_fetcher.go +++ b/internal/cli/terraform_fetcher.go @@ -122,6 +122,11 @@ func (f *clientResourceFetcher) FetchData(ctx context.Context) (importDataList, ResourceName: "auth0_client." + sanitizeResourceName(client.GetName()), ImportID: client.GetClientID(), }) + + data = append(data, importDataItem{ + ResourceName: "auth0_client_credentials." + sanitizeResourceName(client.GetName()), + ImportID: client.GetClientID(), + }) } if !clients.HasNext() { diff --git a/internal/cli/terraform_fetcher_test.go b/internal/cli/terraform_fetcher_test.go index d751cd946..ca264ad81 100644 --- a/internal/cli/terraform_fetcher_test.go +++ b/internal/cli/terraform_fetcher_test.go @@ -202,18 +202,34 @@ func TestClientResourceFetcher_FetchData(t *testing.T) { ResourceName: "auth0_client.my_test_client_1", ImportID: "clientID_1", }, + { + ResourceName: "auth0_client_credentials.my_test_client_1", + ImportID: "clientID_1", + }, { ResourceName: "auth0_client.my_test_client_2", ImportID: "clientID_2", }, + { + ResourceName: "auth0_client_credentials.my_test_client_2", + ImportID: "clientID_2", + }, { ResourceName: "auth0_client.my_test_client_3", ImportID: "clientID_3", }, + { + ResourceName: "auth0_client_credentials.my_test_client_3", + ImportID: "clientID_3", + }, { ResourceName: "auth0_client.my_test_client_4", ImportID: "clientID_4", }, + { + ResourceName: "auth0_client_credentials.my_test_client_4", + ImportID: "clientID_4", + }, } data, err := fetcher.FetchData(context.Background())