Search in sources :

Example 31 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class CreateApplicationFromImageJob method addToGeneratedResources.

@Override
protected void addToGeneratedResources(Map<String, IResource> resources, final Connection connection, final String name, final IProject project) {
    IBuildConfigBuilder builder = connection.getResourceBuilder(IBuildConfigBuilder.class);
    IBuildConfig bc = builder.named(name).inNamespace(project.getName()).fromGitSource().fromGitUrl(buildConfigModel.getGitRepositoryUrl()).usingGitReference(buildConfigModel.getGitReference()).inContextDir(buildConfigModel.getContextDir()).end().usingSourceStrategy().fromImageStreamTag(buildConfigModel.getBuilderImageName()).inNamespace(buildConfigModel.getBuilderImageNamespace()).withEnvVars(createEnvVars()).end().buildOnSourceChange(buildConfigModel.isConfigWebHook()).buildOnConfigChange(buildConfigModel.isConfigChangeTrigger()).buildOnImageChange(buildConfigModel.isImageChangeTrigger()).toImageStreamTag(new DockerImageURI(name).getNameAndTag()).build();
    resources.put(ResourceKind.BUILD_CONFIG, bc);
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) IBuildConfig(com.openshift.restclient.model.IBuildConfig) IBuildConfigBuilder(com.openshift.restclient.model.build.IBuildConfigBuilder)

Example 32 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class DeployImageJobTest method givenTheDeploymentConfigExistFor.

private void givenTheDeploymentConfigExistFor(String name, String tag, String triggerNamespace, String triggerKind) {
    IDeploymentImageChangeTrigger trigger = mock(IDeploymentImageChangeTrigger.class);
    when(trigger.getType()).thenReturn(DeploymentTriggerType.IMAGE_CHANGE);
    when(trigger.getNamespace()).thenReturn(triggerNamespace);
    when(trigger.getKind()).thenReturn(triggerKind);
    when(trigger.getFrom()).thenReturn(new DockerImageURI(null, null, name, tag));
    IDeploymentConfig dc = createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG, new IResourceVisitor<IDeploymentConfig>() {

        @Override
        public void visit(IDeploymentConfig resource) {
            Collection<IDeploymentTrigger> triggers = new ArrayList<IDeploymentTrigger>();
            triggers.add(trigger);
            when(resource.getTriggers()).thenReturn(triggers);
        }
    });
    when(connection.getResource(ResourceKind.DEPLOYMENT_CONFIG, project.getName(), parameters.getResourceName())).thenReturn(dc);
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) Collection(java.util.Collection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IDeploymentTrigger(com.openshift.restclient.model.deploy.IDeploymentTrigger) IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)

Example 33 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class BuildConfigPropertySourceTest method givenSTIBuildStrategy.

private ISourceBuildStrategy givenSTIBuildStrategy() {
    ISourceBuildStrategy strategy = mock(ISourceBuildStrategy.class);
    when(strategy.getType()).thenReturn(BuildStrategyType.SOURCE);
    when(strategy.getScriptsLocation()).thenReturn("scriptlocation");
    when(strategy.getImage()).thenReturn(new DockerImageURI("foobar"));
    Map<String, String> env = new HashMap<>();
    env.put("foo", "bar");
    when(strategy.getEnvironmentVariables()).thenReturn(env);
    when(resource.getBuildStrategy()).thenReturn(strategy);
    return strategy;
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI) HashMap(java.util.HashMap)

Example 34 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class BuildConfigPropertySourceTest method givenCustomBuildStrategy.

private ICustomBuildStrategy givenCustomBuildStrategy() {
    ICustomBuildStrategy strategy = mock(ICustomBuildStrategy.class);
    when(strategy.getType()).thenReturn(BuildStrategyType.CUSTOM);
    Map<String, String> env = new HashMap<>();
    env.put("foo", "bar");
    when(strategy.getEnvironmentVariables()).thenReturn(env);
    when(strategy.exposeDockerSocket()).thenReturn(true);
    when(strategy.getImage()).thenReturn(new DockerImageURI("foo/bar:latest"));
    when(resource.getBuildStrategy()).thenReturn(strategy);
    return strategy;
}
Also used : DockerImageURI(com.openshift.restclient.images.DockerImageURI) HashMap(java.util.HashMap) ICustomBuildStrategy(com.openshift.restclient.model.build.ICustomBuildStrategy)

Example 35 with DockerImageURI

use of com.openshift.restclient.images.DockerImageURI in project jbosstools-openshift by jbosstools.

the class OpenshiftEapProfileDetector method isEapStyle.

@SuppressWarnings({ "deprecation" })
public boolean isEapStyle(IBuildConfig buildConfig) {
    if (buildConfig == null) {
        return false;
    }
    // First check buildconfig docker image name
    IBuildStrategy strategy = buildConfig.getBuildStrategy();
    DockerImageURI image = null;
    boolean isEapStyle = false;
    if (strategy instanceof ISourceBuildStrategy) {
        image = ((ISourceBuildStrategy) strategy).getImage();
    } else if (strategy instanceof ICustomBuildStrategy) {
        image = ((ICustomBuildStrategy) strategy).getImage();
    } else if (strategy instanceof IDockerBuildStrategy) {
        image = ((IDockerBuildStrategy) strategy).getBaseImage();
    } else if (strategy instanceof ISTIBuildStrategy) {
        image = ((ISTIBuildStrategy) strategy).getImage();
    }
    if (image != null) {
        isEapStyle = containsEapLikeKeywords(image.getName());
    }
    if (!isEapStyle) {
        // Check template labels as a last resort
        // not sure it's even possible to reach this point
        Map<String, String> labels = buildConfig.getLabels();
        if (labels != null) {
            String template = labels.get("template");
            isEapStyle = containsEapLikeKeywords(template);
        }
    }
    return isEapStyle;
}
Also used : ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) DockerImageURI(com.openshift.restclient.images.DockerImageURI) IDockerBuildStrategy(com.openshift.restclient.model.build.IDockerBuildStrategy) IBuildStrategy(com.openshift.restclient.model.build.IBuildStrategy) ISTIBuildStrategy(com.openshift.restclient.model.build.ISTIBuildStrategy) ISTIBuildStrategy(com.openshift.restclient.model.build.ISTIBuildStrategy) ICustomBuildStrategy(com.openshift.restclient.model.build.ICustomBuildStrategy)

Aggregations

DockerImageURI (com.openshift.restclient.images.DockerImageURI)39 Test (org.junit.Test)23 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)9 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)6 IImageStream (com.openshift.restclient.model.IImageStream)5 ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)5 IImageStreamImportCapability (com.openshift.restclient.capability.resources.IImageStreamImportCapability)4 IResource (com.openshift.restclient.model.IResource)4 IImageStreamImport (com.openshift.restclient.model.image.IImageStreamImport)4 HashMap (java.util.HashMap)4 IResourceFactory (com.openshift.restclient.IResourceFactory)3 IBuildConfig (com.openshift.restclient.model.IBuildConfig)3 IProject (com.openshift.restclient.model.IProject)3 IStatus (com.openshift.restclient.model.IStatus)3 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)3 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)3 Collection (java.util.Collection)3 EnvironmentVariable (org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable)3 ResourceKind (com.openshift.restclient.ResourceKind)2 IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)2