use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.
the class VertxHealthCheckEnricherTest method setupExpectations.
private void setupExpectations(Map<String, Object> config, TreeMap<String, String> plexusMavenConfig) {
final ProcessorConfig processorConfig = new ProcessorConfig();
processorConfig.setConfig(Collections.singletonMap("jkube-healthcheck-vertx", plexusMavenConfig));
// @formatter:off
new Expectations() {
{
context.hasPlugin(VertxHealthCheckEnricher.VERTX_MAVEN_PLUGIN_GROUP, VertxHealthCheckEnricher.VERTX_MAVEN_PLUGIN_ARTIFACT);
result = true;
context.getConfiguration().getProcessorConfig();
result = processorConfig;
minTimes = 0;
context.getConfiguration().getPluginConfiguration(anyString, anyString);
result = Optional.of(config);
context.getConfiguration().getPluginConfigLookup();
result = getProjectLookup(config);
minTimes = 0;
}
};
// @formatter:on
}
use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.
the class DefaultResourceService method generateProfiledResourcesFromSubdirectories.
private List<HasMetadata> generateProfiledResourcesFromSubdirectories(PlatformMode platformMode, EnricherManager enricherManager) throws IOException {
final List<HasMetadata> ret = new ArrayList<>();
final File resourceDir = resourceServiceConfig.getResourceDir();
File[] profileDirs = resourceDir.listFiles(File::isDirectory);
if (profileDirs != null) {
for (File profileDir : profileDirs) {
Profile foundProfile = ProfileUtil.findProfile(profileDir.getName(), resourceDir);
ProcessorConfig enricherConfig = foundProfile.getEnricherConfig();
File[] resourceFiles = listResourceFragments(profileDir);
final File[] processedResources = processResourceFiles(resourceFiles);
if (processedResources.length > 0) {
KubernetesListBuilder profileBuilder = readResourceFragments(platformMode, processedResources);
enricherManager.createDefaultResources(platformMode, enricherConfig, profileBuilder);
enricherManager.enrich(platformMode, enricherConfig, profileBuilder);
ret.addAll(profileBuilder.buildItems());
}
}
}
return ret;
}
use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.
the class QuarkusGeneratorTest method setUp.
@Before
public void setUp() throws IOException {
config = new ProcessorConfig();
projectProps = new Properties();
projectProps.put("jkube.generator.name", "quarkus");
baseDir = temporaryFolder.newFolder("target");
// @formatter:off
new Expectations() {
{
project.getVersion();
result = "0.0.1-SNAPSHOT";
minTimes = 0;
project.getBaseDirectory();
result = baseDir;
minTimes = 0;
project.getBuildDirectory();
result = baseDir.getAbsolutePath();
minTimes = 0;
project.getProperties();
result = projectProps;
project.getCompileClassPathElements();
result = Collections.emptyList();
minTimes = 0;
project.getOutputDirectory();
result = baseDir;
ctx.getProject();
result = project;
ctx.getConfig();
result = config;
ctx.getStrategy();
result = JKubeBuildStrategy.s2i;
minTimes = 0;
defaultImageLookup.getImageName("java.upstream.docker");
result = "quarkus/docker";
defaultImageLookup.getImageName("java.upstream.s2i");
result = "quarkus/s2i";
}
};
// @formatter:on
}
use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.
the class AutoTLSEnricherTest method testAdapt.
@Test
public void testAdapt() {
final AdaptTestConfig[] data = new AdaptTestConfig[] { AdaptTestConfig.builder().mode(RuntimeMode.KUBERNETES).build(), new AdaptTestConfig(RuntimeMode.OPENSHIFT, null, "tls-jks-converter", null, "jimmidyson/pemtokeystore:v0.1.0", null, "tls-pem", null, "tls-jks"), new AdaptTestConfig(RuntimeMode.OPENSHIFT, null, "tls-jks-converter", null, "jimmidyson/pemtokeystore:v0.1.0", "tls-a", "tls-a", null, "tls-jks"), new AdaptTestConfig(RuntimeMode.OPENSHIFT, null, "tls-jks-converter", null, "jimmidyson/pemtokeystore:v0.1.0", null, "tls-pem", "jks-b", "jks-b"), new AdaptTestConfig(RuntimeMode.OPENSHIFT, "test-container-name", "test-container-name", "image/123", "image/123", "tls-a", "tls-a", "jks-b", "jks-b") };
for (final AdaptTestConfig tc : data) {
TreeMap<String, Object> configMap = new TreeMap<>();
configMap.put("pemToJKSInitContainerName", tc.initContainerNameConfig);
configMap.put("pemToJKSInitContainerImage", tc.initContainerImageConfig);
configMap.put("tlsSecretVolumeName", tc.tlsSecretVolumeNameConfig);
configMap.put("jksVolumeName", tc.jksVolumeNameConfig);
final ProcessorConfig config = new ProcessorConfig(null, null, Collections.singletonMap("jkube-openshift-autotls", configMap));
final Properties properties = new Properties();
properties.put(RuntimeMode.JKUBE_EFFECTIVE_PLATFORM_MODE, tc.mode.name());
// @formatter:off
new Expectations() {
{
Configuration configuration = Configuration.builder().processorConfig(config).build();
context.getProperties();
result = properties;
context.getConfiguration();
result = configuration;
}
};
// @formatter:on
AutoTLSEnricher enricher = new AutoTLSEnricher(context);
KubernetesListBuilder klb = new KubernetesListBuilder().addNewPodTemplateItem().withNewMetadata().and().withNewTemplate().withNewMetadata().and().withNewSpec().and().and().and().addNewServiceItem().and();
enricher.enrich(PlatformMode.kubernetes, klb);
PodTemplate pt = (PodTemplate) klb.buildItems().get(0);
Service service = (Service) klb.buildItems().get(1);
ObjectMeta om = service.getMetadata();
List<Container> initContainers = pt.getTemplate().getSpec().getInitContainers();
assertEquals(tc.mode == RuntimeMode.OPENSHIFT, !initContainers.isEmpty());
if (tc.mode == RuntimeMode.KUBERNETES) {
continue;
}
// Test metadata annotation
Map<String, String> generatedAnnotation = om.getAnnotations();
Assert.assertTrue(generatedAnnotation.containsKey(AutoTLSEnricher.AUTOTLS_ANNOTATION_KEY));
Assert.assertTrue(generatedAnnotation.containsValue(context.getGav().getArtifactId() + "-tls"));
// Test Pod template
Gson gson = new Gson();
JsonArray ja = new JsonParser().parse(gson.toJson(initContainers, new TypeToken<Collection<Container>>() {
}.getType())).getAsJsonArray();
assertEquals(1, ja.size());
JsonObject jo = ja.get(0).getAsJsonObject();
assertEquals(tc.initContainerName, jo.get("name").getAsString());
assertEquals(tc.initContainerImage, jo.get("image").getAsString());
// Test volumes are created
List<Volume> volumes = pt.getTemplate().getSpec().getVolumes();
assertEquals(2, volumes.size());
List<String> volumeNames = volumes.stream().map(Volume::getName).collect(Collectors.toList());
Assert.assertTrue(volumeNames.contains(tc.tlsSecretVolumeName));
Assert.assertTrue(volumeNames.contains(tc.jksVolumeName));
// Test volume mounts are created
JsonArray mounts = jo.get("volumeMounts").getAsJsonArray();
assertEquals(2, mounts.size());
JsonObject mount = mounts.get(0).getAsJsonObject();
assertEquals(tc.tlsSecretVolumeName, mount.get("name").getAsString());
mount = mounts.get(1).getAsJsonObject();
assertEquals(tc.jksVolumeName, mount.get("name").getAsString());
}
}
use of org.eclipse.jkube.kit.config.resource.ProcessorConfig in project jkube by eclipse.
the class RouteEnricherTest method setUpExpectations.
@Before
public void setUpExpectations() {
properties = new Properties();
processorConfig = new ProcessorConfig();
klb = new KubernetesListBuilder();
}
Aggregations