Search in sources :

Example 1 with OpenShiftProviderImpl

use of org.guvnor.ala.openshift.model.OpenShiftProviderImpl in project kie-wb-common by kiegroup.

the class OpenShiftProviderConfigExecutor method apply.

@Override
public Optional<OpenShiftProvider> apply(final OpenShiftProviderConfig openshiftProviderConfig) {
    if (openshiftProviderConfig.getName() == null || openshiftProviderConfig.getName().isEmpty()) {
        throw new ProvisioningException("No name was provided for the OpenShiftProviderConfig.getName() " + "configuration parameter. You might probably have to properly set " + "the pipeline input parameter: " + ProviderConfig.PROVIDER_NAME);
    }
    Provider provider = runtimeRegistry.getProvider(openshiftProviderConfig.getName());
    OpenShiftProvider openshiftProvider;
    if (provider != null) {
        if (!(provider instanceof OpenShiftProvider)) {
            throw new ProvisioningException("The provider: " + openshiftProviderConfig.getName() + " must be an instance of " + OpenShiftProviderConfig.class + " but is: " + provider.getClass());
        } else {
            openshiftProvider = (OpenShiftProvider) provider;
        }
    } else {
        openshiftProvider = new OpenShiftProviderImpl(openshiftProviderConfig.getName(), openshiftProviderConfig);
        runtimeRegistry.registerProvider(openshiftProvider);
    }
    return Optional.of(openshiftProvider);
}
Also used : ProvisioningException(org.guvnor.ala.exceptions.ProvisioningException) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftProviderConfig(org.guvnor.ala.openshift.config.OpenShiftProviderConfig) Provider(org.guvnor.ala.runtime.providers.Provider) OpenShiftProvider(org.guvnor.ala.openshift.model.OpenShiftProvider) OpenShiftProviderImpl(org.guvnor.ala.openshift.model.OpenShiftProviderImpl)

Aggregations

ProvisioningException (org.guvnor.ala.exceptions.ProvisioningException)1 OpenShiftProviderConfig (org.guvnor.ala.openshift.config.OpenShiftProviderConfig)1 OpenShiftProvider (org.guvnor.ala.openshift.model.OpenShiftProvider)1 OpenShiftProviderImpl (org.guvnor.ala.openshift.model.OpenShiftProviderImpl)1 Provider (org.guvnor.ala.runtime.providers.Provider)1