@Test public void testDaemonSetEnrichment() throws IOException { KubernetesListBuilder builder = new KubernetesListBuilder() .addNewDaemonSetItem() .withNewMetadata() .addToAnnotations("annkey", "annvalue") .endMetadata() .withNewSpec() .withNewTemplate() .withNewSpec() .withContainers(createContainers( "c1", "iss:1.1.0", "c2", "docker.io/a-docker-user/is:latest" )) .endSpec() .endTemplate() .endSpec() .endDaemonSetItem(); TriggersAnnotationEnricher enricher = new TriggersAnnotationEnricher(context); enricher.enrich(PlatformMode.kubernetes, builder); DaemonSet res = (DaemonSet) builder.build().getItems().get(0); String triggers = res.getMetadata().getAnnotations().get("image.openshift.io/triggers"); assertNotNull(triggers); List<ImageChangeTrigger> triggerList = OBJECT_MAPPER.readValue(triggers, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, ImageChangeTrigger.class)); assertEquals(1, triggerList.size()); ImageChangeTrigger trigger = triggerList.get(0); assertEquals("ImageStreamTag", trigger.getFrom().getKind()); assertEquals("iss:1.1.0", trigger.getFrom().getName()); assertTrue(trigger.getAdditionalProperties().containsKey("fieldPath")); assertEquals("annvalue", res.getMetadata().getAnnotations().get("annkey")); }
@Override public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { builder.accept(new TypedVisitor<StatefulSetBuilder>() { @Override public void visit(StatefulSetBuilder o) { StatefulSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<ReplicaSetBuilder>() { @Override public void visit(ReplicaSetBuilder o) { ReplicaSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<DaemonSetBuilder>() { @Override public void visit(DaemonSetBuilder o) { DaemonSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); }
TriggersAnnotationEnricher extends BaseEnricher { @Override public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { builder.accept(new TypedVisitor<StatefulSetBuilder>() { @Override public void visit(StatefulSetBuilder o) { StatefulSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<ReplicaSetBuilder>() { @Override public void visit(ReplicaSetBuilder o) { ReplicaSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<DaemonSetBuilder>() { @Override public void visit(DaemonSetBuilder o) { DaemonSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); } }
TriggersAnnotationEnricher extends BaseEnricher { @Override public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { builder.accept(new TypedVisitor<StatefulSetBuilder>() { @Override public void visit(StatefulSetBuilder o) { StatefulSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<ReplicaSetBuilder>() { @Override public void visit(ReplicaSetBuilder o) { ReplicaSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<DaemonSetBuilder>() { @Override public void visit(DaemonSetBuilder o) { DaemonSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); } TriggersAnnotationEnricher(MavenEnricherContext buildContext); }
TriggersAnnotationEnricher extends BaseEnricher { @Override public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { builder.accept(new TypedVisitor<StatefulSetBuilder>() { @Override public void visit(StatefulSetBuilder o) { StatefulSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<ReplicaSetBuilder>() { @Override public void visit(ReplicaSetBuilder o) { ReplicaSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<DaemonSetBuilder>() { @Override public void visit(DaemonSetBuilder o) { DaemonSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); } TriggersAnnotationEnricher(MavenEnricherContext buildContext); @Override void enrich(PlatformMode platformMode, KubernetesListBuilder builder); }
TriggersAnnotationEnricher extends BaseEnricher { @Override public void enrich(PlatformMode platformMode, KubernetesListBuilder builder) { builder.accept(new TypedVisitor<StatefulSetBuilder>() { @Override public void visit(StatefulSetBuilder o) { StatefulSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<ReplicaSetBuilder>() { @Override public void visit(ReplicaSetBuilder o) { ReplicaSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); builder.accept(new TypedVisitor<DaemonSetBuilder>() { @Override public void visit(DaemonSetBuilder o) { DaemonSet s = o.build(); if (canWriteTriggers(s)) { o.withMetadata(getMetaEnrichedWithTriggers(s.getMetadata(), o)); } } }); } TriggersAnnotationEnricher(MavenEnricherContext buildContext); @Override void enrich(PlatformMode platformMode, KubernetesListBuilder builder);  }