use of io.strimzi.api.kafka.model.connect.build.DockerOutput in project strimzi-kafka-operator by strimzi.
the class KafkaConnectBuild method fromCrd.
/**
* Created the KafkaConnectBuild instance from the Kafka Connect Custom Resource
*
* @param reconciliation The reconciliation
* @param kafkaConnect Kafka Connect CR with the build configuration
* @param versions Kafka versions configuration
* @return Instance of KafkaConnectBuild class
*/
@SuppressWarnings({ "checkstyle:CyclomaticComplexity", "checkstyle:NPathComplexity" })
public static KafkaConnectBuild fromCrd(Reconciliation reconciliation, KafkaConnect kafkaConnect, KafkaVersion.Lookup versions) {
KafkaConnectBuild build = new KafkaConnectBuild(reconciliation, kafkaConnect);
KafkaConnectSpec spec = kafkaConnect.getSpec();
if (spec == null) {
throw new InvalidResourceException("Required .spec section is missing.");
}
build.setOwnerReference(kafkaConnect);
if (spec.getBuild() != null) {
validateBuildConfiguration(spec.getBuild());
// The additionalKanikoOptions are validated separately to avoid parsing the list twice
if (spec.getBuild().getOutput() != null && spec.getBuild().getOutput() instanceof DockerOutput) {
DockerOutput dockerOutput = (DockerOutput) spec.getBuild().getOutput();
if (dockerOutput.getAdditionalKanikoOptions() != null && !dockerOutput.getAdditionalKanikoOptions().isEmpty()) {
validateAdditionalKanikoOptions(dockerOutput.getAdditionalKanikoOptions());
build.additionalKanikoOptions = dockerOutput.getAdditionalKanikoOptions();
}
}
}
build.baseImage = versions.kafkaConnectVersion(spec.getImage(), spec.getVersion());
if (spec.getTemplate() != null) {
KafkaConnectTemplate template = spec.getTemplate();
ModelUtils.parsePodTemplate(build, template.getBuildPod());
if (template.getBuildContainer() != null && template.getBuildContainer().getEnv() != null) {
build.templateBuildContainerEnvVars = template.getBuildContainer().getEnv();
}
if (template.getBuildContainer() != null && template.getBuildContainer().getSecurityContext() != null) {
build.templateBuildContainerSecurityContext = template.getBuildContainer().getSecurityContext();
}
if (template.getBuildConfig() != null) {
build.pullSecret = template.getBuildConfig().getPullSecret();
if (template.getBuildConfig().getMetadata() != null) {
if (template.getBuildConfig().getMetadata().getLabels() != null) {
build.templateBuildConfigLabels = template.getBuildConfig().getMetadata().getLabels();
}
if (template.getBuildConfig().getMetadata().getAnnotations() != null) {
build.templateBuildConfigAnnotations = template.getBuildConfig().getMetadata().getAnnotations();
}
}
}
if (template.getBuildServiceAccount() != null && template.getBuildServiceAccount().getMetadata() != null) {
build.templateServiceAccountLabels = template.getBuildServiceAccount().getMetadata().getLabels();
build.templateServiceAccountAnnotations = template.getBuildServiceAccount().getMetadata().getAnnotations();
}
}
build.templatePodLabels = Util.mergeLabelsOrAnnotations(build.templatePodLabels, DEFAULT_POD_LABELS);
build.build = spec.getBuild();
return build;
}
use of io.strimzi.api.kafka.model.connect.build.DockerOutput in project strimzi-kafka-operator by strimzi.
the class KafkaConnectBuild method getVolumes.
/**
* Generates a list of volumes used by the builder pod
*
* @param isOpenShift Flag defining whether we are running on OpenShift
*
* @return List of volumes
*/
private List<Volume> getVolumes(boolean isOpenShift) {
List<Volume> volumes = new ArrayList<>(2);
volumes.add(VolumeUtils.createConfigMapVolume("dockerfile", KafkaConnectResources.dockerFileConfigMapName(cluster), Collections.singletonMap("Dockerfile", "Dockerfile")));
if (build.getOutput() instanceof DockerOutput) {
DockerOutput output = (DockerOutput) build.getOutput();
if (output.getPushSecret() != null) {
volumes.add(VolumeUtils.createSecretVolume("docker-credentials", output.getPushSecret(), Collections.singletonMap(".dockerconfigjson", "config.json"), isOpenShift));
}
} else {
throw new RuntimeException("Kubernetes build requires output of type `docker`.");
}
return volumes;
}
use of io.strimzi.api.kafka.model.connect.build.DockerOutput in project strimzi-kafka-operator by strimzi.
the class KafkaConnectBuild method getVolumeMounts.
/**
* Generates a list of volume mounts used by the builder pod
*
* @return List of volume mounts
*/
private List<VolumeMount> getVolumeMounts() {
List<VolumeMount> volumeMounts = new ArrayList<>(2);
volumeMounts.add(new VolumeMountBuilder().withName("dockerfile").withMountPath("/dockerfile").build());
if (build.getOutput() instanceof DockerOutput) {
DockerOutput output = (DockerOutput) build.getOutput();
if (output.getPushSecret() != null) {
volumeMounts.add(new VolumeMountBuilder().withName("docker-credentials").withMountPath("/kaniko/.docker").build());
}
} else {
throw new RuntimeException("Kubernetes build requires output of type `docker`.");
}
return volumeMounts;
}
Aggregations