Skip to content

Commit

Permalink
Merge pull request #15 from blackducksoftware/broker-rearch
Browse files Browse the repository at this point in the history
Rearchitecture of the Cloud Foundry integration
  • Loading branch information
sig-fisherj committed Feb 8, 2019
2 parents 691a593 + 992f3ca commit 8ff0409
Show file tree
Hide file tree
Showing 148 changed files with 6,160 additions and 1,826 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
/.project
/.DS_Store
.gradle
.project
.project
.settings/org.eclipse.buildship.core.prefs
14 changes: 5 additions & 9 deletions .travis.yml
@@ -1,6 +1,4 @@
language: python
python:
- '2.7'
language: java
jdk:
- 'oraclejdk8'

Expand All @@ -11,14 +9,12 @@ addons:

install:
- './gradlew clean build -x test'

before_script:
- 'pip install proboscis'


script:
- './gradlew :black-duck-broker:test'
- 'cd black-duck-decorator/test && python run_tests.py && cd ../..'
- './gradlew :black-duck-perceiver:test'
- './gradlew :black-duck-img-facade:test'

after_success:
- './gradlew :black-duck-broker:test :black-duck-broker:jacocoTestReport :black-duck-broker:coveralls'
- './gradlew :{black-duck-broker,black-duck-perceiver,black-duck-img-facade}:{test,jacocoTestReport,coveralls}'
- bash <(curl -s https://copilot.blackducksoftware.com/ci/travis/scripts/upload)
41 changes: 28 additions & 13 deletions black-duck-broker/build.gradle
@@ -1,13 +1,10 @@
plugins {
id 'java'
id 'application'
id 'eclipse-wtp'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.1'
}

apply plugin: 'org.springframework.boot'

sourceCompatibility = 1.8
mainClassName = 'com.blackducksoftware.integration.cloudfoundry.BDServiceBrokerApplication'

Expand All @@ -16,16 +13,23 @@ repositories {
}

dependencies {
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.8.RELEASE') {
exclude group: 'org.springframework.security.oauth', module: 'spring-security-oauth2'
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
}
compile('com.fasterxml.jackson.core:jackson-databind:2.8.11.1')
compile('com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.8.6')
compile('org.yaml:snakeyaml:1.18')
compile('org.springframework.security.oauth:spring-security-oauth2:2.3.4.RELEASE') // Update version based on Co-Pilot report
compile('org.bouncycastle:bcprov-jdk15on:1.60') // Update version based on Co-Pilot report
compile('org.springframework.boot:spring-boot-configuration-processor')
compile('org.apache.httpcomponents:httpclient:4.5.5')
compile('com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8')
compile('com.fasterxml.jackson.module:jackson-modules-java8:2.9.8')
compile('com.google.code.findbugs:jsr305:3.0.2')
compile('com.blackducksoftware.integration:phone-home-api:5.+')
compile('org.cloudfoundry:cloudfoundry-client-reactor:3.13.0.RELEASE') {
exclude group: 'org.apache.commons', module: 'commons-compress'
}
compile('org.apache.commons:commons-compress:1.18') // Update version based on Co-Pilot report
testCompile('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'junit', module: 'junit'
}
Expand All @@ -38,10 +42,21 @@ test{
}
}

import org.apache.tools.ant.filters.ReplaceTokens
processResources {
filesMatching("**/application.yml") {
expand(project.properties)
}
with copySpec {
from 'src/main/resources'
include '**/application*.yml'
include '**/application*.yaml'
include '**/application*.properties'
project.properties.findAll().each {
prop ->
if (prop.key != 'properties' && prop.value != null) {
filter(ReplaceTokens, tokens: [ (prop.key): prop.value])
filter(ReplaceTokens, tokens: [ ('project.' + prop.key): prop.value])
}
}
}
}

