From 9c9eccc206885ce769473f3e2e8b61c43ac9b6ed Mon Sep 17 00:00:00 2001 From: Kevin McHale Date: Fri, 6 Jul 2018 15:37:19 -0400 Subject: [PATCH 1/3] Add nextPageToken to fields argument against ServiceUsage api --- google/resource_google_project_services.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/resource_google_project_services.go b/google/resource_google_project_services.go index 7e2d606d0c4..9e812baee3f 100644 --- a/google/resource_google_project_services.go +++ b/google/resource_google_project_services.go @@ -201,7 +201,7 @@ func getApiServices(pid string, config *Config, ignore map[string]struct{}) ([]s ctx := context.Background() return config.clientServiceUsage.Services. List("projects/"+pid). - Fields("services/name"). + Fields("services/name,nextPageToken"). Filter("state:ENABLED"). Pages(ctx, func(r *serviceusage.ListServicesResponse) error { for _, v := range r.Services { From c998a37a834cd1459af7786ac63a8a90a3ca7a72 Mon Sep 17 00:00:00 2001 From: Paddy Carver Date: Thu, 12 Jul 2018 06:04:09 -0700 Subject: [PATCH 2/3] Update our test to page. Add a bunch more services to our manyServices test, so that we have a page that exercises pagination logic. --- .../resource_google_project_services_test.go | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/google/resource_google_project_services_test.go b/google/resource_google_project_services_test.go index 66f343442b0..5c9a663b551 100644 --- a/google/resource_google_project_services_test.go +++ b/google/resource_google_project_services_test.go @@ -185,9 +185,19 @@ func TestAccProjectServices_manyServices(t *testing.T) { billingId := getTestBillingAccountFromEnv(t) pid := "terraform-" + acctest.RandString(10) services := []string{ + "actions.googleapis.com", + "appengine.googleapis.com", + "appengineflex.googleapis.com", "bigquery-json.googleapis.com", + "bigquerydatatransfer.googleapis.com", + "bigtableadmin.googleapis.com", + "bigtabletableadmin.googleapis.com", "cloudbuild.googleapis.com", + "clouderrorreporting.googleapis.com", "cloudfunctions.googleapis.com", + "cloudiot.googleapis.com", + "cloudkms.googleapis.com", + "cloudmonitoring.googleapis.com", "cloudresourcemanager.googleapis.com", "cloudtrace.googleapis.com", "compute.googleapis.com", @@ -195,10 +205,16 @@ func TestAccProjectServices_manyServices(t *testing.T) { "containerregistry.googleapis.com", "dataflow.googleapis.com", "dataproc.googleapis.com", + "datastore.googleapis.com", "deploymentmanager.googleapis.com", + "dialogflow.googleapis.com", "dns.googleapis.com", "endpoints.googleapis.com", + "firebaserules.googleapis.com", + "firestore.googleapis.com", + "genomics.googleapis.com", "iam.googleapis.com", + "language.googleapis.com", "logging.googleapis.com", "ml.googleapis.com", "monitoring.googleapis.com", @@ -212,8 +228,17 @@ func TestAccProjectServices_manyServices(t *testing.T) { "servicemanagement.googleapis.com", "sourcerepo.googleapis.com", "spanner.googleapis.com", + "speech.googleapis.com", + "sql-component.googleapis.com", "storage-api.googleapis.com", "storage-component.googleapis.com", + "storagetransfer.googleapis.com", + "testing.googleapis.com", + "toolresults.googleapis.com", + "translate.googleapis.com", + "videointelligence.googleapis.com", + "vision.googleapis.com", + "zync.googleapis.com", } resource.Test(t, resource.TestCase{ From d6f2a285ef36624d25e4d52505d5765613d4e886 Mon Sep 17 00:00:00 2001 From: Paddy Carver Date: Thu, 12 Jul 2018 10:26:48 -0700 Subject: [PATCH 3/3] Rename test, add comment. --- google/resource_google_project_services_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/google/resource_google_project_services_test.go b/google/resource_google_project_services_test.go index 5c9a663b551..80983106d03 100644 --- a/google/resource_google_project_services_test.go +++ b/google/resource_google_project_services_test.go @@ -178,12 +178,15 @@ func TestAccProjectServices_ignoreUnenablableServices(t *testing.T) { }) } -func TestAccProjectServices_manyServices(t *testing.T) { +func TestAccProjectServices_pagination(t *testing.T) { t.Parallel() org := getTestOrgFromEnv(t) billingId := getTestBillingAccountFromEnv(t) pid := "terraform-" + acctest.RandString(10) + + // we need at least 50 services (doesn't matter what they are) to exercise the + // pagination handling code. services := []string{ "actions.googleapis.com", "appengine.googleapis.com",