Search in sources :

Example 1 with GitCommandType

use of io.hops.hopsworks.persistence.entity.git.config.GitCommandType 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");
    }
}
Also used : GitCommandType(io.hops.hopsworks.persistence.entity.git.config.GitCommandType) GitOpException(io.hops.hopsworks.exceptions.GitOpException) GitProvider(io.hops.hopsworks.persistence.entity.git.config.GitProvider)

Aggregations

GitOpException (io.hops.hopsworks.exceptions.GitOpException)1 GitCommandType (io.hops.hopsworks.persistence.entity.git.config.GitCommandType)1 GitProvider (io.hops.hopsworks.persistence.entity.git.config.GitProvider)1