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


##########
catalog/rest/rest.go:
##########
@@ -630,16 +630,45 @@ func checkValidNamespace(ident table.Identifier) error {
        return nil
 }
 
-func (r *Catalog) tableFromResponse(ctx context.Context, identifier []string, 
metadata table.Metadata, loc string, config iceberg.Properties) (*table.Table, 
error) {
+func (r *Catalog) tableFromResponse(_ context.Context, identifier []string, 
metadata table.Metadata, loc string, config iceberg.Properties) (*table.Table, 
error) {
+       refresher := &vendedCredentialRefresher{
+               mu:          semaphore.NewWeighted(1),
+               identifier:  identifier,
+               location:    loc,
+               props:       config,
+               fetchConfig: r.fetchTableConfig,
+       }
+
        return table.New(
                identifier,
                metadata,
                loc,
-               iceio.LoadFSFunc(config, loc),
+               refresher.loadFS,
                r,
        ), nil
 }
 
+func (r *Catalog) fetchTableConfig(ctx context.Context, ident []string) 
(iceberg.Properties, error) {
+       ns, tbl, err := splitIdentForPath(ident)
+       if err != nil {
+               return nil, err
+       }
+
+       ret, err := doGet[loadTableResponse](ctx, r.baseURI, 
[]string{"namespaces", ns, "tables", tbl},
+               r.cl, map[int]error{http.StatusNotFound: 
catalog.ErrNoSuchTable})
+       if err != nil {
+               return nil, err
+       }
+
+       config := maps.Clone(r.props)
+       maps.Copy(config, ret.Metadata.Properties())
+       for k, v := range ret.Config {
+               config[k] = v
+       }
+
+       return config, nil
+}

Review Comment:
   rather than re-loading the whole table we should just use the 
[/v1/{prefix}/namespaces/{namespace}/tables/{table}/credentials endpoint in the 
REST 
spec](https://github.com/apache/iceberg/blob/69caca0ecfe1b2f4a60b4164c24ea65853c23857/open-api/rest-catalog-open-api.yaml#L1211).
 This would return vended credentials with an expiration.



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