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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations