use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class StatefulSetHandlerTest method before.
@Before
public void before() {
// volume config with name and multiple mount
mounts.add("/path/system");
mounts.add("/path/sys");
ports.add("8080");
ports.add("9090");
tags.add("latest");
tags.add("test");
VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
volumes1.add(volumeConfig1);
// container name with alias
BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
images.add(imageConfiguration);
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class ContainerHandler method getContainers.
List<Container> getContainers(ResourceConfig config, List<ImageConfiguration> images) {
List<Container> ret = new ArrayList<>();
for (ImageConfiguration imageConfig : images) {
if (imageConfig.getBuildConfiguration() != null) {
Probe livenessProbe = probeHandler.getProbe(config.getLiveness());
Probe readinessProbe = probeHandler.getProbe(config.getReadiness());
Container container = new ContainerBuilder().withName(KubernetesResourceUtil.extractContainerName(project, imageConfig)).withImage(getImageName(imageConfig)).withImagePullPolicy(getImagePullPolicy(config)).withEnv(envVarHandler.getEnvironmentVariables(config.getEnv())).withSecurityContext(createSecurityContext(config)).withPorts(getContainerPorts(imageConfig)).withVolumeMounts(getVolumeMounts(config)).withLivenessProbe(livenessProbe).withReadinessProbe(readinessProbe).build();
ret.add(container);
}
}
return ret;
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class GeneratorManager method generate.
public static List<ImageConfiguration> generate(List<ImageConfiguration> imageConfigs, GeneratorContext genCtx, boolean prePackagePhase) throws MojoExecutionException {
List<ImageConfiguration> ret = imageConfigs;
PluginServiceFactory<GeneratorContext> pluginFactory = genCtx.isUseProjectClasspath() ? new PluginServiceFactory<GeneratorContext>(genCtx, ClassUtil.createProjectClassLoader(genCtx.getProject(), genCtx.getLogger())) : new PluginServiceFactory<GeneratorContext>(genCtx);
List<Generator> generators = pluginFactory.createServiceObjects("META-INF/fabric8/generator-default", "META-INF/fabric8/fabric8-generator-default", "META-INF/fabric8/generator", "META-INF/fabric8-generator");
ProcessorConfig config = genCtx.getConfig();
Logger log = genCtx.getLogger();
List<Generator> usableGenerators = config.prepareProcessors(generators, "generator");
log.verbose("Generators:");
for (Generator generator : usableGenerators) {
log.verbose(" - %s", generator.getName());
if (generator.isApplicable(ret)) {
log.info("Running generator %s", generator.getName());
ret = generator.customize(ret, prePackagePhase);
}
}
return ret;
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class PushMojo method customizeConfig.
/**
* Customization hook called by the base plugin.
*
* @param configs configuration to customize
* @return the configuration customized by our generators.
*/
@Override
public List<ImageConfiguration> customizeConfig(List<ImageConfiguration> configs) {
try {
ProcessorConfig generatorConfig = ProfileUtil.blendProfileWithConfiguration(ProfileUtil.GENERATOR_CONFIG, profile, resourceDir, generator);
GeneratorContext ctx = new GeneratorContext.Builder().config(generatorConfig).project(project).session(session).goalFinder(goalFinder).goalName("fabric8:push").logger(log).mode(mode).strategy(buildStrategy).useProjectClasspath(false).build();
return GeneratorManager.generate(configs, ctx, true);
} catch (Exception e) {
throw new IllegalArgumentException("Cannot extract generator config: " + e, e);
}
}
use of io.fabric8.maven.docker.config.ImageConfiguration in project fabric8-maven-plugin by fabric8io.
the class ResourceMojo method generateAppResources.
private KubernetesListBuilder generateAppResources(List<ImageConfiguration> images, EnricherManager enricherManager) throws IOException, MojoExecutionException {
Path composeFilePath = checkComposeConfig();
ComposeService composeUtil = new ComposeService(komposeBinDir, composeFilePath, log);
try {
File[] resourceFiles = KubernetesResourceUtil.listResourceFragments(resourceDir);
File[] composeResourceFiles = composeUtil.convertToKubeFragments();
File[] allResources = ArrayUtils.addAll(resourceFiles, composeResourceFiles);
KubernetesListBuilder builder;
// Add resource files found in the fabric8 directory
if (allResources != null && allResources.length > 0) {
if (resourceFiles != null && resourceFiles.length > 0) {
log.info("using resource templates from %s", resourceDir);
}
if (composeResourceFiles != null && composeResourceFiles.length > 0) {
log.info("using resource templates generated from compose file");
}
builder = readResourceFragments(allResources);
} else {
builder = new KubernetesListBuilder();
}
// Add locally configured objects
if (resources != null) {
// TODO: Allow also support resources to be specified via XML
addConfiguredResources(builder, images);
}
// Create default resources for app resources only
enricherManager.createDefaultResources(builder);
// Enrich descriptors
enricherManager.enrich(builder);
return builder;
} catch (ConstraintViolationException e) {
String message = ValidationUtil.createValidationMessage(e.getConstraintViolations());
log.error("ConstraintViolationException: %s", message);
throw new MojoExecutionException(message, e);
} catch (Fabric8ServiceException e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
composeUtil.cleanComposeResources();
}
}
Aggregations