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


##########
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.
+//
+// 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

Review Comment:
   The interface doesn't always guarantee a new table instance, not sure where 
you're reading this. Either way I updated the comment on the interface to say 
that returning the same table in the non-temp-credential case is fine. Only 
reason I added the trivial equality checks instead of the pointer check is 
because of the earlier suggestion from you asking for them; the earlier test 
just had a pointer equality if you remember.



-- 
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