Java Code Examples for io.fabric8.kubernetes.api.model.KubernetesListBuilder#build()
The following examples show how to use
io.fabric8.kubernetes.api.model.KubernetesListBuilder#build() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceMojo.java From jkube with Eclipse Public License 2.0 | 6 votes |
private void addProfiledResourcesFromSubdirectories(PlatformMode platformMode, KubernetesListBuilder builder, File resourceDir, EnricherManager enricherManager) throws IOException, MojoExecutionException { 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 = KubernetesResourceUtil.listResourceFragments(profileDir); if (resourceFiles.length > 0) { KubernetesListBuilder profileBuilder = readResourceFragments(platformMode, resourceFiles); enricherManager.createDefaultResources(platformMode, enricherConfig, profileBuilder); enricherManager.enrich(platformMode, enricherConfig, profileBuilder); KubernetesList profileItems = profileBuilder.build(); for (HasMetadata item : profileItems.getItems()) { builder.addToItems(item); } } } } }
Example 2
Source File: KubernetesResourceUtilTest.java From jkube with Eclipse Public License 2.0 | 6 votes |
@Test public void readWholeDir() throws IOException { ResourceVersioning v = new ResourceVersioning() .withCoreVersion("v2") .withExtensionsVersion("extensions/v2"); KubernetesListBuilder builder = KubernetesResourceUtil.readResourceFragmentsFrom(PlatformMode.kubernetes, v, "pong", new File(jkubeDir, "read-dir").listFiles()); KubernetesList list = builder.build(); assertEquals(2,list.getItems().size()); for (HasMetadata item : list.getItems() ) { assertTrue("Service".equals(item.getKind()) || "ReplicationController".equals(item.getKind())); assertEquals("pong",item.getMetadata().getName()); assertEquals("v2",item.getApiVersion()); } }
Example 3
Source File: MavenProjectEnricherTest.java From jkube with Eclipse Public License 2.0 | 6 votes |
@Test public void testGeneratedResources() { ProjectLabelEnricher projectEnricher = new ProjectLabelEnricher(context); KubernetesListBuilder builder = createListWithDeploymentConfig(); projectEnricher.enrich(PlatformMode.kubernetes, builder); KubernetesList list = builder.build(); Map<String, String> labels = list.getItems().get(0).getMetadata().getLabels(); assertNotNull(labels); assertEquals("groupId", labels.get("group")); assertEquals("artifactId", labels.get("app")); assertEquals("version", labels.get("version")); assertNull(labels.get("project")); builder = new KubernetesListBuilder().withItems(new DeploymentBuilder().build()); projectEnricher.create(PlatformMode.kubernetes, builder); Deployment deployment = (Deployment)builder.buildFirstItem(); Map<String, String> selectors = deployment.getSpec().getSelector().getMatchLabels(); assertEquals("groupId", selectors.get("group")); assertEquals("artifactId", selectors.get("app")); assertNull(selectors.get("version")); assertNull(selectors.get("project")); }
Example 4
Source File: DefaultServiceEnricherTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Test public void headlessServiceNegative() throws Exception { setupExpectations(false, "headless", "false"); DefaultServiceEnricher serviceEnricher = new DefaultServiceEnricher(context); KubernetesListBuilder builder = new KubernetesListBuilder(); serviceEnricher.create(PlatformMode.kubernetes, builder); // Validate that the generated resource contains KubernetesList list = builder.build(); assertEquals(list.getItems().size(),0); }
Example 5
Source File: DefaultServiceEnricherTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
private String enrich() throws JsonProcessingException { // Enrich DefaultServiceEnricher serviceEnricher = new DefaultServiceEnricher(context); KubernetesListBuilder builder = new KubernetesListBuilder(); serviceEnricher.create(PlatformMode.kubernetes, builder); // Validate that the generated resource contains KubernetesList list = builder.build(); assertEquals(1, list.getItems().size()); return ResourceUtil.toJson(list.getItems().get(0)); }
Example 6
Source File: PortNameEnricherTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
private KubernetesList enrich() throws com.fasterxml.jackson.core.JsonProcessingException { // Enrich PortNameEnricher portNameEnricher = new PortNameEnricher(context); KubernetesListBuilder builder = getPodTemplateList(); portNameEnricher.create(PlatformMode.kubernetes,builder); // Validate that the generated resource contains KubernetesList list = builder.build(); System.out.println(list); return list; }
Example 7
Source File: DockerRegistrySecretEnricherTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Test public void testDockerRegistryWithBadKind() { setupExpectations(); DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context); KubernetesListBuilder builder = new KubernetesListBuilder(); Secret secret = createBaseSecret(true); secret.setKind("Secrets"); builder.addToSecretItems(createBaseSecret(true)); KubernetesList expected = builder.build(); enricher.create(PlatformMode.kubernetes, builder); assertEquals(expected, builder.build()); }
Example 8
Source File: DockerRegistrySecretEnricherTest.java From jkube with Eclipse Public License 2.0 | 5 votes |
@Test public void testDockerRegistryWithBadAnnotation() { DockerRegistrySecretEnricher enricher = new DockerRegistrySecretEnricher(context); setupExpectations(); KubernetesListBuilder builder = new KubernetesListBuilder(); Secret secret = createBaseSecret(true); secret.getMetadata().getAnnotations().put(annotation, "docker1.io"); builder.addToSecretItems(createBaseSecret(true)); KubernetesList expected = builder.build(); enricher.create(PlatformMode.kubernetes, builder); assertEquals(expected, builder.build()); }
Example 9
Source File: OpenshiftBuildService.java From jkube with Eclipse Public License 2.0 | 5 votes |
private void applyResourceObjects(BuildServiceConfig config, OpenShiftClient client, KubernetesListBuilder builder) throws Exception { if (config.getEnricherTask() != null) { config.getEnricherTask().execute(builder); } if (builder.hasItems()) { KubernetesList k8sList = builder.build(); client.lists().create(k8sList); } }
Example 10
Source File: DependencyEnricherTest.java From jkube with Eclipse Public License 2.0 | 4 votes |
private KubernetesList enrichResources(KubernetesListBuilder aBuilder) { DependencyEnricher enricher = new DependencyEnricher(context); enricher.create(PlatformMode.kubernetes, aBuilder); enricher.enrich(PlatformMode.kubernetes, aBuilder); return aBuilder.build(); }