jacocoTestReport {
Expand Down
Expand Up @@ -23,11 +23,19 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;

@SpringBootApplication
@EnableAsync
@EnableScheduling
@EnableOAuth2Client
public class BDServiceBrokerApplication {

public static void main(String[] args) {
SpringApplication.run(BDServiceBrokerApplication.class, args);
@SuppressWarnings("unused")
ConfigurableApplicationContext ctx = SpringApplication.run(BDServiceBrokerApplication.class, args);
}
}
Expand Up @@ -21,15 +21,25 @@
*/
package com.blackducksoftware.integration.cloudfoundry;

import java.io.IOException;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import com.blackducksoftware.integration.cloudfoundry.servicebroker.app.api.HubCredentials;
import com.blackducksoftware.integration.cloudfoundry.servicebroker.app.api.PhoneHomeParameters;
import com.blackducksoftware.integration.cloudfoundry.servicebroker.app.iface.ICloudControllerEventMonitorService;
import com.blackducksoftware.integration.cloudfoundry.servicebroker.app.impl.BindingInstanceService;
import com.blackducksoftware.integration.cloudfoundry.servicebroker.app.impl.ServiceInstanceService;
import com.blackducksoftware.integration.cloudfoundry.servicebroker.security.AuthenticationEntryPoint;
import com.blackducksoftware.integration.cloudfoundry.v2.model.Catalog;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

/**
* @author jfisher
Expand All @@ -39,13 +49,11 @@
public class ServiceBrokerConfiguration {

@Bean
public HubCredentials hubCredentials(
@Value(value = "#{ @environment['HUB_SCHEME'] ?: '0' }") final String scheme,
@Value(value = "#{ @environment['HUB_HOST'] ?: '0' }") final String host,
@Value(value = "#{ @environment['HUB_PORT'] ?: -1 }") final int port,
@Value(value = "#{ @environment['HUB_LOGIN'] ?: '{}' }") final String loginInfo,
@Value(value = "#{ @environment['HUB_INSECURE'] ?: false }") final boolean insecure) {
return new HubCredentials(scheme, host, port, loginInfo, insecure);
public Catalog serviceBrokerCatalog() throws JsonParseException, JsonMappingException, IOException {
ObjectMapper om = new ObjectMapper(new YAMLFactory());
Catalog catalog = om.readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream("service.yml"),
Catalog.class);
return catalog;
}

@Bean
Expand All @@ -54,9 +62,10 @@ public ServiceInstanceService serviceInstanceService() {
}

@Bean
public BindingInstanceService bindingInstanceService(ServiceInstanceService serviceInstanceService, HubCredentials hubCredentials, String pluginVersion,
PhoneHomeParameters phoneHomeParms) {
return new BindingInstanceService(serviceInstanceService, hubCredentials, pluginVersion, phoneHomeParms);
public BindingInstanceService bindingInstanceService(ServiceInstanceService serviceInstanceService,
@Value("${plugin.version}") String pluginVersion,
ICloudControllerEventMonitorService ccEventMonitorHandler) {
return new BindingInstanceService(serviceInstanceService, pluginVersion, ccEventMonitorHandler);
}

@Bean
Expand All @@ -65,14 +74,19 @@ public AuthenticationEntryPoint authEntryPoint(@Value(value = "${application.rea
}

@Bean
public String getPluginVersion(@Value(value = "${plugin.version}") final String pluginVersion) {
return pluginVersion;
protected CloseableHttpClient httpClient() {
return HttpClients.createDefault();
}

@Bean
protected HttpComponentsClientHttpRequestFactory clientHttpRequestFactory() {
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
clientHttpRequestFactory.setHttpClient(httpClient());
return clientHttpRequestFactory;
}

@Bean
public PhoneHomeParameters phoneHomeParameters(
@Value(value = "#{ @environment['INTEGRATION_SOURCE'] ?: '0' }") final String source,
@Value(value = "#{ @environment['INTEGRATION_VENDOR'] ?: '0' }") final String vendor) {
return new PhoneHomeParameters(source, vendor);
public RestTemplate perceiverRestTemplate() {
return new RestTemplate(clientHttpRequestFactory());
}
}
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2018 Black Duck Software Inc.
* http://www.blackducksoftware.com/
* All rights reserved.
*
* This software is the confidential and proprietary information of
* Black Duck Software ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Black Duck Software.
*/
package com.blackducksoftware.integration.cloudfoundry.servicebroker.app.api;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author fisherj
*
*/
public final class BackendBindingProvisionRequest {
private final String bindingId;

private final String resourceId;

private final BindResource bindResource;

private final HubProjectParameters hubProjectParams;

@JsonCreator
public BackendBindingProvisionRequest(@JsonProperty("bindingId") String bindingId,
@JsonProperty("resourceId") String resourceId,
@JsonProperty("bindResource") BindResource bindResource,
@JsonProperty("hubProjectParameters") HubProjectParameters hubProjectParams) {
this.bindingId = bindingId;
this.resourceId = resourceId;
this.bindResource = bindResource;
this.hubProjectParams = hubProjectParams;
}

@JsonProperty("bindingId")
public final String getBindingId() {
return bindingId;
}

@JsonProperty("resourceId")
public final String getResourceId() {
return resourceId;
}

@JsonProperty("bindResource")
public final BindResource getBindResource() {
return bindResource;
}

@JsonProperty("hubProjectParameters")
public final HubProjectParameters getHubProjectParams() {
return hubProjectParams;
}
}
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2018 Black Duck Software Inc.
* http://www.blackducksoftware.com/
* All rights reserved.
*
* This software is the confidential and proprietary information of
* Black Duck Software ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Black Duck Software.
*/
package com.blackducksoftware.integration.cloudfoundry.servicebroker.app.api;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* @author fisherj
*
*/
public final class BackendServiceInstanceProvisionRequest {
private final String serviceInstanceId;

@JsonCreator
public BackendServiceInstanceProvisionRequest(@JsonProperty("serviceInstanceId") String serviceInstanceId) {
this.serviceInstanceId = serviceInstanceId;
}

@JsonProperty("serviceInstanceId")
public final String getServiceInstanceId() {
return serviceInstanceId;
}
}

0 comments on commit 8ff0409

Please sign in to comment.