use of io.hops.hopsworks.common.dao.git.GitPaths in project hopsworks by logicalclocks.
the class GitExecutionController method createExecution.
/**
* initializes the execution of all git commands
*
* @param gitCommandConfiguration
* @param project
* @param hopsworksUser
* @param repository
* @return
* @throws HopsSecurityException
* @throws GitOpException
*/
public GitOpExecution createExecution(GitCommandConfiguration gitCommandConfiguration, Project project, Users hopsworksUser, GitRepository repository) throws HopsSecurityException, GitOpException {
String hdfsUsername = hdfsUsersController.getHdfsUserName(project, hopsworksUser);
BasicAuthSecrets authSecrets = gitCommandOperationUtil.getAuthenticationSecrets(hopsworksUser, repository.getGitProvider());
commandConfigurationValidator.validateProviderConfiguration(authSecrets, gitCommandConfiguration);
String configSecret = DigestUtils.sha256Hex(Integer.toString(ThreadLocalRandom.current().nextInt()));
lockRepository(repository.getId());
GitOpExecution gitOpExecution = null;
DistributedFileSystemOps udfso = null;
try {
udfso = dfsService.getDfsOps(hdfsUsername);
GitPaths gitPaths = prepareCommandExecution(project, hopsworksUser, udfso, configSecret);
gitOpExecution = gitOpExecutionFacade.create(gitCommandConfiguration, hopsworksUser, repository, configSecret);
argumentsWriter.createArgumentFile(gitOpExecution, gitPaths, authSecrets);
gitCommandExecutor.execute(gitOpExecution, gitPaths);
return gitOpExecution;
} catch (Exception ex) {
gitRepositoryFacade.updateRepositoryCid(repository, null);
gitCommandOperationUtil.cleanUp(project, hopsworksUser, configSecret);
if (ex instanceof IOException) {
throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CERT_MATERIALIZATION_ERROR, Level.SEVERE, ex.getMessage(), null, ex);
}
throw new GitOpException(RESTCodes.GitOpErrorCode.GIT_OPERATION_ERROR, Level.SEVERE, ex.getMessage());
} finally {
if (udfso != null) {
dfsService.closeDfsClient(udfso);
}
}
}
use of io.hops.hopsworks.common.dao.git.GitPaths in project hopsworks by logicalclocks.
the class GitExecutionController method prepareCommandExecution.
/**
* Generate the git paths, materialize user certificates, and jwt
*
* @param project
* @param hopsworksUser
* @param dfso
* @throws GitOpException
* @throws IOException
*/
public GitPaths prepareCommandExecution(Project project, Users hopsworksUser, DistributedFileSystemOps dfso, String configSecret) throws GitOpException, IOException {
GitPaths gitPaths = new GitPaths(settings.getStagingDir() + settings.PRIVATE_DIRS, configSecret);
gitCommandOperationUtil.generatePaths(gitPaths);
HopsUtils.materializeCertificatesForUserCustomDir(project.getName(), hopsworksUser.getUsername(), settings.getHdfsTmpCertDir(), dfso, certificateMaterializer, settings, gitPaths.getCertificatesDirPath());
gitJWTManager.materializeJWT(hopsworksUser, gitPaths.getTokenPath());
return gitPaths;
}
Aggregations