diff --git a/LICENSE-THIRD-PARTY.txt b/LICENSE-THIRD-PARTY.txt index d3a0c18c..36512204 100644 --- a/LICENSE-THIRD-PARTY.txt +++ b/LICENSE-THIRD-PARTY.txt @@ -1,5 +1,5 @@ -Lists of 144 third-party dependencies. +Lists of 150 third-party dependencies. (Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Classic Module (ch.qos.logback:logback-classic:1.2.3 - http://logback.qos.ch/logback-classic) (Eclipse Public License - v 1.0) (GNU Lesser General Public License) Logback Core Module (ch.qos.logback:logback-core:1.2.3 - http://logback.qos.ch/logback-core) (Apache License, Version 2.0) ClassMate (com.fasterxml:classmate:1.5.1 - https://github.com/FasterXML/java-classmate) @@ -22,6 +22,7 @@ Lists of 144 third-party dependencies. (Apache License, Version 2.0) Apache Commons Collections (commons-collections:commons-collections:3.2.2 - http://commons.apache.org/collections/) (The Apache Software License, Version 2.0) Apache Commons Logging (commons-logging:commons-logging:1.2 - http://commons.apache.org/proper/commons-logging/) (The MIT License (MIT)) ClassGraph (io.github.classgraph:classgraph:4.8.69 - https://github.com/classgraph/classgraph) + (The Apache Software License, Version 2.0) micrometer-core (io.micrometer:micrometer-core:1.5.5 - https://github.com/micrometer-metrics/micrometer) (The Apache Software License, Version 2.0) Allure Attachments (io.qameta.allure:allure-attachments:2.13.6 - https://github.com/allure-framework/allure-java) (The Apache Software License, Version 2.0) Allure Java Commons (io.qameta.allure:allure-java-commons:2.13.6 - https://github.com/allure-framework/allure-java) (The Apache Software License, Version 2.0) Allure JUnit Platform Integration (io.qameta.allure:allure-junit-platform:2.13.6 - https://github.com/allure-framework/allure-java) @@ -80,6 +81,7 @@ Lists of 144 third-party dependencies. (BSD License 3) Hamcrest (org.hamcrest:hamcrest:2.2 - http://hamcrest.org/JavaHamcrest/) (BSD License 3) Hamcrest Core (org.hamcrest:hamcrest-core:2.2 - http://hamcrest.org/JavaHamcrest/) (BSD License 3) Hamcrest Library (org.hamcrest:hamcrest-library:2.2 - http://hamcrest.org/JavaHamcrest/) + (BSD-2-Clause) (Public Domain, per Creative Commons CC0) HdrHistogram (org.hdrhistogram:HdrHistogram:2.1.12 - http://hdrhistogram.github.io/HdrHistogram/) (Apache License 2.0) Hibernate Validator Engine (org.hibernate.validator:hibernate-validator:6.1.5.Final - http://hibernate.org/validator/hibernate-validator) (Apache License, version 2.0) JBoss Logging 3 (org.jboss.logging:jboss-logging:3.4.1.Final - http://www.jboss.org) (The Apache Software License, Version 2.0) JetBrains Java Annotations (org.jetbrains:annotations:19.0.0 - https://github.com/JetBrains/java-annotations) @@ -92,6 +94,7 @@ Lists of 144 third-party dependencies. (Eclipse Public License v2.0) JUnit Platform Commons (org.junit.platform:junit-platform-commons:1.6.2 - https://junit.org/junit5/) (Eclipse Public License v2.0) JUnit Platform Engine API (org.junit.platform:junit-platform-engine:1.6.2 - https://junit.org/junit5/) (Eclipse Public License v2.0) JUnit Vintage Engine (org.junit.vintage:junit-vintage-engine:5.6.2 - https://junit.org/junit5/) + (Public Domain, per Creative Commons CC0) LatencyUtils (org.latencyutils:LatencyUtils:2.0.3 - http://latencyutils.github.io/LatencyUtils/) (The MIT License) mockito-core (org.mockito:mockito-core:3.3.3 - https://github.com/mockito/mockito) (The MIT License) mockito-junit-jupiter (org.mockito:mockito-junit-jupiter:3.3.3 - https://github.com/mockito/mockito) (Apache 2) Objenesis (org.objenesis:objenesis:2.6 - http://objenesis.org) @@ -123,9 +126,12 @@ Lists of 144 third-party dependencies. (Apache License, Version 2.0) Spring Web (org.springframework:spring-web:5.2.9.RELEASE - https://github.com/spring-projects/spring-framework) (Apache License, Version 2.0) Spring Web MVC (org.springframework:spring-webmvc:5.2.9.RELEASE - https://github.com/spring-projects/spring-framework) (Apache License, Version 2.0) spring-boot (org.springframework.boot:spring-boot:2.3.4.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-actuator (org.springframework.boot:spring-boot-actuator:2.3.4.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-actuator-autoconfigure (org.springframework.boot:spring-boot-actuator-autoconfigure:2.3.4.RELEASE - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-autoconfigure (org.springframework.boot:spring-boot-autoconfigure:2.3.4.RELEASE - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-devtools (org.springframework.boot:spring-boot-devtools:2.3.4.RELEASE - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-starter (org.springframework.boot:spring-boot-starter:2.3.4.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-starter-actuator (org.springframework.boot:spring-boot-starter-actuator:2.3.4.RELEASE - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-starter-jdbc (org.springframework.boot:spring-boot-starter-jdbc:2.3.4.RELEASE - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-starter-jooq (org.springframework.boot:spring-boot-starter-jooq:2.3.4.RELEASE - https://spring.io/projects/spring-boot) (Apache License, Version 2.0) spring-boot-starter-json (org.springframework.boot:spring-boot-starter-json:2.3.4.RELEASE - https://spring.io/projects/spring-boot) diff --git a/appstore-metadata-service/pom.xml b/appstore-metadata-service/pom.xml index fc8c9bba..d088d33c 100644 --- a/appstore-metadata-service/pom.xml +++ b/appstore-metadata-service/pom.xml @@ -24,6 +24,8 @@ com.lgi.appstore.metadata.Application com.lgi.appstore.metadata 2.2.0 + current + latest @@ -32,6 +34,11 @@ spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-actuator + + io.swagger swagger-annotations @@ -162,6 +169,13 @@ 8080 8081 + + ${project.artifactId} + ${project.version} + ${scmCommit} + ${scmBranch} + ${maven.build.timestamp} + ${maven.build.timestamp} USE_CURRENT_TIMESTAMP diff --git a/appstore-metadata-service/src/main/java/com/lgi/appstore/metadata/info/AppInfoContributor.java b/appstore-metadata-service/src/main/java/com/lgi/appstore/metadata/info/AppInfoContributor.java new file mode 100644 index 00000000..4be92a57 --- /dev/null +++ b/appstore-metadata-service/src/main/java/com/lgi/appstore/metadata/info/AppInfoContributor.java @@ -0,0 +1,83 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 Liberty Global B.V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lgi.appstore.metadata.info; + +import org.springframework.boot.actuate.info.Info; +import org.springframework.boot.actuate.info.InfoContributor; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.TimeZone; + +@Component +public class AppInfoContributor implements InfoContributor { + + private static final String MISSING_DETAIL_VALUE = "not specified"; + private static final Map DETAILS = new HashMap<>(); + + private final Environment environment; + + public AppInfoContributor(Environment environment) { + this.environment = environment; + } + + @PostConstruct + public void init() { + addAppPropertyDetailFromEnvironment(AppProperty.APP_BRANCH); + addAppPropertyDetailFromEnvironment(AppProperty.APP_BUILD_TIME); + addAppPropertyDetailFromEnvironment(AppProperty.APP_NAME); + addAppPropertyDetailFromEnvironment(AppProperty.APP_REVISION); + addAppPropertyDetail(AppProperty.APP_START_TIME, getCurrentTime()); + addAppPropertyDetailFromEnvironment(AppProperty.APP_VERSION); + addAppPropertyDetailFromEnvironment(AppProperty.HOST_NAME); + addAppPropertyDetailFromEnvironment(AppProperty.STACK_NAME); + } + + @Override + public void contribute(Info.Builder builder) { + builder.withDetails(DETAILS); + } + + private void addAppPropertyDetailFromEnvironment(AppProperty appProperty) { + addAppPropertyDetail(appProperty, getAppPropertyValueFromEnvironment(appProperty)); + } + + private void addAppPropertyDetail(AppProperty appProperty, Object value) { + DETAILS.put(appProperty.toString(), value); + } + + private Object getAppPropertyValueFromEnvironment(AppProperty appProperty) { + return Optional.ofNullable(environment.getProperty(appProperty.toString())) + .orElse(MISSING_DETAIL_VALUE); + } + + public static String getCurrentTime() { + final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + return df.format(new Date()); + } +} diff --git a/appstore-metadata-service/src/main/java/com/lgi/appstore/metadata/info/AppProperty.java b/appstore-metadata-service/src/main/java/com/lgi/appstore/metadata/info/AppProperty.java new file mode 100644 index 00000000..4f9421fa --- /dev/null +++ b/appstore-metadata-service/src/main/java/com/lgi/appstore/metadata/info/AppProperty.java @@ -0,0 +1,31 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 Liberty Global B.V. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.lgi.appstore.metadata.info; + +public enum AppProperty { + APP_BRANCH, + APP_BUILD_TIME, + APP_NAME, + APP_REVISION, + APP_START_TIME, + APP_VERSION, + HOST_NAME, + STACK_NAME +} diff --git a/appstore-metadata-service/src/main/resources/config/application.properties b/appstore-metadata-service/src/main/resources/config/application.properties index 2cf5f845..2789c972 100644 --- a/appstore-metadata-service/src/main/resources/config/application.properties +++ b/appstore-metadata-service/src/main/resources/config/application.properties @@ -12,3 +12,8 @@ server.error.include-stacktrace=never server.error.whitelabel.enabled=false springdoc.swagger-ui.path=/swagger springdoc.swagger-ui.url=/appstore-metadata-service.yaml +management.endpoints.enabled-by-default=false +management.endpoints.jmx.exposure.exclude=info +management.endpoints.web.base-path= +management.endpoint.info.enabled=true +management.info.defaults.enabled=false diff --git a/pom.xml b/pom.xml index a0a24c81..db171734 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,7 @@ BSD-2-Clause|${line.separator} CC0|${line.separator} CC0 1.0 Universal License|${line.separator} + Public Domain, per Creative Commons CC0|${line.separator} COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0|${line.separator} CDDL/GPLv2+CE|${line.separator} Eclipse Public License 1.0|${line.separator}