io.fabric8.kubernetes.api.model.LocalObjectReferenceBuilder Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.LocalObjectReferenceBuilder.
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 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 #2
Source File: JobHandler.java From module-ballerina-kubernetes with Apache License 2.0 | 5 votes |
private List<LocalObjectReference> getImagePullSecrets(JobModel jobModel) { List<LocalObjectReference> imagePullSecrets = new ArrayList<>(); for (String imagePullSecret : jobModel.getImagePullSecrets()) { imagePullSecrets.add(new LocalObjectReferenceBuilder().withName(imagePullSecret).build()); } return imagePullSecrets; }
Example #3
Source File: DeploymentHandler.java From module-ballerina-kubernetes with Apache License 2.0 | 5 votes |
private List<LocalObjectReference> getImagePullSecrets(DeploymentModel deploymentModel) { List<LocalObjectReference> imagePullSecrets = new ArrayList<>(); for (String imagePullSecret : deploymentModel.getImagePullSecrets()) { imagePullSecrets.add(new LocalObjectReferenceBuilder().withName(imagePullSecret).build()); } return imagePullSecrets; }
Example #4
Source File: ClusterOperatorConfig.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
private static List<LocalObjectReference> parseImagePullSecrets(String imagePullSecretList) { List<LocalObjectReference> imagePullSecrets = null; if (imagePullSecretList != null && !imagePullSecretList.isEmpty()) { if (imagePullSecretList.matches("(\\s*[a-z0-9.-]+\\s*,)*\\s*[a-z0-9.-]+\\s*")) { imagePullSecrets = Arrays.stream(imagePullSecretList.trim().split("\\s*,+\\s*")).map(secret -> new LocalObjectReferenceBuilder().withName(secret).build()).collect(Collectors.toList()); } else { throw new InvalidConfigurationException(ClusterOperatorConfig.STRIMZI_IMAGE_PULL_SECRETS + " is not a valid list of secret names"); } } return imagePullSecrets; }
Example #5
Source File: ClusterOperatorConfigTest.java From strimzi-kafka-operator with Apache License 2.0 | 5 votes |
@Test public void testImagePullSecrets() { Map<String, String> envVars = new HashMap<>(ClusterOperatorConfigTest.envVars); envVars.put(ClusterOperatorConfig.STRIMZI_IMAGE_PULL_SECRETS, "secret1, secret2 , secret3 "); List<LocalObjectReference> imagePullSecrets = ClusterOperatorConfig.fromMap(envVars, KafkaVersionTestUtils.getKafkaVersionLookup()).getImagePullSecrets(); assertThat(imagePullSecrets, hasSize(3)); assertThat(imagePullSecrets, hasItems(new LocalObjectReferenceBuilder().withName("secret1").build(), new LocalObjectReferenceBuilder().withName("secret2").build(), new LocalObjectReferenceBuilder().withName("secret3").build())); }
Example #6
Source File: ImagePullSecretProvisioner.java From che with Eclipse Public License 2.0 | 5 votes |
private void addImagePullSecret(String secretName, PodSpec podSpec) { List<LocalObjectReference> imagePullSecrets = podSpec.getImagePullSecrets(); podSpec.setImagePullSecrets( ImmutableList.<LocalObjectReference>builder() .add(new LocalObjectReferenceBuilder().withName(secretName).build()) .addAll(imagePullSecrets) .build()); }
Example #7
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()); }