From 470fefe3a6b4ff5a5d53a2da1a914a20271c8133 Mon Sep 17 00:00:00 2001 From: deiflaender Date: Wed, 2 Sep 2020 11:24:23 +0200 Subject: [PATCH] Added project structure --- CHANGELOG.md | 12 ++ bamboo-specs/pom.xml | 37 +++++ .../src/main/java/buildjob/PlanSpec.java | 143 ++++++++++++++++++ .../src/test/java/buildjob/PlanSpecTest.java | 20 +++ pom.xml | 19 +++ redaction-report-service-image-v1/pom.xml | 96 ++++++++++++ .../src/main/docker/Dockerfile | 9 ++ redaction-report-service-v1/pom.xml | 36 +++++ .../redaction-report-service-api-v1/pom.xml | 30 ++++ .../pom.xml | 76 ++++++++++ .../report/v1/server/Application.java | 31 ++++ .../settings/RedactionReportSettings.java | 11 ++ .../src/main/resources/application.yml | 19 +++ .../src/main/resources/banner.txt | 22 +++ .../src/main/resources/bootstrap.yml | 10 ++ .../RedactionReportIntegrationTest.java | 17 +++ 16 files changed, 588 insertions(+) create mode 100644 CHANGELOG.md create mode 100644 bamboo-specs/pom.xml create mode 100644 bamboo-specs/src/main/java/buildjob/PlanSpec.java create mode 100644 bamboo-specs/src/test/java/buildjob/PlanSpecTest.java create mode 100644 pom.xml create mode 100644 redaction-report-service-image-v1/pom.xml create mode 100644 redaction-report-service-image-v1/src/main/docker/Dockerfile create mode 100644 redaction-report-service-v1/pom.xml create mode 100644 redaction-report-service-v1/redaction-report-service-api-v1/pom.xml create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/pom.xml create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/Application.java create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/settings/RedactionReportSettings.java create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/banner.txt create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/bootstrap.yml create mode 100644 redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2c28d4d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# Changelog +All notable changes to this project will be documented in this file. + +## [Unreleased] + +### Fixed + +### Added + +### Changed + +### Removed \ No newline at end of file diff --git a/bamboo-specs/pom.xml b/bamboo-specs/pom.xml new file mode 100644 index 0000000..533e6db --- /dev/null +++ b/bamboo-specs/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + + + com.atlassian.bamboo + bamboo-specs-parent + 7.0.4 + + + + bamboo-specs + 1.0.0-SNAPSHOT + jar + + + + com.atlassian.bamboo + bamboo-specs-api + + + com.atlassian.bamboo + bamboo-specs + + + + + junit + junit + test + + + + + + + \ No newline at end of file diff --git a/bamboo-specs/src/main/java/buildjob/PlanSpec.java b/bamboo-specs/src/main/java/buildjob/PlanSpec.java new file mode 100644 index 0000000..02a2b00 --- /dev/null +++ b/bamboo-specs/src/main/java/buildjob/PlanSpec.java @@ -0,0 +1,143 @@ +package buildjob; + +import static com.atlassian.bamboo.specs.builders.task.TestParserTask.createJUnitParserTask; + +import com.atlassian.bamboo.specs.api.BambooSpec; +import com.atlassian.bamboo.specs.api.builders.BambooKey; +import com.atlassian.bamboo.specs.api.builders.docker.DockerConfiguration; +import com.atlassian.bamboo.specs.api.builders.permission.PermissionType; +import com.atlassian.bamboo.specs.api.builders.permission.Permissions; +import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions; +import com.atlassian.bamboo.specs.api.builders.plan.Job; +import com.atlassian.bamboo.specs.api.builders.plan.Plan; +import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier; +import com.atlassian.bamboo.specs.api.builders.plan.Stage; +import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup; +import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement; +import com.atlassian.bamboo.specs.api.builders.project.Project; +import com.atlassian.bamboo.specs.builders.task.CheckoutItem; +import com.atlassian.bamboo.specs.builders.task.InjectVariablesTask; +import com.atlassian.bamboo.specs.builders.task.ScriptTask; +import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask; +import com.atlassian.bamboo.specs.builders.task.VcsTagTask; +import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger; +import com.atlassian.bamboo.specs.model.task.InjectVariablesScope; +import com.atlassian.bamboo.specs.util.BambooServer; + +/** + * Plan configuration for Bamboo. + * Learn more on: https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs + */ +@BambooSpec +public class PlanSpec { + + private static final String SERVICE_NAME = "redaction-report-service"; + + private static final String SERVICE_KEY = SERVICE_NAME.toUpperCase().replaceAll("-", ""); + + /** + * Run main to publish plan on Bamboo + */ + public static void main(final String[] args) throws Exception { + //By default credentials are read from the '.credentials' file. + BambooServer bambooServer = new BambooServer("http://localhost:8085"); + + Plan plan = new PlanSpec().createPlan(); + bambooServer.publish(plan); + PlanPermissions planPermission = new PlanSpec().createPlanPermission(plan.getIdentifier()); + bambooServer.publish(planPermission); + } + + private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) { + Permissions permission = new Permissions() + .userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, PermissionType.CLONE, PermissionType.BUILD) + .groupPermissions("gin4", PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE, PermissionType.BUILD) + .loggedInUserPermissions(PermissionType.VIEW) + .anonymousUserPermissionView(); + return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission); + } + + private Project project() { + return new Project() + .name("RED") + .key(new BambooKey("RED")); + } + + public Plan createPlan() { + return new Plan( + project(), + SERVICE_NAME, new BambooKey(SERVICE_KEY)) + .description("Plan created from (enter repository url of your plan)") + .stages(new Stage("Default Stage") + .jobs(new Job("Default Job", + new BambooKey("JOB1")) + .tasks( + new ScriptTask() + .description("Clean") + .inlineBody("#!/bin/bash\n" + + "set -e\n" + + "rm -rf ./*"), + new VcsCheckoutTask() + .description("Checkout Default Repository") + .checkoutItems(new CheckoutItem().defaultRepository()), + new ScriptTask() + .description("Clean") + .inlineBody("#!/bin/bash\n" + + "set -e\n" + + "rm -rf ./*"), + new VcsCheckoutTask() + .description("Checkout Default Repository") + .checkoutItems(new CheckoutItem().defaultRepository()), + new ScriptTask() + .description("Build") + .inlineBody("#!/bin/bash\n" + + "set -e\n" + + "if [[ \"${bamboo.version_tag}\" = \"dev\" ]]\n" + + "then\n" + + " ${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn -f ${bamboo_build_working_directory}/" + SERVICE_NAME + "-v1/pom.xml --no-transfer-progress clean install -Djava.security.egd=file:/dev/./urandom\n" + + "else\n" + + " ${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn --no-transfer-progress -f ${bamboo_build_working_directory}/" + SERVICE_NAME + "-v1/pom.xml versions:set -DnewVersion=${bamboo.version_tag}\n" + + " ${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn --no-transfer-progress -f ${bamboo_build_working_directory}/" + SERVICE_NAME + "-image-v1/pom.xml versions:set -DnewVersion=${bamboo.version_tag}\n" + + " ${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn -f ${bamboo_build_working_directory}/" + SERVICE_NAME + "-v1/pom.xml --no-transfer-progress clean deploy -e -DdeployAtEnd=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true -DaltDeploymentRepository=iqser_release::default::https://nexus.iqser.com/repository/red-platform-releases\n" + + "fi\n" + + + "${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn --no-transfer-progress -f ${bamboo_build_working_directory}/" + SERVICE_NAME + "-image-v1/pom.xml package\n" + + "${bamboo_capability_system_builder_mvn3_Maven_3}/bin/mvn --no-transfer-progress -f ${bamboo_build_working_directory}/" + SERVICE_NAME + "-image-v1/pom.xml docker:push\n" + + + "if [[ \"${bamboo.version_tag}\" = \"dev\" ]]\n" + + "then\n" + + " echo \"gitTag=${bamboo.planRepository.1.branch}_${bamboo.buildNumber}\" > git.tag\n" + + "else\n" + + " echo \"gitTag=${bamboo.version_tag}\" > git.tag\n" + + "fi\n"), + createJUnitParserTask() + .description("Resultparser") + .resultDirectories("**/test-reports/*.xml, **/target/surefire-reports/*.xml, **/target/failsafe-reports/*.xml") + .enabled(true), + new InjectVariablesTask() + .description("Inject git Tag") + .path("git.tag") + .namespace("g") + .scope(InjectVariablesScope.LOCAL), + new VcsTagTask() + .description("${bamboo.g.gitTag}") + .tagName("${bamboo.g.gitTag}") + .defaultRepository()) + .dockerConfiguration( + new DockerConfiguration() + .image("nexus.iqser.com:5001/infra/maven:3.6.2-jdk-13-3.0.0") + .volume("/etc/maven/settings.xml", "/usr/share/maven/ref/settings.xml") + .volume("/var/run/docker.sock", "/var/run/docker.sock") + ) + ) + ) + .linkedRepositories("RED / " + SERVICE_NAME) + + .triggers(new BitbucketServerTrigger()) + .planBranchManagement(new PlanBranchManagement() + .createForVcsBranch() + .delete(new BranchCleanup() + .whenInactiveInRepositoryAfterDays(14)) + .notificationForCommitters()); + } +} diff --git a/bamboo-specs/src/test/java/buildjob/PlanSpecTest.java b/bamboo-specs/src/test/java/buildjob/PlanSpecTest.java new file mode 100644 index 0000000..ee5c237 --- /dev/null +++ b/bamboo-specs/src/test/java/buildjob/PlanSpecTest.java @@ -0,0 +1,20 @@ +package buildjob; + + +import org.junit.Test; + +import com.atlassian.bamboo.specs.api.builders.plan.Plan; +import com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException; +import com.atlassian.bamboo.specs.api.util.EntityPropertiesBuilders; + +public class PlanSpecTest { + + @Test + public void checkYourPlanOffline() throws PropertiesValidationException { + + Plan plan = new PlanSpec().createPlan(); + EntityPropertiesBuilders.build(plan); + + } + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6f56eee --- /dev/null +++ b/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + com.iqser.red.service + redaction-report-service + 1.0-SNAPSHOT + + pom + + + bamboo-specs + redaction-report-service-v1 + redaction-report-service-image-v1 + + + diff --git a/redaction-report-service-image-v1/pom.xml b/redaction-report-service-image-v1/pom.xml new file mode 100644 index 0000000..f495872 --- /dev/null +++ b/redaction-report-service-image-v1/pom.xml @@ -0,0 +1,96 @@ + + + + com.iqser.red + platform-docker-dependency + 1.0.1 + + 4.0.0 + + redaction-report-service-image-v1 + com.iqser.red.service + 1.0-SNAPSHOT + pom + + + redaction-report-service-server-v1 + ${service.server}.jar + false + ${docker.image.prefix}/${service.server} + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + org.apache.maven.plugins + maven-resources-plugin + + + org.codehaus.mojo + exec-maven-plugin + + + io.fabric8 + docker-maven-plugin + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + download-platform-jar + prepare-package + + copy + + + + + ${project.groupId} + ${service.server} + ${project.version} + jar + true + ${platform.jar} + + + ${docker.build.directory} + + + + + + io.fabric8 + docker-maven-plugin + + + + ${docker.image.name} + + ${docker.build.directory} + + ${platform.jar} + + + ${docker.image.version} + latest + + + + + + + + + + diff --git a/redaction-report-service-image-v1/src/main/docker/Dockerfile b/redaction-report-service-image-v1/src/main/docker/Dockerfile new file mode 100644 index 0000000..b48a13a --- /dev/null +++ b/redaction-report-service-image-v1/src/main/docker/Dockerfile @@ -0,0 +1,9 @@ +FROM gin5/platform-base:5.2.0 + +ARG PLATFORM_JAR + +ENV PLATFORM_JAR ${PLATFORM_JAR} + +ENV USES_ELASTICSEARCH false + +COPY ["${PLATFORM_JAR}", "/"] \ No newline at end of file diff --git a/redaction-report-service-v1/pom.xml b/redaction-report-service-v1/pom.xml new file mode 100644 index 0000000..9183672 --- /dev/null +++ b/redaction-report-service-v1/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + + + com.iqser.red + platform-dependency + 1.0.2 + + + com.iqser.red.service + redaction-report-service-v1 + 1.0-SNAPSHOT + + pom + + + redaction-report-service-api-v1 + redaction-report-service-server-v1 + + + + + + com.iqser.red + platform-commons-dependency + 1.0.0 + import + pom + + + + + diff --git a/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml b/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml new file mode 100644 index 0000000..6add97d --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + + com.iqser.red.service + redaction-report-service-v1 + 1.0-SNAPSHOT + + + redaction-report-service-api-v1 + 1.0-SNAPSHOT + + + + + + io.github.openfeign + feign-core + true + + + + org.springframework + spring-web + + + diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml b/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml new file mode 100644 index 0000000..a168bda --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + + + com.iqser.red.service + redaction-report-service-v1 + 1.0-SNAPSHOT + + + redaction-report-service-server-v1 + 1.0-SNAPSHOT + + + + com.iqser.red.service + redaction-report-service-api-v1 + ${project.version} + + + com.iqser.gin4.commons + spring-commons + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + com.iqser.gin4.commons + test-commons + test + + + + + + + pl.project13.maven + git-commit-id-plugin + + + + revision + + + true + + true + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + true + + + + + + + diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/Application.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/Application.java new file mode 100644 index 0000000..abff3c2 --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/Application.java @@ -0,0 +1,31 @@ +package com.iqser.red.service.redaction.report.v1.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Import; +import org.springframework.scheduling.annotation.EnableAsync; + +import com.iqser.gin4.commons.spring.DefaultWebMvcConfiguration; +import com.iqser.red.service.redaction.report.v1.server.settings.RedactionReportSettings; + +@EnableAsync +@EnableConfigurationProperties(RedactionReportSettings.class) +@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class}) +@Import(DefaultWebMvcConfiguration.class) +@EnableFeignClients // TODO specify basePackageClasses +public class Application { + + /** + * Entry point to the service application. + * + * @param args Any command line parameter given upon startup. + */ + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} \ No newline at end of file diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/settings/RedactionReportSettings.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/settings/RedactionReportSettings.java new file mode 100644 index 0000000..08bc982 --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/settings/RedactionReportSettings.java @@ -0,0 +1,11 @@ +package com.iqser.red.service.redaction.report.v1.server.settings; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import lombok.Data; + +@Data +@ConfigurationProperties("service-template") +public class RedactionReportSettings { + private int numberOfParallelProcessed = 5; +} \ No newline at end of file diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml new file mode 100644 index 0000000..c5a0648 --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/application.yml @@ -0,0 +1,19 @@ +info: + description: Redaction Report Server v1 + +server: + port: 8080 + +spring: + profiles: + active: kubernetes + +platform.multi-tenancy: + enabled: false + +management: + endpoint: + metrics.enabled: ${monitoring.enabled:false} + prometheus.enabled: ${monitoring.enabled:false} + endpoints.web.exposure.include: prometheus, health + metrics.export.prometheus.enabled: ${monitoring.enabled:false} \ No newline at end of file diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/banner.txt b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/banner.txt new file mode 100644 index 0000000..3409dad --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/banner.txt @@ -0,0 +1,22 @@ +------------------------------------------------------------------ +| | +| Redaction Report Server v1 | +| | + ________________________________________________________________ +| | +| ___ ________ ________ _________ _________ | +| | | / \ / || || \ | +| | | / ____ \ / _____|| _____||______ \ | +| | | / / \ \| / | | \ | | +| | || | | || \____ | |____ ______/ | | +| | || | | || \ | | | | | +| | || | ___| | \_____ || ____| | _ _/ | +| | || | \ \ | \ || | | | \ \ | +| | | \ \_ \ / ______/ || |_____ | | \ \ | +| | | \ \ \ \ | /| || | \ \ | +| |___| \____\ \___\|_________/ |_________||___| \___\ | +| | +| | +| F r o m d a t a t o i n f o r m a t i o n | +| | +|________________________________________________________________| \ No newline at end of file diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/bootstrap.yml b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..156ac85 --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/resources/bootstrap.yml @@ -0,0 +1,10 @@ +spring: + application: + name: redaction-report-service-v1 + +management: + endpoints: + web: + base-path: / + path-mapping: + health: "health" \ No newline at end of file diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java new file mode 100644 index 0000000..b02a17c --- /dev/null +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java @@ -0,0 +1,17 @@ +package com.iqser.red.service.redaction.report.v1.server; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +public class RedactionReportIntegrationTest { + + @Test + public void testServiceTemplate() { + assertThat(true).isTrue(); + } + +} \ No newline at end of file