use of io.hops.hopsworks.persistence.entity.git.config.GitProvider in project hopsworks by logicalclocks.
the class GitCommandConfigurationValidator method validateProviderConfiguration.
public void validateProviderConfiguration(BasicAuthSecrets secrets, GitCommandConfiguration gitCommandConfiguration) throws GitOpException {
GitCommandType commandType = gitCommandConfiguration.getCommandType();
GitProvider gitProvider = gitCommandConfiguration.getProvider();
// push we still need username and password/token.
if (gitProvider == GitProvider.BITBUCKET && (commandType == GitCommandType.PULL || commandType == GitCommandType.PUSH || commandType == GitCommandType.CLONE) && (Strings.isNullOrEmpty(secrets.getUsername()) || Strings.isNullOrEmpty(secrets.getPassword()))) {
throw new GitOpException(RESTCodes.GitOpErrorCode.GIT_USERNAME_AND_PASSWORD_NOT_SET, Level.WARNING, ". You " + "should setup secrets for " + gitProvider.getProvider() + " to be able to perform a " + commandType.getGitCommand() + " operation");
} else if ((gitProvider == GitProvider.GIT_HUB || gitProvider == GitProvider.GIT_LAB) && (commandType == GitCommandType.PUSH) && (Strings.isNullOrEmpty(secrets.getUsername()) || Strings.isNullOrEmpty(secrets.getPassword()))) {
throw new GitOpException(RESTCodes.GitOpErrorCode.GIT_USERNAME_AND_PASSWORD_NOT_SET, Level.WARNING, ". You should setup secrets for " + gitProvider.getProvider() + " to be able to perform a " + commandType.getGitCommand() + " operation");
}
}
Aggregations