FANNG1 commented on PR #5974:
URL: https://github.com/apache/gravitino/pull/5974#issuecomment-2579109778

   There're two options, I prefer Option2.  @yuqi1129 @jerryshao WDYT?
   
   Option1 using a helper class to translate the configuration.
   ```java
         totalProperty.putAll(getCredentialConfigs(fileset))
         return provider.getFileSystem(filePath, totalProperty);
   
   
     Map<String, String> getCredentialConfigs(Fileset fileset) {
       Credential[] credentials = 
fileset.supportsCredentials().getCredentials();
       if (credentials.length == 0) {
         return ImmutableMap.of();
       }
       
       Map<String, String> maps = Maps.newHashMap();
       // common configurations for credential vending
       maps.put(xx, xx);
       
       // specific configurations
       Arrays.stream(credentials).forEach(
           credential -> {
             if (credential instanceof ADLSTokenCredential) {
               // add azure token credential configurations
             } else if (credential instanceof AzureAccountCredential) {
               // add azure account configurations
             } 
           }
       );   
       return maps;
     }
   ```
   
   Option2  add an new `SupportsCredentialVending` interface to translate the 
configuration.
   
   ```
    if (provider instanceOf SupportsCredentialVending) {
        Credential[] credentials =  fileset.getCredentials()   
        totalProperty.putAll(provider.getCredentialConfig(credentials))
    }
   
    return provider.getFileSystem(filePath, totalProperty);
   
   
   interface SupportsCredentialVending {
       default Map<String, String>  getCredentialConfig(Credential[] 
credentials) {
           // common logic
       }
   } 
   
   AzureFileSystemProvider implements SupportsCredentials {
       Map<String, String>  getCredentialConfig(Credential[] credentials) {
           // specific logic
       }
   }
   ```


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

Reply via email to