@@ -236,46 +236,50 @@ def _get_init_action_timeout(self) -> dict:
236
236
)
237
237
238
238
def _build_gce_cluster_config (self , cluster_data ):
239
+ # This variable is created since same string was being used multiple times
240
+ config = "gce_cluster_config"
239
241
if self .zone :
240
242
zone_uri = f"https://www.googleapis.com/compute/v1/projects/{ self .project_id } /zones/{ self .zone } "
241
- cluster_data ["gce_cluster_config" ]["zone_uri" ] = zone_uri
243
+ cluster_data [config ]["zone_uri" ] = zone_uri
242
244
243
245
if self .metadata :
244
- cluster_data ["gce_cluster_config" ]["metadata" ] = self .metadata
246
+ cluster_data [config ]["metadata" ] = self .metadata
245
247
246
248
if self .network_uri :
247
- cluster_data ["gce_cluster_config" ]["network_uri" ] = self .network_uri
249
+ cluster_data [config ]["network_uri" ] = self .network_uri
248
250
249
251
if self .subnetwork_uri :
250
- cluster_data ["gce_cluster_config" ]["subnetwork_uri" ] = self .subnetwork_uri
252
+ cluster_data [config ]["subnetwork_uri" ] = self .subnetwork_uri
251
253
252
254
if self .internal_ip_only :
253
255
if not self .subnetwork_uri :
254
256
raise AirflowException ("Set internal_ip_only to true only when you pass a subnetwork_uri." )
255
- cluster_data ["gce_cluster_config" ]["internal_ip_only" ] = True
257
+ cluster_data [config ]["internal_ip_only" ] = True
256
258
257
259
if self .tags :
258
- cluster_data ["gce_cluster_config" ]["tags" ] = self .tags
260
+ cluster_data [config ]["tags" ] = self .tags
259
261
260
262
if self .service_account :
261
- cluster_data ["gce_cluster_config" ]["service_account" ] = self .service_account
263
+ cluster_data [config ]["service_account" ] = self .service_account
262
264
263
265
if self .service_account_scopes :
264
- cluster_data ["gce_cluster_config" ]["service_account_scopes" ] = self .service_account_scopes
266
+ cluster_data [config ]["service_account_scopes" ] = self .service_account_scopes
265
267
266
268
return cluster_data
267
269
268
270
def _build_lifecycle_config (self , cluster_data ):
271
+ # This variable is created since same string was being used multiple times
272
+ lifecycle_config = "lifecycle_config"
269
273
if self .idle_delete_ttl :
270
- cluster_data [" lifecycle_config" ]["idle_delete_ttl" ] = {"seconds" : self .idle_delete_ttl }
274
+ cluster_data [lifecycle_config ]["idle_delete_ttl" ] = {"seconds" : self .idle_delete_ttl }
271
275
272
276
if self .auto_delete_time :
273
277
utc_auto_delete_time = timezone .convert_to_utc (self .auto_delete_time )
274
- cluster_data [" lifecycle_config" ]["auto_delete_time" ] = utc_auto_delete_time .strftime (
278
+ cluster_data [lifecycle_config ]["auto_delete_time" ] = utc_auto_delete_time .strftime (
275
279
"%Y-%m-%dT%H:%M:%S.%fZ"
276
280
)
277
281
elif self .auto_delete_ttl :
278
- cluster_data [" lifecycle_config" ]["auto_delete_ttl" ] = {"seconds" : int (self .auto_delete_ttl )}
282
+ cluster_data [lifecycle_config ]["auto_delete_ttl" ] = {"seconds" : int (self .auto_delete_ttl )}
279
283
280
284
return cluster_data
281
285
0 commit comments