@Test public void testCamelkIntegration() throws Exception { TestResourceManager manager = new TestResourceManager(); Integration integration = manager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .putConfiguredProperty("username", "admin") .action(HTTP_ACTION) .connection(HTTP_CONNECTION) .build(), new Step.Builder() .stepKind(StepKind.mapper) .putConfiguredProperty("atlasmapping", "some data") .build() ); ProjectGenerator generator = new ProjectGenerator(new ProjectGeneratorConfiguration(), manager, new MavenProperties()); IntegrationDeployment deployment = new IntegrationDeployment.Builder() .userId("user") .id("idId") .spec(integration) .build(); CamelKPublishHandler handler = new CamelKPublishHandler( new OpenShiftServiceNoOp(), null, null, generator, null, manager, Collections.emptyList(), new ControllersConfigurationProperties(), new ExposureHelper(new OpenShiftConfigurationProperties())); io.syndesis.server.controller.integration.camelk.crd.Integration i = handler.createIntegrationCR(deployment); assertThat(i.getSpec().getSources()).isNotEmpty(); assertThat(i.getSpec().getResources()).isNotEmpty(); assertThat(i.getSpec().getResources()).anyMatch(r -> "mapping-flow-0-step-1.json".equals(r.getDataSpec().getName())); }
@SuppressWarnings({"PMD.ExcessiveMethodLength"}) protected io.syndesis.server.controller.integration.camelk.crd.Integration createIntegrationCR(IntegrationDeployment integrationDeployment) { final Integration integration = integrationDeployment.getSpec(); String username = integrationDeployment.getUserId().get(); String integrationId = integrationDeployment.getIntegrationId().get(); String version = Integer.toString(integrationDeployment.getVersion()); String integrationDeploymentId = integrationDeployment.getId().get(); io.syndesis.server.controller.integration.camelk.crd.Integration result = new io.syndesis.server.controller.integration.camelk.crd.Integration(); result.getMetadata().setName(CamelKSupport.integrationName(integration.getName())); result.getMetadata().setLabels(new HashMap<>()); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.sanitize(integrationId)); result.getMetadata().getLabels().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getLabels().put(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username)); result.getMetadata().getLabels().put(OpenShiftService.COMPONENT_LABEL, "integration"); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_NAME_LABEL, Labels.sanitize(integration.getName())); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_TYPE_LABEL, OpenShiftService.INTEGRATION_TYPE_LABEL_VALUE); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_APP_LABEL, OpenShiftService.INTEGRATION_APP_LABEL_VALUE); result.getMetadata().setAnnotations(new HashMap<>()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_ID_LABEL, integrationId); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_ID_ANNOTATION, integrationDeploymentId); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_PORT_ANNOTATION, "9779"); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_SCRAPE_ANNOTATION, "true"); ImmutableIntegrationSpec.Builder integrationSpecBuilder = new IntegrationSpec.Builder(); Collection<String> customizers = configuration.getCamelk().getCustomizers(); integrationSpecBuilder.addResources(new ResourceSpec.Builder() .dataSpec(new DataSpec.Builder() .name("prometheus-config.yml") .contentRef("syndesis-prometheus-agent-config") .contentKey("prometheus-config.yml") .build()) .mountPath("/etc/camel/resources") .type("data") .build()); this.configuration.getCamelk().getEnvironment().forEach((k, v) -> { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder().type("env").value(k + "=" + v).build()); }); for (String customizerId: customizers) { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("customizer." + customizerId + ".enabled=true") .build()); } integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("env") .value("AB_JMX_EXPORTER_CONFIG=/etc/camel/resources/prometheus-config.yml") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("camel.context.streamCaching=true") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("secret") .value(CamelKSupport.integrationName(integration.getName())) .build()); try { addMappingRules(integration, integrationSpecBuilder); addIntegrationSource(integration, integrationSpecBuilder); } catch (Exception e) { throw new IllegalStateException(e); } result.setSpec(integrationSpecBuilder.build()); return result; }
CamelKPublishHandler extends BaseCamelKHandler implements StateChangeHandler { @SuppressWarnings({"PMD.ExcessiveMethodLength"}) protected io.syndesis.server.controller.integration.camelk.crd.Integration createIntegrationCR(IntegrationDeployment integrationDeployment) { final Integration integration = integrationDeployment.getSpec(); String username = integrationDeployment.getUserId().get(); String integrationId = integrationDeployment.getIntegrationId().get(); String version = Integer.toString(integrationDeployment.getVersion()); String integrationDeploymentId = integrationDeployment.getId().get(); io.syndesis.server.controller.integration.camelk.crd.Integration result = new io.syndesis.server.controller.integration.camelk.crd.Integration(); result.getMetadata().setName(CamelKSupport.integrationName(integration.getName())); result.getMetadata().setLabels(new HashMap<>()); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.sanitize(integrationId)); result.getMetadata().getLabels().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getLabels().put(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username)); result.getMetadata().getLabels().put(OpenShiftService.COMPONENT_LABEL, "integration"); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_NAME_LABEL, Labels.sanitize(integration.getName())); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_TYPE_LABEL, OpenShiftService.INTEGRATION_TYPE_LABEL_VALUE); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_APP_LABEL, OpenShiftService.INTEGRATION_APP_LABEL_VALUE); result.getMetadata().setAnnotations(new HashMap<>()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_ID_LABEL, integrationId); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_ID_ANNOTATION, integrationDeploymentId); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_PORT_ANNOTATION, "9779"); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_SCRAPE_ANNOTATION, "true"); ImmutableIntegrationSpec.Builder integrationSpecBuilder = new IntegrationSpec.Builder(); Collection<String> customizers = configuration.getCamelk().getCustomizers(); integrationSpecBuilder.addResources(new ResourceSpec.Builder() .dataSpec(new DataSpec.Builder() .name("prometheus-config.yml") .contentRef("syndesis-prometheus-agent-config") .contentKey("prometheus-config.yml") .build()) .mountPath("/etc/camel/resources") .type("data") .build()); this.configuration.getCamelk().getEnvironment().forEach((k, v) -> { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder().type("env").value(k + "=" + v).build()); }); for (String customizerId: customizers) { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("customizer." + customizerId + ".enabled=true") .build()); } integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("env") .value("AB_JMX_EXPORTER_CONFIG=/etc/camel/resources/prometheus-config.yml") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("camel.context.streamCaching=true") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("secret") .value(CamelKSupport.integrationName(integration.getName())) .build()); try { addMappingRules(integration, integrationSpecBuilder); addIntegrationSource(integration, integrationSpecBuilder); } catch (Exception e) { throw new IllegalStateException(e); } result.setSpec(integrationSpecBuilder.build()); return result; } }
CamelKPublishHandler extends BaseCamelKHandler implements StateChangeHandler { @SuppressWarnings({"PMD.ExcessiveMethodLength"}) protected io.syndesis.server.controller.integration.camelk.crd.Integration createIntegrationCR(IntegrationDeployment integrationDeployment) { final Integration integration = integrationDeployment.getSpec(); String username = integrationDeployment.getUserId().get(); String integrationId = integrationDeployment.getIntegrationId().get(); String version = Integer.toString(integrationDeployment.getVersion()); String integrationDeploymentId = integrationDeployment.getId().get(); io.syndesis.server.controller.integration.camelk.crd.Integration result = new io.syndesis.server.controller.integration.camelk.crd.Integration(); result.getMetadata().setName(CamelKSupport.integrationName(integration.getName())); result.getMetadata().setLabels(new HashMap<>()); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.sanitize(integrationId)); result.getMetadata().getLabels().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getLabels().put(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username)); result.getMetadata().getLabels().put(OpenShiftService.COMPONENT_LABEL, "integration"); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_NAME_LABEL, Labels.sanitize(integration.getName())); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_TYPE_LABEL, OpenShiftService.INTEGRATION_TYPE_LABEL_VALUE); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_APP_LABEL, OpenShiftService.INTEGRATION_APP_LABEL_VALUE); result.getMetadata().setAnnotations(new HashMap<>()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_ID_LABEL, integrationId); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_ID_ANNOTATION, integrationDeploymentId); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_PORT_ANNOTATION, "9779"); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_SCRAPE_ANNOTATION, "true"); ImmutableIntegrationSpec.Builder integrationSpecBuilder = new IntegrationSpec.Builder(); Collection<String> customizers = configuration.getCamelk().getCustomizers(); integrationSpecBuilder.addResources(new ResourceSpec.Builder() .dataSpec(new DataSpec.Builder() .name("prometheus-config.yml") .contentRef("syndesis-prometheus-agent-config") .contentKey("prometheus-config.yml") .build()) .mountPath("/etc/camel/resources") .type("data") .build()); this.configuration.getCamelk().getEnvironment().forEach((k, v) -> { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder().type("env").value(k + "=" + v).build()); }); for (String customizerId: customizers) { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("customizer." + customizerId + ".enabled=true") .build()); } integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("env") .value("AB_JMX_EXPORTER_CONFIG=/etc/camel/resources/prometheus-config.yml") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("camel.context.streamCaching=true") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("secret") .value(CamelKSupport.integrationName(integration.getName())) .build()); try { addMappingRules(integration, integrationSpecBuilder); addIntegrationSource(integration, integrationSpecBuilder); } catch (Exception e) { throw new IllegalStateException(e); } result.setSpec(integrationSpecBuilder.build()); return result; } CamelKPublishHandler(
        OpenShiftService openShiftService,
        IntegrationDao iDao,
        IntegrationDeploymentDao idDao,
        IntegrationProjectGenerator projectGenerator,
        IntegrationPublishValidator validator,
        IntegrationResourceManager resourceManager,
        List<CamelKIntegrationCustomizer> customizers,
        ControllersConfigurationProperties configuration,
        ExposureHelper exposureHelper); }
