NIFI-11193 Improve GitFlowPersisenceProvider logging

This closes #6967

Co-authored-by: David Handermann <exceptionfactory@apache.org>
Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
Kevin Doran 2023-02-16 15:28:59 -05:00
parent 6f2b9e5f65
commit 17b4480831
No known key found for this signature in database
GPG Key ID: 5621A6244B77AC02
2 changed files with 7 additions and 8 deletions

View File

@ -181,16 +181,12 @@ class GitFlowMetaData {
* @param remoteRepository the URI value of the 'Remote Clone Repository' configuration * @param remoteRepository the URI value of the 'Remote Clone Repository' configuration
* @throws IOException if creating the repository fails * @throws IOException if creating the repository fails
*/ */
public void remoteRepoExists(String remoteRepository) throws IOException { public void remoteRepoExists(String remoteRepository) throws GitAPIException, IOException {
final Git git = new Git(FileRepositoryBuilder.create(new File(remoteRepository))); final Git git = new Git(FileRepositoryBuilder.create(new File(remoteRepository)));
final LsRemoteCommand lsCmd = git.lsRemote(); final LsRemoteCommand lsCmd = git.lsRemote();
try { lsCmd.setRemote(remoteRepository);
lsCmd.setRemote(remoteRepository); lsCmd.setCredentialsProvider(this.credentialsProvider);
lsCmd.setCredentialsProvider(this.credentialsProvider); lsCmd.call();
lsCmd.call();
} catch (Exception e){
throw new IllegalArgumentException("InvalidRemoteRepository : Given remote repository is not valid");
}
} }
/** /**

View File

@ -94,9 +94,12 @@ public class GitFlowPersistenceProvider implements MetadataAwareFlowPersistenceP
flowStorageDir = new File(flowStorageDirValue); flowStorageDir = new File(flowStorageDirValue);
final boolean localRepoExists = flowMetaData.localRepoExists(flowStorageDir); final boolean localRepoExists = flowMetaData.localRepoExists(flowStorageDir);
if (remoteRepo != null && !remoteRepo.isEmpty() && !localRepoExists){ if (remoteRepo != null && !remoteRepo.isEmpty() && !localRepoExists){
logger.info("Validating remote repository [{}]", remoteRepo);
flowMetaData.remoteRepoExists(remoteRepo); flowMetaData.remoteRepoExists(remoteRepo);
logger.info("Cloning remote repository [{}] to [{}]", remoteRepo, flowStorageDirValue);
flowMetaData.cloneRepository(flowStorageDir, remoteRepo); flowMetaData.cloneRepository(flowStorageDir, remoteRepo);
} }
logger.info("Loading remote repository [{}]", remoteRepo);
flowMetaData.loadGitRepository(flowStorageDir); flowMetaData.loadGitRepository(flowStorageDir);
flowMetaData.startPushThread(); flowMetaData.startPushThread();
logger.info("Configured GitFlowPersistenceProvider with Flow Storage Directory {}", logger.info("Configured GitFlowPersistenceProvider with Flow Storage Directory {}",