complone opened a new issue, #10387:
URL: https://github.com/apache/dolphinscheduler/issues/10387

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar feature requirement.
   
   
   ### Description
   
   The current resource center supports hdfs/s3/local storage due to the way of 
uploading and reading files, only need to add git file storage
   
   When a user uploads a file to the resource center to access 
```ResourcesController```, the implementation class ```HadoopUtils``` of the 
```StorageOperate``` interface will implement file operations with ```S3Utils```
   
   Research, it protocol ecplise provides a Java client ``org.eclipse.jgit``` 
to support file storage based on
   I will compose the API-related storage operation implementation based on the 
production environment example here
   [jgit-cookbook](https://github.com/centic9/jgit-cookbook)
   
   
   ### Use case
   
   The following are two simple git manipulation examples, which will be 
further expanded in combination with 
[jgit-cookbook](https://github.com/centic9/jgit-cookbook)
   
   
   git create
   ```
   public class RepositoryProviderExistingClientImpl implements 
RepositoryProvider {
       
       private String[] clientPath;
       private String tenantCode;
       public RepositoryProviderExistingClientImpl(String tenantCode, String[] 
clientPath) {
           this.clientPath = clientPath;
           this.tenantCode = tenantCode;
       }
       
       @Override
       public Repository getRepository() throws Exception {
           try  {
               File workdir = getFile(tenantCode, clientPath);
               return new FileRepositoryBuilder().setWorkTree(workdir).build();
           }catch (Exception ex){
               throw new StorageOperateTransformException();
           }
       }
       
       public File getFile(String tenantCode, String... pathComponents) throws 
IOException {
           String rootPath = new File(new File(tenantCode), "").getPath();
           for (String pathComponent : pathComponents)
               rootPath = rootPath + File.separatorChar + pathComponent;
           File result = new File(rootPath);
           FileUtils.mkdirs(result, true);
           return result;
       }
   }
   ```
   
   
   git pull 
   ```
   public class RepositoryProviderCloneImpl implements RepositoryProvider {
       
       private String repoPath;
       private String clientPath;
       public RepositoryProviderCloneImpl(String repoPath, String clientPath) {
           this.repoPath = repoPath;
           this.clientPath = clientPath;
       }
       
       @Override
       public Repository getRepository() throws Exception {
           File client = new File(clientPath);
           boolean isCreated = client.mkdir();
           if (!isCreated){
               throw new StorageOperateTransformException("File create failed 
by using Git!");
           }
          
           try {
               Git result = Git.cloneRepository()
                   .setURI(repoPath)
                   .setDirectory(client)
                   .call();
               return result.getRepository();
           } catch (Exception ex){
               throw new StorageOperateTransformException(ex.getMessage());
           }
       }
   }
   ```
   
   ### Related issues
   
   Nope
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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