CamelKPublishHandler extends BaseCamelKHandler implements StateChangeHandler { @SuppressWarnings({"PMD.ExcessiveMethodLength"}) protected io.syndesis.server.controller.integration.camelk.crd.Integration createIntegrationCR(IntegrationDeployment integrationDeployment) { final Integration integration = integrationDeployment.getSpec(); String username = integrationDeployment.getUserId().get(); String integrationId = integrationDeployment.getIntegrationId().get(); String version = Integer.toString(integrationDeployment.getVersion()); String integrationDeploymentId = integrationDeployment.getId().get(); io.syndesis.server.controller.integration.camelk.crd.Integration result = new io.syndesis.server.controller.integration.camelk.crd.Integration(); result.getMetadata().setName(CamelKSupport.integrationName(integration.getName())); result.getMetadata().setLabels(new HashMap<>()); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.sanitize(integrationId)); result.getMetadata().getLabels().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getLabels().put(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username)); result.getMetadata().getLabels().put(OpenShiftService.COMPONENT_LABEL, "integration"); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_NAME_LABEL, Labels.sanitize(integration.getName())); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_TYPE_LABEL, OpenShiftService.INTEGRATION_TYPE_LABEL_VALUE); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_APP_LABEL, OpenShiftService.INTEGRATION_APP_LABEL_VALUE); result.getMetadata().setAnnotations(new HashMap<>()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_ID_LABEL, integrationId); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_ID_ANNOTATION, integrationDeploymentId); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_PORT_ANNOTATION, "9779"); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_SCRAPE_ANNOTATION, "true"); ImmutableIntegrationSpec.Builder integrationSpecBuilder = new IntegrationSpec.Builder(); Collection<String> customizers = configuration.getCamelk().getCustomizers(); integrationSpecBuilder.addResources(new ResourceSpec.Builder() .dataSpec(new DataSpec.Builder() .name("prometheus-config.yml") .contentRef("syndesis-prometheus-agent-config") .contentKey("prometheus-config.yml") .build()) .mountPath("/etc/camel/resources") .type("data") .build()); this.configuration.getCamelk().getEnvironment().forEach((k, v) -> { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder().type("env").value(k + "=" + v).build()); }); for (String customizerId: customizers) { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("customizer." + customizerId + ".enabled=true") .build()); } integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("env") .value("AB_JMX_EXPORTER_CONFIG=/etc/camel/resources/prometheus-config.yml") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("camel.context.streamCaching=true") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("secret") .value(CamelKSupport.integrationName(integration.getName())) .build()); try { addMappingRules(integration, integrationSpecBuilder); addIntegrationSource(integration, integrationSpecBuilder); } catch (Exception e) { throw new IllegalStateException(e); } result.setSpec(integrationSpecBuilder.build()); return result; } CamelKPublishHandler(
        OpenShiftService openShiftService,
        IntegrationDao iDao,
        IntegrationDeploymentDao idDao,
        IntegrationProjectGenerator projectGenerator,
        IntegrationPublishValidator validator,
        IntegrationResourceManager resourceManager,
        List<CamelKIntegrationCustomizer> customizers,
        ControllersConfigurationProperties configuration,
        ExposureHelper exposureHelper); @Override Set<IntegrationDeploymentState> getTriggerStates(); @Override @SuppressWarnings("PMD.NPathComplexity") StateUpdate execute(IntegrationDeployment integrationDeployment); }
