@@ -380,7 +380,7 @@ func (p *FrameworkProviderConfig) HandleZeroValues(ctx context.Context, data *fw
380
380
381
381
// HandleDefaults will handle all the defaults necessary in the provider
382
382
func (p * FrameworkProviderConfig ) HandleDefaults (ctx context.Context , data * fwmodels.ProviderModel , diags * diag.Diagnostics ) {
383
- if data .AccessToken .IsNull () && data .Credentials .IsNull () {
383
+ if ( data .AccessToken .IsNull () || data . AccessToken . IsUnknown ()) && ( data .Credentials .IsNull () || data . Credentials . IsUnknown () ) {
384
384
credentials := transport_tpg .MultiEnvDefault ([]string {
385
385
"GOOGLE_CREDENTIALS" ,
386
386
"GOOGLE_CLOUD_KEYFILE_JSON" ,
@@ -400,11 +400,11 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
400
400
}
401
401
}
402
402
403
- if data .ImpersonateServiceAccount .IsNull () && os .Getenv ("GOOGLE_IMPERSONATE_SERVICE_ACCOUNT" ) != "" {
403
+ if ( data .ImpersonateServiceAccount .IsNull () || data . ImpersonateServiceAccount . IsUnknown () ) && os .Getenv ("GOOGLE_IMPERSONATE_SERVICE_ACCOUNT" ) != "" {
404
404
data .ImpersonateServiceAccount = types .StringValue (os .Getenv ("GOOGLE_IMPERSONATE_SERVICE_ACCOUNT" ))
405
405
}
406
406
407
- if data .Project .IsNull () {
407
+ if data .Project .IsNull () || data . Project . IsUnknown () {
408
408
project := transport_tpg .MultiEnvDefault ([]string {
409
409
"GOOGLE_PROJECT" ,
410
410
"GOOGLE_CLOUD_PROJECT" ,
@@ -420,7 +420,7 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
420
420
data .BillingProject = types .StringValue (os .Getenv ("GOOGLE_BILLING_PROJECT" ))
421
421
}
422
422
423
- if data .Region .IsNull () {
423
+ if data .Region .IsNull () || data . Region . IsUnknown () {
424
424
region := transport_tpg .MultiEnvDefault ([]string {
425
425
"GOOGLE_REGION" ,
426
426
"GCLOUD_REGION" ,
@@ -432,7 +432,7 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
432
432
}
433
433
}
434
434
435
- if data .Zone .IsNull () {
435
+ if data .Zone .IsNull () || data . Zone . IsUnknown () {
436
436
zone := transport_tpg .MultiEnvDefault ([]string {
437
437
"GOOGLE_ZONE" ,
438
438
"GCLOUD_ZONE" ,
@@ -453,26 +453,26 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
453
453
}
454
454
}
455
455
456
- if ! data .Batching .IsNull () {
456
+ if ! data .Batching .IsNull () && ! data . Batching . IsUnknown () {
457
457
var pbConfigs []fwmodels.ProviderBatching
458
458
d := data .Batching .ElementsAs (ctx , & pbConfigs , true )
459
459
diags .Append (d ... )
460
460
if diags .HasError () {
461
461
return
462
462
}
463
463
464
- if pbConfigs [0 ].SendAfter .IsNull () {
464
+ if pbConfigs [0 ].SendAfter .IsNull () || pbConfigs [ 0 ]. SendAfter . IsUnknown () {
465
465
pbConfigs [0 ].SendAfter = types .StringValue ("10s" )
466
466
}
467
467
468
- if pbConfigs [0 ].EnableBatching .IsNull () {
468
+ if pbConfigs [0 ].EnableBatching .IsNull () || pbConfigs [ 0 ]. EnableBatching . IsUnknown () {
469
469
pbConfigs [0 ].EnableBatching = types .BoolValue (true )
470
470
}
471
471
472
472
data .Batching , d = types .ListValueFrom (ctx , types.ObjectType {}.WithAttributeTypes (fwmodels .ProviderBatchingAttributes ), pbConfigs )
473
473
}
474
474
475
- if data .UserProjectOverride .IsNull () && os .Getenv ("USER_PROJECT_OVERRIDE" ) != "" {
475
+ if ( data .UserProjectOverride .IsNull () || data . UserProjectOverride . IsUnknown () ) && os .Getenv ("USER_PROJECT_OVERRIDE" ) != "" {
476
476
override , err := strconv .ParseBool (os .Getenv ("USER_PROJECT_OVERRIDE" ))
477
477
if err != nil {
478
478
diags .AddError (
@@ -481,11 +481,11 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo
481
481
data .UserProjectOverride = types .BoolValue (override )
482
482
}
483
483
484
- if data .RequestReason .IsNull () && os .Getenv ("CLOUDSDK_CORE_REQUEST_REASON" ) != "" {
484
+ if ( data .RequestReason .IsNull () || data . RequestReason . IsUnknown () ) && os .Getenv ("CLOUDSDK_CORE_REQUEST_REASON" ) != "" {
485
485
data .RequestReason = types .StringValue (os .Getenv ("CLOUDSDK_CORE_REQUEST_REASON" ))
486
486
}
487
487
488
- if data .RequestTimeout .IsNull () {
488
+ if data .RequestTimeout .IsNull () || data . RequestTimeout . IsUnknown () {
489
489
data .RequestTimeout = types .StringValue ("120s" )
490
490
}
491
491
@@ -1558,7 +1558,7 @@ func (p *FrameworkProviderConfig) logGoogleIdentities(ctx context.Context, data
1558
1558
// a separate diagnostics here
1559
1559
var d diag.Diagnostics
1560
1560
1561
- if data .ImpersonateServiceAccount .IsNull () {
1561
+ if data .ImpersonateServiceAccount .IsNull () || data . ImpersonateServiceAccount . IsUnknown () {
1562
1562
1563
1563
tokenSource := GetTokenSource (ctx , data , true , diags )
1564
1564
if diags .HasError () {
@@ -1618,19 +1618,23 @@ func GetCredentials(ctx context.Context, data fwmodels.ProviderModel, initialCre
1618
1618
var clientScopes []string
1619
1619
var delegates []string
1620
1620
1621
- d := data .Scopes .ElementsAs (ctx , & clientScopes , false )
1622
- diags .Append (d ... )
1623
- if diags .HasError () {
1624
- return googleoauth.Credentials {}
1621
+ if ! data .Scopes .IsNull () && ! data .Scopes .IsUnknown () {
1622
+ d := data .Scopes .ElementsAs (ctx , & clientScopes , false )
1623
+ diags .Append (d ... )
1624
+ if diags .HasError () {
1625
+ return googleoauth.Credentials {}
1626
+ }
1625
1627
}
1626
1628
1627
- d = data .ImpersonateServiceAccountDelegates .ElementsAs (ctx , & delegates , false )
1628
- diags .Append (d ... )
1629
- if diags .HasError () {
1630
- return googleoauth.Credentials {}
1629
+ if ! data .ImpersonateServiceAccountDelegates .IsNull () && ! data .ImpersonateServiceAccountDelegates .IsUnknown () {
1630
+ d := data .ImpersonateServiceAccountDelegates .ElementsAs (ctx , & delegates , false )
1631
+ diags .Append (d ... )
1632
+ if diags .HasError () {
1633
+ return googleoauth.Credentials {}
1634
+ }
1631
1635
}
1632
1636
1633
- if ! data .AccessToken .IsNull () {
1637
+ if ! data .AccessToken .IsNull () && ! data . AccessToken . IsUnknown () {
1634
1638
contents , _ , err := verify .PathOrContents (data .AccessToken .ValueString ())
1635
1639
if err != nil {
1636
1640
diags .AddError ("error loading access token" , err .Error ())
@@ -1655,7 +1659,7 @@ func GetCredentials(ctx context.Context, data fwmodels.ProviderModel, initialCre
1655
1659
}
1656
1660
}
1657
1661
1658
- if ! data .Credentials .IsNull () {
1662
+ if ! data .Credentials .IsNull () && ! data . Credentials . IsUnknown () {
1659
1663
contents , _ , err := verify .PathOrContents (data .Credentials .ValueString ())
1660
1664
if err != nil {
1661
1665
diags .AddError (fmt .Sprintf ("error loading credentials: %s" , err ), err .Error ())
@@ -1714,7 +1718,8 @@ func GetBatchingConfig(ctx context.Context, data types.List, diags *diag.Diagnos
1714
1718
EnableBatching : true ,
1715
1719
}
1716
1720
1717
- if data .IsNull () {
1721
+ // Handle if entire batching block is null/unknown
1722
+ if data .IsNull () || data .IsUnknown () {
1718
1723
return bc
1719
1724
}
1720
1725
0 commit comments