Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.quarkus.minikube.deployment.MinikubeProcessor Maven / Gradle / Ivy
package io.quarkus.minikube.deployment;
import static io.quarkus.kubernetes.deployment.Constants.DEPLOYMENT;
import static io.quarkus.kubernetes.deployment.Constants.DEPLOYMENT_GROUP;
import static io.quarkus.kubernetes.deployment.Constants.DEPLOYMENT_VERSION;
import static io.quarkus.kubernetes.deployment.Constants.KUBERNETES;
import static io.quarkus.kubernetes.deployment.Constants.MINIKUBE;
import static io.quarkus.kubernetes.spi.KubernetesDeploymentTargetBuildItem.DEFAULT_PRIORITY;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import io.quarkus.container.spi.BaseImageInfoBuildItem;
import io.quarkus.container.spi.ContainerImageInfoBuildItem;
import io.quarkus.container.spi.ContainerImageLabelBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ApplicationInfoBuildItem;
import io.quarkus.deployment.builditem.InitTaskBuildItem;
import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem;
import io.quarkus.deployment.pkg.PackageConfig;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.kubernetes.client.spi.KubernetesClientCapabilityBuildItem;
import io.quarkus.kubernetes.deployment.AddPortToKubernetesConfig;
import io.quarkus.kubernetes.deployment.DevClusterHelper;
import io.quarkus.kubernetes.deployment.InitTaskProcessor;
import io.quarkus.kubernetes.deployment.KubernetesCommonHelper;
import io.quarkus.kubernetes.deployment.KubernetesConfig;
import io.quarkus.kubernetes.deployment.ResourceNameUtil;
import io.quarkus.kubernetes.spi.ConfiguratorBuildItem;
import io.quarkus.kubernetes.spi.CustomProjectRootBuildItem;
import io.quarkus.kubernetes.spi.DecoratorBuildItem;
import io.quarkus.kubernetes.spi.KubernetesAnnotationBuildItem;
import io.quarkus.kubernetes.spi.KubernetesClusterRoleBuildItem;
import io.quarkus.kubernetes.spi.KubernetesCommandBuildItem;
import io.quarkus.kubernetes.spi.KubernetesDeploymentTargetBuildItem;
import io.quarkus.kubernetes.spi.KubernetesEnvBuildItem;
import io.quarkus.kubernetes.spi.KubernetesHealthLivenessPathBuildItem;
import io.quarkus.kubernetes.spi.KubernetesHealthReadinessPathBuildItem;
import io.quarkus.kubernetes.spi.KubernetesHealthStartupPathBuildItem;
import io.quarkus.kubernetes.spi.KubernetesInitContainerBuildItem;
import io.quarkus.kubernetes.spi.KubernetesJobBuildItem;
import io.quarkus.kubernetes.spi.KubernetesLabelBuildItem;
import io.quarkus.kubernetes.spi.KubernetesPortBuildItem;
import io.quarkus.kubernetes.spi.KubernetesProbePortNameBuildItem;
import io.quarkus.kubernetes.spi.KubernetesResourceMetadataBuildItem;
import io.quarkus.kubernetes.spi.KubernetesRoleBindingBuildItem;
import io.quarkus.kubernetes.spi.KubernetesRoleBuildItem;
import io.quarkus.kubernetes.spi.KubernetesServiceAccountBuildItem;
public class MinikubeProcessor {
private static final int MINIKUBE_PRIORITY = DEFAULT_PRIORITY + 20;
@BuildStep
public void checkMinikube(ApplicationInfoBuildItem applicationInfo, KubernetesConfig config,
BuildProducer deploymentTargets,
BuildProducer resourceMeta) {
deploymentTargets.produce(
new KubernetesDeploymentTargetBuildItem(MINIKUBE, DEPLOYMENT, DEPLOYMENT_GROUP, DEPLOYMENT_VERSION,
MINIKUBE_PRIORITY, true, config.getDeployStrategy()));
String name = ResourceNameUtil.getResourceName(config, applicationInfo);
resourceMeta.produce(
new KubernetesResourceMetadataBuildItem(KUBERNETES, DEPLOYMENT_GROUP, DEPLOYMENT_VERSION, DEPLOYMENT, name));
}
@BuildStep
public void createAnnotations(KubernetesConfig config, BuildProducer annotations) {
config.getAnnotations().forEach((k, v) -> {
annotations.produce(new KubernetesAnnotationBuildItem(k, v, MINIKUBE));
});
}
@BuildStep
public void createLabels(KubernetesConfig config, BuildProducer labels,
BuildProducer imageLabels) {
config.getLabels().forEach((k, v) -> {
labels.produce(new KubernetesLabelBuildItem(k, v, MINIKUBE));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
}
@BuildStep
public List createConfigurators(KubernetesConfig config,
List ports) {
List result = new ArrayList<>();
KubernetesCommonHelper.combinePorts(ports, config).values().forEach(value -> {
result.add(new ConfiguratorBuildItem(new AddPortToKubernetesConfig(value)));
});
return result;
}
@BuildStep
public List createDecorators(ApplicationInfoBuildItem applicationInfo,
OutputTargetBuildItem outputTarget,
KubernetesConfig config,
PackageConfig packageConfig,
Optional metricsConfiguration,
Optional kubernetesClientConfiguration,
List initContainers,
List jobs,
List annotations,
List labels,
List envs,
Optional baseImage,
Optional image,
Optional command,
List ports,
Optional portName,
Optional livenessPath,
Optional readinessPath,
Optional startupPath,
List roles,
List clusterRoles,
List serviceAccounts,
List roleBindings,
Optional customProjectRoot) {
return DevClusterHelper.createDecorators(MINIKUBE, applicationInfo, outputTarget, config, packageConfig,
metricsConfiguration, kubernetesClientConfiguration, initContainers, jobs, annotations, labels, envs,
baseImage, image, command, ports, portName,
livenessPath, readinessPath, startupPath,
roles, clusterRoles, serviceAccounts, roleBindings, customProjectRoot);
}
@BuildStep
void externalizeInitTasks(
ApplicationInfoBuildItem applicationInfo,
KubernetesConfig config,
ContainerImageInfoBuildItem image,
List initTasks,
BuildProducer jobs,
BuildProducer initContainers,
BuildProducer env,
BuildProducer roles,
BuildProducer roleBindings,
BuildProducer serviceAccount,
BuildProducer decorators) {
final String name = ResourceNameUtil.getResourceName(config, applicationInfo);
if (config.isExternalizeInit()) {
InitTaskProcessor.process(MINIKUBE, name, image, initTasks, config.getInitTaskDefaults(), config.getInitTasks(),
jobs, initContainers, env, roles, roleBindings, serviceAccount, decorators);
}
}
}