CamelKPublishHandler extends BaseCamelKHandler implements StateChangeHandler { @SuppressWarnings({"PMD.ExcessiveMethodLength"}) protected io.syndesis.server.controller.integration.camelk.crd.Integration createIntegrationCR(IntegrationDeployment integrationDeployment) { final Integration integration = integrationDeployment.getSpec(); String username = integrationDeployment.getUserId().get(); String integrationId = integrationDeployment.getIntegrationId().get(); String version = Integer.toString(integrationDeployment.getVersion()); String integrationDeploymentId = integrationDeployment.getId().get(); io.syndesis.server.controller.integration.camelk.crd.Integration result = new io.syndesis.server.controller.integration.camelk.crd.Integration(); result.getMetadata().setName(CamelKSupport.integrationName(integration.getName())); result.getMetadata().setLabels(new HashMap<>()); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.sanitize(integrationId)); result.getMetadata().getLabels().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getLabels().put(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username)); result.getMetadata().getLabels().put(OpenShiftService.COMPONENT_LABEL, "integration"); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_NAME_LABEL, Labels.sanitize(integration.getName())); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_TYPE_LABEL, OpenShiftService.INTEGRATION_TYPE_LABEL_VALUE); result.getMetadata().getLabels().put(OpenShiftService.INTEGRATION_APP_LABEL, OpenShiftService.INTEGRATION_APP_LABEL_VALUE); result.getMetadata().setAnnotations(new HashMap<>()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName()); result.getMetadata().getAnnotations().put(OpenShiftService.INTEGRATION_ID_LABEL, integrationId); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version); result.getMetadata().getAnnotations().put(OpenShiftService.DEPLOYMENT_ID_ANNOTATION, integrationDeploymentId); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_PORT_ANNOTATION, "9779"); result.getMetadata().getAnnotations().put(OpenShiftService.PROMETHEUS_SCRAPE_ANNOTATION, "true"); ImmutableIntegrationSpec.Builder integrationSpecBuilder = new IntegrationSpec.Builder(); Collection<String> customizers = configuration.getCamelk().getCustomizers(); integrationSpecBuilder.addResources(new ResourceSpec.Builder() .dataSpec(new DataSpec.Builder() .name("prometheus-config.yml") .contentRef("syndesis-prometheus-agent-config") .contentKey("prometheus-config.yml") .build()) .mountPath("/etc/camel/resources") .type("data") .build()); this.configuration.getCamelk().getEnvironment().forEach((k, v) -> { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder().type("env").value(k + "=" + v).build()); }); for (String customizerId: customizers) { integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("customizer." + customizerId + ".enabled=true") .build()); } integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("env") .value("AB_JMX_EXPORTER_CONFIG=/etc/camel/resources/prometheus-config.yml") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("property") .value("camel.context.streamCaching=true") .build()); integrationSpecBuilder.addConfiguration(new ConfigurationSpec.Builder() .type("secret") .value(CamelKSupport.integrationName(integration.getName())) .build()); try { addMappingRules(integration, integrationSpecBuilder); addIntegrationSource(integration, integrationSpecBuilder); } catch (Exception e) { throw new IllegalStateException(e); } result.setSpec(integrationSpecBuilder.build()); return result; } CamelKPublishHandler(
        OpenShiftService openShiftService,
        IntegrationDao iDao,
        IntegrationDeploymentDao idDao,
        IntegrationProjectGenerator projectGenerator,
        IntegrationPublishValidator validator,
        IntegrationResourceManager resourceManager,
        List<CamelKIntegrationCustomizer> customizers,
        ControllersConfigurationProperties configuration,
        ExposureHelper exposureHelper); @Override Set<IntegrationDeploymentState> getTriggerStates(); @Override @SuppressWarnings("PMD.NPathComplexity") StateUpdate execute(IntegrationDeployment integrationDeployment);  }