Skip to content

Commit 13633d5

Browse files
Refactoring clients continues (18 more services) (#4031) (#2529)
* create new service for compute beta calls * update client container to create new client each call * update client container beta to create new client each call * update client dns to create new client each call * update dns client * update containerOperationWait calls to pass userAgent * update client dns beta to create new client each call * update client kms to create new client each call * remove clientKms from config * update client logging to create new client each call * update client storage to create new client each call * update client sqladmin to create new client each call * update client pubsub to create new client each call * update client dataflow to create new client each call * update client resource manager to create new client each call * update client resource manager v2beta1 to create new client each call * fix lint errors (remove clientContainer, clientContainerBeta and clientDns from config) * update client runtime config to create new client each call * update client iam to create new client each call * update client iam credentials to create new client each call * update client service management to create new client each call * update client service usage to create new client each call * fix wrappedPubsubClient for vcr tests * attempt fix wrappedPubsubClient for vcr tests * attempt fix for pubsub in vcr tests * another pubsub fix * attempt fix wrappedPubsubClient for vcr tests Signed-off-by: Modular Magician <[email protected]>
1 parent 1276685 commit 13633d5

File tree

145 files changed

+986
-908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+986
-908
lines changed

.changelog/4031.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/bootstrap_utils_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func BootstrapKMSKeyWithPurposeInLocationAndName(t *testing.T, purpose, location
7070
keyName := fmt.Sprintf("%s/cryptoKeys/%s", keyParent, keyShortName)
7171

7272
// Get or Create the hard coded shared keyring for testing
73-
kmsClient := config.clientKms
73+
kmsClient := config.NewKmsClient(config.userAgent)
7474
keyRing, err := kmsClient.Projects.Locations.KeyRings.Get(keyRingName).Do()
7575
if err != nil {
7676
if isGoogleApiErrorWithCode(err, 404) {
@@ -137,7 +137,7 @@ func getOrCreateServiceAccount(config *Config, project string) (*iam.ServiceAcco
137137
name := fmt.Sprintf("projects/%s/serviceAccounts/%s@%s.iam.gserviceaccount.com", project, serviceAccountEmail, project)
138138
log.Printf("[DEBUG] Verifying %s as bootstrapped service account.\n", name)
139139

140-
sa, err := config.clientIAM.Projects.ServiceAccounts.Get(name).Do()
140+
sa, err := config.NewIamClient(config.userAgent).Projects.ServiceAccounts.Get(name).Do()
141141
if err != nil && !isGoogleApiErrorWithCode(err, 404) {
142142
return nil, err
143143
}
@@ -152,7 +152,7 @@ func getOrCreateServiceAccount(config *Config, project string) (*iam.ServiceAcco
152152
AccountId: serviceAccountEmail,
153153
ServiceAccount: sa,
154154
}
155-
sa, err = config.clientIAM.Projects.ServiceAccounts.Create("projects/"+project, r).Do()
155+
sa, err = config.NewIamClient(config.userAgent).Projects.ServiceAccounts.Create("projects/"+project, r).Do()
156156
if err != nil {
157157
return nil, err
158158
}
@@ -180,7 +180,7 @@ func impersonationServiceAccountPermissions(config *Config, sa *iam.ServiceAccou
180180
// Overwrite the roles each time on this service account. This is because this account is
181181
// only created for the test suite and will stop snowflaking of permissions to get tests
182182
// to run. Overwriting permissions on 1 service account shouldn't affect others.
183-
_, err := config.clientIAM.Projects.ServiceAccounts.SetIamPolicy(sa.Name, &iam.SetIamPolicyRequest{
183+
_, err := config.NewIamClient(config.userAgent).Projects.ServiceAccounts.SetIamPolicy(sa.Name, &iam.SetIamPolicyRequest{
184184
Policy: &policy,
185185
}).Do()
186186
if err != nil {
@@ -274,7 +274,7 @@ func BootstrapServicePerimeterProjects(t *testing.T, desiredProjects int) []*clo
274274
// doesn't seem to allow for prefix matching. Don't change this to include the parent type unless
275275
// that API behavior changes.
276276
prefixFilter := fmt.Sprintf("id:%s* parent.id:%s", SharedServicePerimeterProjectPrefix, org)
277-
res, err := config.clientResourceManager.Projects.List().Filter(prefixFilter).Do()
277+
res, err := config.NewResourceManagerClient(config.userAgent).Projects.List().Filter(prefixFilter).Do()
278278
if err != nil {
279279
t.Fatalf("Error getting shared test projects: %s", err)
280280
}
@@ -290,7 +290,7 @@ func BootstrapServicePerimeterProjects(t *testing.T, desiredProjects int) []*clo
290290
Id: org,
291291
},
292292
}
293-
op, err := config.clientResourceManager.Projects.Create(project).Do()
293+
op, err := config.NewResourceManagerClient(config.userAgent).Projects.Create(project).Do()
294294
if err != nil {
295295
t.Fatalf("Error bootstrapping shared test project: %s", err)
296296
}
@@ -305,7 +305,7 @@ func BootstrapServicePerimeterProjects(t *testing.T, desiredProjects int) []*clo
305305
t.Fatalf("Error bootstrapping shared test project: %s", err)
306306
}
307307

308-
p, err := config.clientResourceManager.Projects.Get(pid).Do()
308+
p, err := config.NewResourceManagerClient(config.userAgent).Projects.Get(pid).Do()
309309
if err != nil {
310310
t.Fatalf("Error getting shared test project: %s", err)
311311
}

google-beta/compute_operation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func computeOperationWaitTime(config *Config, res interface{}, project, activity
104104
}
105105

106106
w := &ComputeOperationWaiter{
107-
Service: config.clientComputeBeta,
107+
Service: config.NewComputeBetaClient(userAgent),
108108
Context: config.context,
109109
Op: op,
110110
Project: project,
@@ -116,15 +116,15 @@ func computeOperationWaitTime(config *Config, res interface{}, project, activity
116116
return OperationWait(w, activity, timeout, config.PollInterval)
117117
}
118118

119-
func computeOrgOperationWaitTimeWithResponse(config *Config, res interface{}, response *map[string]interface{}, parent, activity string, timeout time.Duration) error {
119+
func computeOrgOperationWaitTimeWithResponse(config *Config, res interface{}, response *map[string]interface{}, parent, activity, userAgent string, timeout time.Duration) error {
120120
op := &computeBeta.Operation{}
121121
err := Convert(res, op)
122122
if err != nil {
123123
return err
124124
}
125125

126126
w := &ComputeOperationWaiter{
127-
Service: config.clientComputeBeta,
127+
Service: config.NewComputeBetaClient(userAgent),
128128
Op: op,
129129
Parent: parent,
130130
}

0 commit comments

Comments
 (0)