zeroshade commented on code in PR #2075:
URL: https://github.com/apache/iceberg-go/pull/2075#discussion_r4159776229


##########
catalog/rest/rest.go:
##########
@@ -1329,6 +1331,33 @@ func (r *Catalog) fetchTableCreds(ctx context.Context, 
ident []string, location
        return resolveStorageCredentials(ret.StorageCredentials, location), nil
 }
 
+// RefreshTableCredentials updates a *table.Table with newly-vended 
credentials from the catalog
+// without updating any other table-internal state that a full Refresh() would.
+// Allows for a quick table credential refresh if the table was created 
without any pre-seeded
+// credentials. If the catalog did not vend any credentials, the table is 
returned unmodified.
+//
+// Requires that the passed-in table instance be created with the 
table.WithSavedConfig() option to
+// save any table-specific configs. All tables created by this catalog pass in 
that option.
+func (r *Catalog) RefreshTableCredentials(ctx context.Context, tbl 
*table.Table) (*table.Table, error) {
+       metadataLoc := tbl.MetadataLocation()
+       resp, err := r.fetchTableCreds(ctx, tbl.Identifier(), metadataLoc)
+       if err != nil {
+               return nil, err
+       }
+       if len(resp) == 0 {
+               // No new credentials vended. Return as-is.
+               return tbl, nil
+       }
+
+       // Return a new *table.Table with newly-merged credentials coming from 
the
+       // fetchTableCreds call.
+       config := maps.Clone(r.props)
+       maps.Copy(config, tbl.SavedConfig())
+       maps.Copy(config, resp)

Review Comment:
   That's fair and makes sense, sounds good.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to