Skip to content

Commit 8021a75

Browse files
committed
Only set delta sharing recipient token max lifetime during update, not create
1 parent 801840f commit 8021a75

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

catalog/resource_metastore.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ func updateForceSendFieldsAccountLevel(req *catalog.UpdateAccountsMetastore) {
2727
}
2828
}
2929

30+
// Cannot set lifetime to 0 (unlimited), so set to 1 year (maximum allowed)
31+
func setDefaultDeltaSharingRecipientTokenLifetimeInSecondsWorkspaceLevel(req *catalog.UpdateMetastore) {
32+
if req.DeltaSharingRecipientTokenLifetimeInSeconds == 0 {
33+
log.Printf("[DEBUG] Setting delta sharing recipient token lifetime to 1 year")
34+
req.DeltaSharingRecipientTokenLifetimeInSeconds = 31536000
35+
}
36+
}
37+
38+
func setDefaultDeltaSharingRecipientTokenLifetimeInSecondsAccountLevel(req *catalog.UpdateAccountsMetastore) {
39+
if req.DeltaSharingRecipientTokenLifetimeInSeconds == 0 {
40+
log.Printf("[DEBUG] Setting delta sharing recipient token lifetime to 1 year")
41+
req.DeltaSharingRecipientTokenLifetimeInSeconds = 31536000
42+
}
43+
}
44+
3045
func ResourceMetastore() common.Resource {
3146
s := common.StructToSchema(catalog.MetastoreInfo{},
3247
func(m map[string]*schema.Schema) map[string]*schema.Schema {
@@ -70,7 +85,6 @@ func ResourceMetastore() common.Resource {
7085
// Field dependencies and validation
7186
m["delta_sharing_scope"].RequiredWith = []string{"delta_sharing_recipient_token_lifetime_in_seconds"}
7287
m["delta_sharing_recipient_token_lifetime_in_seconds"].RequiredWith = []string{"delta_sharing_scope"}
73-
m["delta_sharing_recipient_token_lifetime_in_seconds"].Default = 31536000 // 1 year
7488
common.CustomizeSchemaPath(m, "delta_sharing_scope").SetValidateFunc(
7589
validation.StringInSlice([]string{"INTERNAL", "INTERNAL_AND_EXTERNAL"}, false),
7690
)
@@ -157,6 +171,7 @@ func ResourceMetastore() common.Resource {
157171
var update catalog.UpdateAccountsMetastore
158172
common.DataToStructPointer(d, s, &update)
159173
updateForceSendFieldsAccountLevel(&update)
174+
setDefaultDeltaSharingRecipientTokenLifetimeInSecondsAccountLevel(&update)
160175
if d.HasChange("owner") {
161176
ownerUpdate := catalog.UpdateAccountsMetastore{
162177
Owner: update.Owner,
@@ -202,6 +217,7 @@ func ResourceMetastore() common.Resource {
202217
common.DataToStructPointer(d, s, &update)
203218
update.Id = d.Id()
204219
updateForceSendFieldsWorkspaceLevel(&update)
220+
setDefaultDeltaSharingRecipientTokenLifetimeInSecondsWorkspaceLevel(&update)
205221
if d.HasChange("owner") {
206222
_, err := w.Metastores.Update(ctx, catalog.UpdateMetastore{
207223
Id: update.Id,

0 commit comments

Comments
 (0)