use of io.fabric8.openshift.api.model.BuildOutput in project fabric8-maven-plugin by fabric8io.
the class OpenshiftBuildService method updateOrCreateBuildConfig.
private String updateOrCreateBuildConfig(BuildServiceConfig config, OpenShiftClient client, KubernetesListBuilder builder, ImageConfiguration imageConfig) {
ImageName imageName = new ImageName(imageConfig.getName());
String buildName = getS2IBuildName(config, imageName);
String imageStreamName = getImageStreamName(imageName);
String outputImageStreamTag = imageStreamName + ":" + (imageName.getTag() != null ? imageName.getTag() : "latest");
BuildStrategy buildStrategyResource = createBuildStrategy(imageConfig, config.getOpenshiftBuildStrategy());
BuildOutput buildOutput = new BuildOutputBuilder().withNewTo().withKind("ImageStreamTag").withName(outputImageStreamTag).endTo().build();
// Fetch exsting build config
BuildConfig buildConfig = client.buildConfigs().withName(buildName).get();
if (buildConfig != null) {
// lets verify the BC
BuildConfigSpec spec = getBuildConfigSpec(buildConfig);
validateSourceType(buildName, spec);
if (config.getBuildRecreateMode().isBuildConfig()) {
// Delete and recreate afresh
client.buildConfigs().withName(buildName).delete();
return createBuildConfig(builder, buildName, buildStrategyResource, buildOutput);
} else {
// Update & return
return updateBuildConfig(client, buildName, buildStrategyResource, buildOutput, spec);
}
} else {
// Create afresh
return createBuildConfig(builder, buildName, buildStrategyResource, buildOutput);
}
}
Aggregations