Java Code Examples for io.fabric8.kubernetes.api.model.PodSpec#setAdditionalProperty()
The following examples show how to use
io.fabric8.kubernetes.api.model.PodSpec#setAdditionalProperty() .
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: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test( expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Pods have to have volumes with unique names but there are multiple `volume` volumes") public void shouldThrownAnExceptionIfVolumeNameCollisionHappened() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder().withVolumes(new VolumeBuilder().withName("volume").build()).build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder().withVolumes(new VolumeBuilder().withName("volume").build()).build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when podMerger.merge(Arrays.asList(podData1, podData2)); }
Example 2
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test public void shouldNotAddImagePullPolicyTwice() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder() .withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret").build()) .build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder() .withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret").build()) .build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then PodTemplateSpec podTemplate = merged.getSpec().getTemplate(); List<LocalObjectReference> imagePullSecrets = podTemplate.getSpec().getImagePullSecrets(); assertEquals(imagePullSecrets.size(), 1); assertEquals(imagePullSecrets.get(0).getName(), "secret"); }
Example 3
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test public void shouldAssignSecurityContextSharedByPods() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder() .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(42L).build()) .build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder() .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(42L).build()) .build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then PodTemplateSpec podTemplate = merged.getSpec().getTemplate(); PodSecurityContext sc = podTemplate.getSpec().getSecurityContext(); assertEquals(sc.getRunAsUser(), (Long) 42L); }
Example 4
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test(expectedExceptions = ValidationException.class) public void shouldFailIfSecurityContextDiffersInPods() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder() .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(42L).build()) .build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder() .withSecurityContext(new PodSecurityContextBuilder().withRunAsUser(43L).build()) .build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then // exception is thrown }
Example 5
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test public void shouldAssignServiceAccountSharedByPods() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder().withServiceAccount("sa").build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder().withServiceAccount("sa").build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then PodTemplateSpec podTemplate = merged.getSpec().getTemplate(); String sa = podTemplate.getSpec().getServiceAccount(); assertEquals(sa, "sa"); }
Example 6
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test(expectedExceptions = ValidationException.class) public void shouldFailServiceAccountDiffersInPods() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder().withServiceAccount("sa").build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder().withServiceAccount("sb").build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then // exception is thrown }
Example 7
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test public void shouldAssignServiceAccountNameSharedByPods() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder().withServiceAccountName("sa").build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder().withServiceAccountName("sa").build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then PodTemplateSpec podTemplate = merged.getSpec().getTemplate(); String sa = podTemplate.getSpec().getServiceAccountName(); assertEquals(sa, "sa"); }
Example 8
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 6 votes |
@Test(expectedExceptions = ValidationException.class) public void shouldFailServiceAccountNameDiffersInPods() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder().withServiceAccountName("sa").build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder().withServiceAccountName("sb").build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then // exception is thrown }
Example 9
Source File: PodMergerTest.java From che with Eclipse Public License 2.0 | 5 votes |
@Test public void shouldMergeSpecsOfPodsData() throws Exception { // given PodSpec podSpec1 = new PodSpecBuilder() .withContainers(new ContainerBuilder().withName("c1").build()) .withInitContainers(new ContainerBuilder().withName("initC1").build()) .withVolumes(new VolumeBuilder().withName("v1").build()) .withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret1").build()) .build(); podSpec1.setAdditionalProperty("add1", 1L); PodData podData1 = new PodData(podSpec1, new ObjectMetaBuilder().build()); PodSpec podSpec2 = new PodSpecBuilder() .withContainers(new ContainerBuilder().withName("c2").build()) .withInitContainers(new ContainerBuilder().withName("initC2").build()) .withVolumes(new VolumeBuilder().withName("v2").build()) .withImagePullSecrets(new LocalObjectReferenceBuilder().withName("secret2").build()) .build(); podSpec2.setAdditionalProperty("add2", 2L); PodData podData2 = new PodData(podSpec2, new ObjectMetaBuilder().build()); // when Deployment merged = podMerger.merge(Arrays.asList(podData1, podData2)); // then PodTemplateSpec podTemplate = merged.getSpec().getTemplate(); verifyContainsAllFrom(podTemplate.getSpec(), podData1.getSpec()); verifyContainsAllFrom(podTemplate.getSpec(), podData2.getSpec()); }