diff --git a/.idea/runConfigurations/All_Tests__2_5_.xml b/.idea/runConfigurations/All_Tests__2_5_.xml index e2694fee68..679ca51e5e 100644 --- a/.idea/runConfigurations/All_Tests__2_5_.xml +++ b/.idea/runConfigurations/All_Tests__2_5_.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/.idea/runConfigurations/All_Tests__2_7_.xml b/.idea/runConfigurations/All_Tests__2_7_.xml index 4f9031d53b..fcde938296 100644 --- a/.idea/runConfigurations/All_Tests__2_7_.xml +++ b/.idea/runConfigurations/All_Tests__2_7_.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/.idea/runConfigurations/All_Tests__3_0_.xml b/.idea/runConfigurations/All_Tests__3_0_.xml index 6dd0b62d5b..e0118a93ec 100644 --- a/.idea/runConfigurations/All_Tests__3_0_.xml +++ b/.idea/runConfigurations/All_Tests__3_0_.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/.idea/runConfigurations/Without_Integration_Tests__2_5_.xml b/.idea/runConfigurations/Without_Integration_Tests__2_5_.xml index bd9dbbf1f5..43ee491dd2 100644 --- a/.idea/runConfigurations/Without_Integration_Tests__2_5_.xml +++ b/.idea/runConfigurations/Without_Integration_Tests__2_5_.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/.idea/runConfigurations/Without_Integration_Tests__2_7_.xml b/.idea/runConfigurations/Without_Integration_Tests__2_7_.xml index 6432e7e234..a95a86acf7 100644 --- a/.idea/runConfigurations/Without_Integration_Tests__2_7_.xml +++ b/.idea/runConfigurations/Without_Integration_Tests__2_7_.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/.idea/runConfigurations/Without_Integration_Tests__3_0_.xml b/.idea/runConfigurations/Without_Integration_Tests__3_0_.xml index 33a62d88ac..221ce17870 100644 --- a/.idea/runConfigurations/Without_Integration_Tests__3_0_.xml +++ b/.idea/runConfigurations/Without_Integration_Tests__3_0_.xml @@ -2,7 +2,7 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/README.md b/README.md index 50167fbb99..8f527237c1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cloud Foundry Java Buildpack -The `java-buildpack` is a [Cloud Foundry][] buildpack for running JVM-based applications. It is designed to run many JVM-based applications ([Grails][], [Groovy][], Java Main, [Play Framework][], [Spring Boot][], and Servlet) with no additional configuration, but supports configuration of the standard components, and extension to add custom components. +The `java-buildpack` is a [Cloud Foundry][] buildpack for running JVM-based applications. It is designed to run many JVM-based applications ([Grails][], [Groovy][], Java Main, [Play Framework][], [Spring Boot][], and Servlet) with no additional configuration, but supports configuration of the standard components, and extension to add custom components. ## Usage To use this buildpack specify the URI of the repository when pushing an application to Cloud Foundry: @@ -21,38 +21,70 @@ The following are _very_ simple examples for deploying the artifact types that w * [Spring Boot CLI](docs/example-spring_boot_cli.md) ## Configuration and Extension -The buildpack default configuration can be overridden with an environment variable matching the configuration file you wish to override minus the `.yml` extension and with a prefix of `JBP_CONFIG`. It is not possible to add new configuration properties and properties with `nil` or empty values will be ignored by the buildpack (in this case you will have to extend the buildpack, see below). The value of the variable should be valid inline yaml, referred to as "flow style" in the yaml spec ([Wikipedia][] has a good description of this yaml syntax). For example, to change the default version of Java to 11 and adjust the memory heuristics apply this environment variable to the application. + +The buildpack default configuration can be overridden with an environment variable matching the configuration file you wish to override minus the `.yml` extension. It is not possible to add new configuration properties and properties with `nil` or empty values will be ignored by the buildpack (in this case you will have to extend the buildpack, see below). The value of the variable should be valid inline yaml, referred to as "flow style" in the yaml spec ([Wikipedia][] has a good description of this yaml syntax). + +There are two levels of overrides: operator and application developer. + + - If you are an operator that wishes to override configuration across a foundation, you may do this by setting environment variable group entries that begin with a prefix of `JBP_DEFAULT`. + - If you are an application developer that wishes to override configuration for an individual application, you may do this by setting environment variables that begin with a prefix of `JBP_CONFIG`. + +Here are some examples: + +### Operator + +1. To change the default version of Java to 11 across all applications on a foundation. + +```bash +$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_OPEN_JDK_JRE":"{jre: {version: 11.+ }}"}' +``` + +2. To change the default repository root across all applications on a foundation. Be careful to ensure that your JSON is properly escaped. + +```bash +$ cf set-staging-environment-variable-group '{"JBP_CONFIG_REPOSITORY": "{default_repository_root: \"http://repo.example.io\" }"}' +``` + +3. To change the default JVM vendor across all applications on a foundation. Be careful to ensure that your JSON is properly escaped. + +```bash +$ cf set-staging-environment-variable-group '{"JBP_CONFIG_COMPONENTS": "{jres: [\"JavaBuildpack::Jre::ZuluJRE\"]}"}' +``` + +### Application Developer + +1. To change the default version of Java to 11 and adjust the memory heuristics then apply this environment variable to the application. ```bash $ cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{ jre: { version: 11.+ }, memory_calculator: { stack_threads: 25 } }' ``` -If the key or value contains a special character such as `:` it should be escaped with double quotes. For example, to change the default repository path for the buildpack. +2. If the key or value contains a special character such as `:` it should be escaped with double quotes. For example, to change the default repository path for the buildpack. ```bash $ cf set-env my-application JBP_CONFIG_REPOSITORY '{ default_repository_root: "http://repo.example.io" }' ``` -If the key or value contains an environment variable that you want to bind at runtime you need to escape it from your shell. For example, to add command line arguments containing an environment variable to a [Java Main](docs/container-java_main.md) application. +3. If the key or value contains an environment variable that you want to bind at runtime you need to escape it from your shell. For example, to add command line arguments containing an environment variable to a [Java Main](docs/container-java_main.md) application. ```bash $ cf set-env my-application JBP_CONFIG_JAVA_MAIN '{ arguments: "--server.port=9090 --foo=bar" }' ``` -An example of configuration is to specify a `javaagent` that is packaged within an application. +4. An example of configuration is to specify a `javaagent` that is packaged within an application. ```bash $ cf set-env my-application JAVA_OPTS '-javaagent:app/META-INF/myagent.jar -Dmyagent.config_file=app/META-INF/my_agent.conf' ``` -Environment variable can also be specified in the applications `manifest` file. For example, to specify an environment variable in an applications manifest file that disables Auto-reconfiguration. +5. Environment variable can also be specified in the applications `manifest` file. For example, to specify an environment variable in an applications manifest file that disables Auto-reconfiguration. ```bash env: JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{ enabled: false }' ``` -This final example shows how to change the version of Tomcat that is used by the buildpack with an environment variable specified in the applications manifest file. +6. This final example shows how to change the version of Tomcat that is used by the buildpack with an environment variable specified in the applications manifest file. ```bash env: @@ -63,7 +95,7 @@ See the [Environment Variables][] documentation for more information. To learn how to configure various properties of the buildpack, follow the "Configuration" links below. -The buildpack supports extension through the use of Git repository forking. The easiest way to accomplish this is to use [GitHub's forking functionality][] to create a copy of this repository. Make the required extension changes in the copy of the repository. Then specify the URL of the new repository when pushing Cloud Foundry applications. If the modifications are generally applicable to the Cloud Foundry community, please submit a [pull request][] with the changes. More information on extending the buildpack is available [here](docs/extending.md). +The buildpack supports extension through the use of Git repository forking. The easiest way to accomplish this is to use [GitHub's forking functionality][] to create a copy of this repository. Make the required extension changes in the copy of the repository. Then specify the URL of the new repository when pushing Cloud Foundry applications. If the modifications are generally applicable to the Cloud Foundry community, please submit a [pull request][] with the changes. More information on extending the buildpack is available [here](docs/extending.md). ## Additional Documentation * [Design](docs/design.md) @@ -141,12 +173,12 @@ The buildpack supports extension through the use of Git repository forking. The * [jvmkill](https://github.com/cloudfoundry/jvmkill) ## Building Packages -The buildpack can be packaged up so that it can be uploaded to Cloud Foundry using the `cf create-buildpack` and `cf update-buildpack` commands. In order to create these packages, the rake `package` task is used. +The buildpack can be packaged up so that it can be uploaded to Cloud Foundry using the `cf create-buildpack` and `cf update-buildpack` commands. In order to create these packages, the rake `package` task is used. Note that this process is not currently supported on Windows. It is possible it will work, but it is not tested, and no additional functionality has been added to make it work. ### Online Package -The online package is a version of the buildpack that is as minimal as possible and is configured to connect to the network for all dependencies. This package is about 50K in size. To create the online package, run: +The online package is a version of the buildpack that is as minimal as possible and is configured to connect to the network for all dependencies. This package is about 250K in size. To create the online package, run: ```bash $ bundle install @@ -156,7 +188,7 @@ Creating build/java-buildpack-cfd6b17.zip ``` ### Offline Package -The offline package is a version of the buildpack designed to run without access to a network. It packages the latest version of each dependency (as configured in the [`config/` directory][]) and [disables `remote_downloads`][]. This package is about 180M in size. To create the offline package, use the `OFFLINE=true` argument: +The offline package is a version of the buildpack designed to run without access to a network. It packages the latest version of each dependency (as configured in the [`config/` directory][]) and [disables `remote_downloads`][]. To create the offline package, use the `OFFLINE=true` argument: To pin the version of dependencies used by the buildpack to the ones currently resolvable use the `PINNED=true` argument. This will update the [`config/` directory][] to contain exact version of each dependency instead of version ranges. ```bash @@ -166,7 +198,11 @@ $ bundle exec rake clean package OFFLINE=true PINNED=true Creating build/java-buildpack-offline-cfd6b17.zip ``` -Only packages referenced in the [`config/components.yml` file](config/components.yml) will be cached. Additional packages may be added using the `ADD_TO_CACHE` argument. The value of `ADD_TO_CACHE` should be set to the name of a `.yml` file in the [`config/` directory][] with the `.yml` file extension omitted (e.g. `sap_machine_jre`). Multiple file names may be separated by commas. This is useful to add additional JREs. These additional components will not be enabled by default and must be explicitly enabled in the application with the `JBP_CONFIG_COMPONENTS` environment variable. +If you would rather specify the exact version to which the buildpack should bundle, you may manually edit the [`config/` file](`config/`) for the component and indicate the specific version to use. For most components, there is a single `version` property which defaults to a pattern to match the latest version. By setting the `version` property to a fixed version, the buildpack will install that exact version when you run the package command. For JRE config files, like [`config/open_jdk_jre.yml`](config/open_jdk_jre.yml), you need to set the `version_lines` array to include the specific version you'd like to install. By default, the `version_lines` array is going to have a pattern entry for each major version line that matches to the latest patch version. You can override the items in the `version_lines` array to set a specific versions to use when packaging the buildpack. For a JRE, the `jre.version` property is used to set the default version line and must match one of the entries in the `version_lines` property. + +This package size will vary depending on what dependencies are included. You can reduce the size by removing unused components, because only packages referenced in the [`config/components.yml` file](config/components.yml) will be cached. In addition, you can remove entries from the `version_lines` array in JRE configuration files, this removes that JRE version line, to further reduce the file size. + +Additional packages may be added using the `ADD_TO_CACHE` argument. The value of `ADD_TO_CACHE` should be set to the name of a `.yml` file in the [`config/` directory][] with the `.yml` file extension omitted (e.g. `sap_machine_jre`). Multiple file names may be separated by commas. This is useful to add additional JREs. These additional components will not be enabled by default and must be explicitly enabled in the application with the `JBP_CONFIG_COMPONENTS` environment variable. ```bash $ bundle install @@ -179,7 +215,7 @@ Creating build/java-buildpack-offline-cfd6b17.zip ``` ### Package Versioning -Keeping track of different versions of the buildpack can be difficult. To help with this, the rake `package` task puts a version discriminator in the name of the created package file. The default value for this discriminator is the current Git hash (e.g. `cfd6b17`). To change the version when creating a package, use the `VERSION=` argument: +Keeping track of different versions of the buildpack can be difficult. To help with this, the rake `package` task puts a version discriminator in the name of the created package file. The default value for this discriminator is the current Git hash (e.g. `cfd6b17`). To change the version when creating a package, use the `VERSION=` argument: ```bash $ bundle install @@ -190,9 +226,13 @@ Creating build/java-buildpack-2.1.zip ### Packaging Caveats -1. When pinning versions, only the default JRE version is pinned. There is [special handling to package additional versions of a JRE](https://github.com/cloudfoundry/java-buildpack/blob/main/rakelib/dependency_cache_task.rb#L128-L144) and the way this works, it will pick the latest version at the time you package not at the time of the version's release. -2. The `index.yml` file for a dependencie is packaged in the buildpack cache when building offline buildpacks. The `index.yml` file isn't versioned with the release, so if you package an offline buildpack for an older release, it will pull the current `index.yml`, not the one from the time of the release. This can result in errors if a user tells the buildpack to install the latest version of a default dependency, because the latest version is calculated from the `index.yml` file which has more recent versions than what are packaged in the offline buildpack. Because of #1, this only impacts the default JRE. Non-default JREs always package the most recent version, which is also the most recent version in `index.yml` at the time you package the offline buildpack. -3. Because of #1 and #2, it is not present to accurately reproduce packages of the buildpack, after releases have been cut. If building pinning or offline buildpacks, it is suggested to build them as soon as possible after a release is cut and save the produced artifact. +1. Prior to version 4.51 when pinning versions, only the default JRE version is pinned. There is [special handling to package additional versions of a JRE](https://github.com/cloudfoundry/java-buildpack/blob/main/rakelib/dependency_cache_task.rb#L128-L144) and the way this works, it will pick the latest version at the time you package not at the time of the version's release. Starting with version 4.51, the version number for all JRE version lines is tracked in the `config/` file. + +2. The `index.yml` file for a dependency is packaged in the buildpack cache when building offline buildpacks. The `index.yml` file isn't versioned with the release, so if you package an offline buildpack later after the release was tagged, it will pull the current `index.yml`, not the one from the time of the release. This can result in errors at build time if a user tells the buildpack to install the latest version of a dependency because the latest version is calculated from the `index.yml` file which has more recent versions than what are packaged in the offline buildpack. For example, if the user says give me Java `11._+` and the buildpack is pinned to Java `11.0.13_8` but at the time you packaged the buildpack the latest version in `index.yml` is `11.0.15_10` then the user will get an error. The buildpack will want to install `11.0.15_10` but it won't be present because `11.0.13_8` is all that's in the buildpack. + + Because of #1 for versions prior to 4.51, this only impacts the default JRE. Non-default JREs always package the most recent version, which is also the most recent version in `index.yml` at the time you package the offline buildpack. For 4.51 and up, this can impact all versions. + +4. Because of #1 and #2, it is not possible to accurately reproduce packages of the buildpack, after releases have been cut. If building pinned or offline buildpacks, it is suggested to build them as soon as possible after a release is cut and save the produced artifact. Alternatively, you would need to maintain your own buildpack dependency repository and keep snapshots of the buildpack dependency repository for each buildpack release you'd like to be able to rebuild. See [#892](https://github.com/cloudfoundry/java-buildpack/issues/892#issuecomment-880212806) for additional details. diff --git a/config/graal_vm_jre.yml b/config/graal_vm_jre.yml index b36d34f9b8..94419a9183 100644 --- a/config/graal_vm_jre.yml +++ b/config/graal_vm_jre.yml @@ -18,7 +18,10 @@ # e.g. repository_root: "https://example.com/graalvm-jre/{platform}/{architecture}" --- jre: - version: 19.3.+ + version: 22.1.+ + version_lines: + - 22.1.+ + - 21.3.+ repository_root: "" jvmkill_agent: version: 1.+ diff --git a/config/ibm_jre.yml b/config/ibm_jre.yml index 39b5c3d944..4446537109 100644 --- a/config/ibm_jre.yml +++ b/config/ibm_jre.yml @@ -18,7 +18,9 @@ --- jre: version: 1.8.+ - repository_root: https://raw.githubusercontent.com/ibmruntimes/ci.docker/master/ibmjava/meta/jre/linux/x86_64 + version_lines: + - 1.8.+ + repository_root: https://raw.githubusercontent.com/ibmruntimes/ci.docker/master/ibmjava/meta/jre/linux/{architecture} heap_ratio: 0.75 jvmkill_agent: version: 1.+ diff --git a/config/open_jdk_jre.yml b/config/open_jdk_jre.yml index 2cee774cf4..27b70a03bd 100644 --- a/config/open_jdk_jre.yml +++ b/config/open_jdk_jre.yml @@ -14,10 +14,13 @@ # limitations under the License. # Configuration for JRE repositories keyed by vendor -# If Java 7 is required, permgen will be used instead of metaspace. Please see the documentation for more detail. --- jre: version: 1.8.0_+ + version_lines: + - 1.8.0_+ + - 11.+ + - 17.+ repository_root: "{default.repository.root}/openjdk/{platform}/{architecture}" jvmkill_agent: version: 1.+ diff --git a/config/oracle_jre.yml b/config/oracle_jre.yml index df91cc2e26..a24848b28c 100644 --- a/config/oracle_jre.yml +++ b/config/oracle_jre.yml @@ -21,6 +21,10 @@ --- jre: version: 1.8.0_+ + version_lines: + - 1.8.0_+ + - 11.+ + - 17.+ repository_root: "" jvmkill_agent: version: 1.+ diff --git a/config/packaging.yml b/config/packaging.yml new file mode 100644 index 0000000000..31bb350dd0 --- /dev/null +++ b/config/packaging.yml @@ -0,0 +1,190 @@ +# Cloud Foundry Java Buildpack +# Copyright 2013-2022 the original author or authors. +# +# 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. + +--- +access_logging_support: + name: Tomcat Access Logging Support + cve_notes: Included inline above + release_notes: Included inline above + +agent: + name: Java Memory Assistant Agent + +app_dynamics_agent: + name: AppDynamics Agent + release_notes: '[Release Notes](https://docs.appdynamics.com/4.5.x/en/product-and-release-announcements/release-notes/language-agent-notes/java-agent-notes)' + +azure_application_insights_agent: + name: Azure Application Insights Agent + release_notes: '[Release Notes](https://github.com/Microsoft/ApplicationInsights-Java/releases)' + +clean_up: + name: Java Memory Assistant Clean Up + +client_certificate_mapper: + name: Client Certificate Mapper + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +container_customizer: + name: Spring Boot Container Customizer + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +container_security_provider: + name: Container Security Provider + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +contrast_security_agent: + name: Contrast Security Agent + release_notes: '[Release Notes](https://docs.contrastsecurity.com/en/java-agent-release-notes.html)' + +datadog_javaagent: + name: Datadog APM Javaagent + release_notes: '[Release Notes](https://github.com/DataDog/dd-trace-java/releases)' + +dynatrace_one_agent: + name: Dynatrace OneAgent + release_notes: '[Release Notes](https://www.dynatrace.com/support/help/whats-new/release-notes/#oneagent)' + +elastic_apm_agent: + name: Elastic APM Agent + release_notes: '[Release Notes](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes.html)' + +geode_store: + name: Geode Tomcat Session Store + +google_stackdriver_debugger: + name: Google Stackdriver Debugger + release_notes: '[Release Notes](https://cloud.google.com/debugger/docs/release-notes)' + +google_stackdriver_profiler: + name: Google Stackdriver Profiler + release_notes: '[Release Notes](https://cloud.google.com/profiler/docs/release-notes)' + +groovy: + name: Groovy + release_notes: '[Release Notes](http://www.groovy-lang.org/releases.html)' + +introscope_agent: + name: CA Introscope APM Framework + +jacoco_agent: + name: JaCoCo Agent + release_notes: '[Release Notes](https://github.com/jacoco/jacoco/releases)' + +jprofiler_profiler: + name: JProfiler Profiler + release_notes: '[ChangeLog](https://www.ej-technologies.com/download/jprofiler/changelog.html)' + +jre: + name: OpenJDK JRE 8 + cve_notes: '[Risk Matrix](https://www.oracle.com/security-alerts/cpujul2022.html#AppendixJAVA)' + release_notes: '[Release Notes](https://bell-sw.com/pages/liberica-release-notes-8u342/)' + +jre-11: + name: OpenJDK JRE 11 + cve_notes: '[Risk Matrix](https://www.oracle.com/security-alerts/cpujul2022.html#AppendixJAVA)' + release_notes: '[Release Notes](https://bell-sw.com/pages/liberica-release-notes-11.0.16/)' + +jre-17: + name: OpenJDK JRE 17 + cve_notes: '[Risk Matrix](https://www.oracle.com/security-alerts/cpujul2022.html#AppendixJAVA)' + release_notes: '[Release Notes](https://bell-sw.com/pages/liberica-release-notes-17.0.4/)' + +jrebel_agent: + name: JRebel Agent + release_notes: '[ChangeLog](https://www.jrebel.com/products/jrebel/changelog)' + +jvmkill_agent: + name: jvmkill Agent + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +lifecycle_support: + name: Tomcat Lifecycle Support + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +logging_support: + name: Tomcat Logging Support + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +luna_security_provider: + name: Gemalto Luna Security Provider + release_notes: '[Release Notes](https://www.thalesdocs.com/gphsm/luna/7/docs/network/Content/CRN/Luna/CRN_Luna.htm)' + +maria_db_jdbc: + name: MariaDB JDBC Driver + release_notes: '[Release Notes](https://mariadb.com/kb/en/mariadb-connector-j-274-release-notes/)' + +memory_calculator: + name: Memory Calculator + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +metric_writer: + name: Metric Writer + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +new_relic_agent: + name: New Relic Agent + release_notes: '[Release Notes](https://docs.newrelic.com/docs/release-notes/agent-release-notes/java-release-notes/)' + +postgresql_jdbc: + name: PostgreSQL JDBC Driver + release_notes: '[ChangeLog](https://jdbc.postgresql.org/documentation/changelog.html)' + +protect_app_security_provider: + name: Gemalto ProtectApp Security Provider + +redis_store: + name: Redis Session Store + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +riverbed_appinternals_agent: + name: Riverbed Appinternals Agent + +sealights_agent: + name: SeaLights Agent + +sky_walking_agent: + name: SkyWalking + release_notes: '[ChangeLog](https://github.com/apache/skywalking/tree/master/changes)' + +spring_auto_reconfiguration: + name: Spring Auto-reconfiguration + cve_notes: 'Included inline above' + release_notes: 'Included inline above' + +spring_boot_cli: + name: Spring Boot CLI + +takipi_agent: + name: Takipi Agent + release_notes: '[Release Notes](https://doc.overops.com/docs/whats-new)' + +tomcat: + name: Tomcat + cve_notes: '[Security](https://tomcat.apache.org/security-9.html)' + release_notes: '[ChangeLog](https://tomcat.apache.org/tomcat-9.0-doc/changelog.html)' + +your_kit_profiler: + name: YourKit Profiler + release_notes: '[Release Notes](https://www.yourkit.com/download/yjp_2022_3_builds.jsp)' diff --git a/config/sap_machine_jre.yml b/config/sap_machine_jre.yml index ef8fb554fb..c0784cded4 100644 --- a/config/sap_machine_jre.yml +++ b/config/sap_machine_jre.yml @@ -18,6 +18,9 @@ --- jre: version: 11.+ + version_lines: + - 11.+ + - 17.+ repository_root: "https://sap.github.io/SapMachine/assets/cf/jre/linux/{architecture}" jvmkill_agent: version: 1.+ diff --git a/config/zulu_jre.yml b/config/zulu_jre.yml index 231b659ccb..5b8f41e05e 100755 --- a/config/zulu_jre.yml +++ b/config/zulu_jre.yml @@ -21,6 +21,9 @@ --- jre: version: 1.8.0_+ + version_lines: + - 1.8.0_+ + - 11.+ repository_root: "https://cdn.azul.com/zulu/bin" jvmkill_agent: version: 1.+ diff --git a/java-buildpack.iml b/java-buildpack.iml index c156f343b4..2b50d9c2eb 100644 --- a/java-buildpack.iml +++ b/java-buildpack.iml @@ -9,7 +9,7 @@ - + @@ -35,7 +35,7 @@ - + @@ -61,7 +61,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -113,7 +113,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -181,7 +181,7 @@ - + @@ -225,7 +225,7 @@ - + @@ -263,7 +263,7 @@ - + @@ -307,7 +307,7 @@ - + @@ -345,7 +345,7 @@ - + @@ -386,39 +386,301 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/java_buildpack/util/configuration_utils.rb b/lib/java_buildpack/util/configuration_utils.rb index c50ae73be7..687ebaa7c7 100644 --- a/lib/java_buildpack/util/configuration_utils.rb +++ b/lib/java_buildpack/util/configuration_utils.rb @@ -45,9 +45,13 @@ def load(identifier, clean_nil_values = true, should_log = true) file = file_name(identifier) if file.exist? - var_name = environment_variable_name(identifier) - user_provided = ENV.fetch(var_name, nil) - configuration = load_configuration(file, user_provided, var_name, clean_nil_values, should_log) + operator_var_name = default_variable_name(identifier) + operator_provided = ENV.fetch(operator_var_name, nil) + + user_var_name = environment_variable_name(identifier) + user_provided = ENV.fetch(user_var_name, nil) + configuration = load_configuration(file, operator_provided, operator_var_name, user_provided, + user_var_name, clean_nil_values, should_log) elsif should_log logger.debug { "No configuration file #{file} found" } end @@ -80,6 +84,7 @@ def write(identifier, new_content, should_log = true) CONFIG_DIRECTORY = Pathname.new(File.expand_path('../../../config', File.dirname(__FILE__))).freeze + DEFAULT_VARIABLE_PATTERN = 'JBP_DEFAULT_' ENVIRONMENT_VARIABLE_PATTERN = 'JBP_CONFIG_' private_constant :CONFIG_DIRECTORY, :ENVIRONMENT_VARIABLE_PATTERN @@ -112,16 +117,26 @@ def header(file) header end - def load_configuration(file, user_provided, var_name, clean_nil_values, should_log) + def load_configuration(file, operator_provided, operator_var_name, user_provided, user_var_name, + clean_nil_values, should_log) configuration = YAML.load_file(file) logger.debug { "Configuration from #{file}: #{configuration}" } if should_log + if operator_provided + begin + operator_provided_value = YAML.safe_load(operator_provided) + configuration = merge_configuration(configuration, operator_provided_value, operator_var_name, should_log) + rescue Psych::SyntaxError => e + raise "Default configuration value in environment variable #{operator_var_name} has invalid syntax: #{e}" + end + end + if user_provided begin user_provided_value = YAML.safe_load(user_provided) - configuration = merge_configuration(configuration, user_provided_value, var_name, should_log) + configuration = merge_configuration(configuration, user_provided_value, user_var_name, should_log) rescue Psych::SyntaxError => e - raise "User configuration value in environment variable #{var_name} has invalid syntax: #{e}" + raise "User configuration value in environment variable #{user_var_name} has invalid syntax: #{e}" end logger.debug { "Configuration from #{file} modified with: #{user_provided}" } if should_log end @@ -161,6 +176,10 @@ def do_resolve_value(key, v1, v2, should_log) v1 end + def default_variable_name(config_name) + DEFAULT_VARIABLE_PATTERN + config_name.upcase + end + def environment_variable_name(config_name) ENVIRONMENT_VARIABLE_PATTERN + config_name.upcase end diff --git a/rakelib/dependency_cache_task.rb b/rakelib/dependency_cache_task.rb index 1d05ee4a06..01a1512a47 100644 --- a/rakelib/dependency_cache_task.rb +++ b/rakelib/dependency_cache_task.rb @@ -36,6 +36,8 @@ class DependencyCacheTask < Rake::TaskLib def initialize return unless BUILDPACK_VERSION.offline + @pkgcfg = nil + JavaBuildpack::Logging::LoggerFactory.instance.setup "#{BUILD_DIR}/" @default_repository_root = default_repository_root @@ -120,39 +122,6 @@ def component_ids conf end - def configuration(id) - JavaBuildpack::Util::ConfigurationUtils.load(id, false, false) - end - - def configurations(component_id, configuration, sub_component_id = nil) - configurations = [] - - if repository_configuration?(configuration) - configuration['component_id'] = component_id - configuration['sub_component_id'] = sub_component_id if sub_component_id - - if component_id == 'open_jdk_jre' && sub_component_id == 'jre' - c1 = configuration.clone - c1['version'] = '11.+' - - configurations << c1 - end - - if component_id == 'open_jdk_jre' && sub_component_id == 'jre' - c1 = configuration.clone - c1['version'] = '17.+' - - configurations << c1 - end - - configurations << configuration - else - configuration.each { |k, v| configurations << configurations(component_id, v, k) if v.is_a? Hash } - end - - configurations - end - def component_configuration(component_id) configurations(component_id, configuration(component_id)) end @@ -161,19 +130,6 @@ def default_repository_root configuration('repository')['default_repository_root'].chomp('/') end - def index_configuration(configuration) - [configuration['repository_root']] - .map { |r| { uri: r } } - .map { |r| augment_repository_root r } - .map { |r| augment_platform r } - .map { |r| augment_architecture r } - .map { |r| augment_path r }.flatten - end - - def repository_configuration?(configuration) - configuration['version'] && configuration['repository_root'] - end - def uris(configurations) uris = [] @@ -190,7 +146,7 @@ def uris(configurations) def get_from_cache(configuration, index_configuration, uris) @cache.get(index_configuration[:uri]) do |f| index = YAML.safe_load f - found_version = version(configuration, index) + found_version = Utils::VersionUtils.version(configuration, index) pin_version(configuration, found_version.to_s) if ENV['PINNED'].to_b if found_version.nil? @@ -205,12 +161,32 @@ def get_from_cache(configuration, index_configuration, uris) def pin_version(old_configuration, version) component_id = old_configuration['component_id'] sub_component_id = old_configuration['sub_component_id'] - rake_output_message "Pinning #{sub_component_id || component_id} version to #{version}" + if Utils::VersionUtils.openjdk_jre? old_configuration + rake_output_message "Pinning JRE #{sub_component_id || component_id} version to #{version}" + pin_jre(component_id, sub_component_id, version) + else + rake_output_message "Pinning #{sub_component_id || component_id} version to #{version}" + pin_component(component_id, sub_component_id, version) + end + end + + def pin_component(component_id, sub_component_id, version) configuration_to_update = JavaBuildpack::Util::ConfigurationUtils.load(component_id, false, true) update_configuration(configuration_to_update, version, sub_component_id) JavaBuildpack::Util::ConfigurationUtils.write(component_id, configuration_to_update) end + def pin_jre(component_id, sub_component_id, version) + # update configuration file, pin version & version lines + configuration_to_update = JavaBuildpack::Util::ConfigurationUtils.load(component_id, false, true) + update_configuration(configuration_to_update, version, sub_component_id) + configuration_to_update['jre']['version_lines'].each_with_index do |version_pattern, index| + configuration_to_update['jre']['version_lines'][index] = version \ + if Utils::VersionUtils.version_matches?(version_pattern, [version]) + end + JavaBuildpack::Util::ConfigurationUtils.write(component_id, configuration_to_update) + end + def update_configuration(config, version, sub_component) if sub_component.nil? config['version'] = version @@ -220,12 +196,5 @@ def update_configuration(config, version, sub_component) config.each_value { |v| update_configuration(v, version, sub_component) if v.is_a? Hash } end end - - def version(configuration, index) - JavaBuildpack::Repository::VersionResolver - .resolve(JavaBuildpack::Util::TokenizedVersion.new(configuration['version']), index.keys) - end - end - end diff --git a/rakelib/package.rb b/rakelib/package.rb index ebbac99291..5fffb464ac 100644 --- a/rakelib/package.rb +++ b/rakelib/package.rb @@ -19,6 +19,46 @@ module Package + def packaging + @pkgcfg = configuration('packaging') if @pkgcfg.nil? + @pkgcfg + end + + def configuration(id) + JavaBuildpack::Util::ConfigurationUtils.load(id, false, false) + end + + def configurations(component_id, configuration, sub_component_id = nil) + configurations = [] + + if repository_configuration?(configuration) + configuration['component_id'] = component_id + configuration['sub_component_id'] = sub_component_id if sub_component_id + + Utils::VersionUtils.java_version_lines(configuration, configurations) \ + if Utils::VersionUtils.openjdk_jre? configuration + + configurations << configuration + else + configuration.each { |k, v| configurations << configurations(component_id, v, k) if v.is_a? Hash } + end + + configurations + end + + def index_configuration(configuration) + [configuration['repository_root']] + .map { |r| { uri: r } } + .map { |r| augment_repository_root r } + .map { |r| augment_platform r } + .map { |r| augment_architecture r } + .map { |r| augment_path r }.flatten + end + + def repository_configuration?(configuration) + configuration['version'] && configuration['repository_root'] + end + def self.offline '-offline' if BUILDPACK_VERSION.offline end diff --git a/rakelib/utils.rb b/rakelib/utils.rb new file mode 100644 index 0000000000..98a40fef8f --- /dev/null +++ b/rakelib/utils.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +# Cloud Foundry Java Buildpack +# Copyright 2013-2022 the original author or authors. +# +# 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. + +module Utils + class VersionUtils + class << self + def version_wildcard?(version_pattern) + version_pattern.include? '+' + end + + def version(configuration, index) + matched_version(configuration['version'], index.keys) + end + + def matched_version(version_pattern, versions) + JavaBuildpack::Repository::VersionResolver + .resolve(JavaBuildpack::Util::TokenizedVersion.new(version_pattern), versions) + end + + def version_matches?(version_pattern, versions) + !matched_version(version_pattern, versions).nil? + end + + def openjdk_jre?(configuration) + configuration['component_id'].end_with?('_jre') && configuration['sub_component_id'].start_with?('jre') + end + + def java_version_lines(configuration, configurations) + configuration['version_lines'].each do |v| + next if version_line_matches?(configuration, v) + + c1 = configuration.clone + c1['sub_component_id'] = "jre-#{v.split('.')[0]}" + c1['version'] = v + configurations << c1 + end + end + + def version_line_matches?(configuration, v) + return true if v == configuration['version'] + return false if version_wildcard? v + + version_matches?(configuration['version'], [v]) + end + end + end +end diff --git a/rakelib/versions_task.rb b/rakelib/versions_task.rb index b0f21155b5..8869c181b1 100644 --- a/rakelib/versions_task.rb +++ b/rakelib/versions_task.rb @@ -24,6 +24,7 @@ require 'json' require 'rake/tasklib' require 'rakelib/package' +require 'rakelib/utils' require 'terminal-table' require 'yaml' @@ -36,6 +37,8 @@ class VersionsTask < Rake::TaskLib def initialize JavaBuildpack::Logging::LoggerFactory.instance.setup "#{BUILD_DIR}/" + @pkgcfg = nil + version_task namespace 'versions' do @@ -51,134 +54,9 @@ def initialize DEFAULT_REPOSITORY_ROOT_PATTERN = /\{default.repository.root\}/.freeze - NAME_MAPPINGS = { - 'access_logging_support' => 'Tomcat Access Logging Support', - 'agent' => 'Java Memory Assistant Agent', - 'app_dynamics_agent' => 'AppDynamics Agent', - 'azure_application_insights_agent' => 'Azure Application Insights Agent', - 'clean_up' => 'Java Memory Assistant Clean Up', - 'client_certificate_mapper' => 'Client Certificate Mapper', - 'container_customizer' => 'Spring Boot Container Customizer', - 'container_security_provider' => 'Container Security Provider', - 'contrast_security_agent' => 'Contrast Security Agent', - 'datadog_javaagent' => 'Datadog APM Javaagent', - 'dynatrace_one_agent' => 'Dynatrace OneAgent', - 'elastic_apm_agent' => 'Elastic APM Agent', - 'geode_store' => 'Geode Tomcat Session Store', - 'google_stackdriver_debugger' => 'Google Stackdriver Debugger', - 'google_stackdriver_profiler' => 'Google Stackdriver Profiler', - 'groovy' => 'Groovy', - 'introscope_agent' => 'CA Introscope APM Framework', - 'jacoco_agent' => 'JaCoCo Agent', - 'jprofiler_profiler' => 'JProfiler Profiler', - 'jre' => 'OpenJDK JRE', - 'jre-11' => 'OpenJDK JRE 11', - 'jre-17' => 'OpenJDK JRE 17', - 'jrebel_agent' => 'JRebel Agent', - 'jvmkill_agent' => 'jvmkill Agent', - 'lifecycle_support' => 'Tomcat Lifecycle Support', - 'logging_support' => 'Tomcat Logging Support', - 'luna_security_provider' => 'Gemalto Luna Security Provider', - 'maria_db_jdbc' => 'MariaDB JDBC Driver', - 'memory_calculator' => 'Memory Calculator', - 'metric_writer' => 'Metric Writer', - 'new_relic_agent' => 'New Relic Agent', - 'postgresql_jdbc' => 'PostgreSQL JDBC Driver', - 'protect_app_security_provider' => 'Gemalto ProtectApp Security Provider', - 'redis_store' => 'Redis Session Store', - 'riverbed_appinternals_agent' => 'Riverbed Appinternals Agent', - 'sealights_agent' => 'SeaLights Agent', - 'sky_walking_agent' => 'SkyWalking', - 'spring_auto_reconfiguration' => 'Spring Auto-reconfiguration', - 'spring_boot_cli' => 'Spring Boot CLI', - 'takipi_agent' => 'Takipi Agent', - 'tomcat' => 'Tomcat', - 'your_kit_profiler' => 'YourKit Profiler' - }.freeze - - NOTE_LINKS = { - 'access_logging_support' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'agent' => { 'cve' => '', 'release' => '' }, - 'app_dynamics_agent' => { - 'cve' => '', - 'release' => '[Release Notes](https://docs.appdynamics.com/4.5.x/en/product-and-' \ - 'release-announcements/release-notes/language-agent-notes/java-agent-notes)' - }, - 'azure_application_insights_agent' => - { 'cve' => '', - 'release' => '[Release Notes](https://github.com/Microsoft/ApplicationInsights-Java/releases)' }, - 'clean_up' => { 'cve' => '', 'release' => '' }, - 'client_certificate_mapper' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'container_customizer' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'container_security_provider' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'contrast_security_agent' => - { 'cve' => '', - 'release' => '[Release Notes](https://docs.contrastsecurity.com/en/java-agent-release-notes.html)' }, - 'datadog_javaagent' => { 'cve' => '', - 'release' => '[Release Notes](https://github.com/DataDog/dd-trace-java/releases)' }, - 'dynatrace_one_agent' => - { 'cve' => '', - 'release' => '[Release Notes](https://www.dynatrace.com/support/help/whats-new/release-notes/#oneagent)' }, - 'elastic_apm_agent' => - { 'cve' => '', - 'release' => '[Release Notes](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes.html)' }, - 'geode_store' => { 'cve' => '', 'release' => '' }, - 'google_stackdriver_debugger' => - { 'cve' => '', - 'release' => '[Release Notes](https://cloud.google.com/debugger/docs/release-notes)' }, - 'google_stackdriver_profiler' => - { 'cve' => '', - 'release' => '[Release Notes](https://cloud.google.com/profiler/docs/release-notes)' }, - 'groovy' => { 'cve' => '', 'release' => '[Release Notes](http://www.groovy-lang.org/releases.html)' }, - 'introscope_agent' => { 'cve' => '', 'release' => '' }, - 'jacoco_agent' => { 'cve' => '', 'release' => '[Release Notes](https://github.com/jacoco/jacoco/releases)' }, - 'jprofiler_profiler' => - { 'cve' => '', - 'release' => '[ChangeLog](https://www.ej-technologies.com/download/jprofiler/changelog.html)' }, - 'jre' => { 'cve' => '[Risk Matrix](https://www.oracle.com/security-alerts/cpujul2022.html#AppendixJAVA)', - 'release' => '[Release Notes](https://bell-sw.com/pages/liberica-release-notes-8u342/)' }, - 'jre-11' => { 'cve' => '[Risk Matrix](https://www.oracle.com/security-alerts/cpujul2022.html#AppendixJAVA)', - 'release' => '[Release Notes](https://bell-sw.com/pages/liberica-release-notes-11.0.16/)' }, - 'jre-17' => { 'cve' => '[Risk Matrix](https://www.oracle.com/security-alerts/cpujul2022.html#AppendixJAVA)', - 'release' => '[Release Notes](https://bell-sw.com/pages/liberica-release-notes-17.0.4/)' }, - 'jrebel_agent' => { 'cve' => '', 'release' => '[ChangeLog](https://www.jrebel.com/products/jrebel/changelog)' }, - 'jvmkill_agent' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'lifecycle_support' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'logging_support' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'luna_security_provider' => - { 'cve' => '', - 'release' => - '[Release Notes](https://www.thalesdocs.com/gphsm/luna/7/docs/network/Content/CRN/Luna/CRN_Luna.htm)' }, - 'maria_db_jdbc' => - { 'cve' => '', - 'release' => '[Release Notes](https://mariadb.com/kb/en/mariadb-connector-j-274-release-notes/)' }, - 'memory_calculator' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'metric_writer' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'new_relic_agent' => - { 'cve' => '', - 'release' => - '[Release Notes](https://docs.newrelic.com/docs/release-notes/agent-release-notes/java-release-notes/)' }, - 'postgresql_jdbc' => { 'cve' => '', - 'release' => '[ChangeLog](https://jdbc.postgresql.org/documentation/changelog.html)' }, - 'protect_app_security_provider' => { 'cve' => '', 'release' => '' }, - 'redis_store' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'riverbed_appinternals_agent' => { 'cve' => '', 'release' => '' }, - 'sealights_agent' => { 'cve' => '', 'release' => '' }, - 'sky_walking_agent' => { 'cve' => '', - 'release' => '[ChangeLog](https://github.com/apache/skywalking/tree/master/changes)' }, - 'spring_auto_reconfiguration' => { 'cve' => 'Included inline above', 'release' => 'Included inline above' }, - 'spring_boot_cli' => { 'cve' => '', 'release' => '' }, - 'takipi_agent' => { 'cve' => '', 'release' => '[Release Notes](https://doc.overops.com/docs/whats-new)' }, - 'tomcat' => { 'cve' => '[Security](https://tomcat.apache.org/security-9.html)', - 'release' => '[ChangeLog](https://tomcat.apache.org/tomcat-9.0-doc/changelog.html)' }, - 'your_kit_profiler' => { 'cve' => '', - 'release' => '[Release Notes](https://www.yourkit.com/download/yjp_2022_3_builds.jsp)' } - }.freeze - PLATFORM_PATTERN = /\{platform\}/.freeze - private_constant :ARCHITECTURE_PATTERN, :DEFAULT_REPOSITORY_ROOT_PATTERN, :NAME_MAPPINGS, - :PLATFORM_PATTERN, :NOTE_LINKS + private_constant :ARCHITECTURE_PATTERN, :DEFAULT_REPOSITORY_ROOT_PATTERN, :PLATFORM_PATTERN def augment(raw, key, pattern, candidates, &block) if raw.respond_to? :at @@ -227,40 +105,6 @@ def component_ids configuration('components').values.flatten.map { |component| component.split('::').last.snake_case } end - def configuration(id) - JavaBuildpack::Util::ConfigurationUtils.load(id, false, false) - end - - def configurations(component_id, configuration, sub_component_id = nil) - configurations = [] - - if repository_configuration?(configuration) - configuration['component_id'] = component_id - configuration['sub_component_id'] = sub_component_id if sub_component_id - - if component_id == 'open_jdk_jre' && sub_component_id == 'jre' - c1 = configuration.clone - c1['sub_component_id'] = 'jre-11' - c1['version'] = '11.+' - - configurations << c1 - end - - if component_id == 'open_jdk_jre' && sub_component_id == 'jre' - c1 = configuration.clone - c1['sub_component_id'] = 'jre-17' - c1['version'] = '17.+' - - configurations << c1 - end - configurations << configuration - else - configuration.each { |k, v| configurations << configurations(component_id, v, k) if v.is_a? Hash } - end - - configurations - end - def default_repository_root configuration('repository')['default_repository_root'].chomp('/') end @@ -268,7 +112,7 @@ def default_repository_root def get_from_cache(cache, configuration, index_configuration) cache.get(index_configuration[:uri]) do |f| index = YAML.safe_load f - found_version = version(configuration, index) + found_version = Utils::VersionUtils.version(configuration, index) if found_version.nil? raise "Unable to resolve version '#{configuration['version']}' for platform " \ @@ -300,7 +144,7 @@ def map_config_to_dependency(cache, configuration, dependency_versions) index_configuration(configuration).each do |index_configuration| version, uri = get_from_cache(cache, configuration, index_configuration) - name = NAME_MAPPINGS[id] + name = packaging[id]['name'] raise "Unable to resolve name for '#{id}'" unless name dependency_versions << { @@ -308,30 +152,12 @@ def map_config_to_dependency(cache, configuration, dependency_versions) 'name' => name, 'uri' => uri, 'version' => version, - 'cve_link' => NOTE_LINKS[id]['cve'], - 'release_notes_link' => NOTE_LINKS[id]['release'] + 'cve_link' => packaging[id]['cve_notes'] || '', + 'release_notes_link' => packaging[id]['release_notes'] || '' } end end - def index_configuration(configuration) - [configuration['repository_root']] - .map { |r| { uri: r } } - .map { |r| augment_repository_root r } - .map { |r| augment_platform r } - .map { |r| augment_architecture r } - .map { |r| augment_path r }.flatten - end - - def repository_configuration?(configuration) - configuration['version'] && configuration['repository_root'] - end - - def version(configuration, index) - JavaBuildpack::Repository::VersionResolver - .resolve(JavaBuildpack::Util::TokenizedVersion.new(configuration['version']), index.keys) - end - def version_task desc 'Display the versions of buildpack dependencies in human readable form' task versions: [] do diff --git a/spec/java_buildpack/util/configuration_utils_spec.rb b/spec/java_buildpack/util/configuration_utils_spec.rb index fe5911bf0e..9ebd64ada7 100644 --- a/spec/java_buildpack/util/configuration_utils_spec.rb +++ b/spec/java_buildpack/util/configuration_utils_spec.rb @@ -99,6 +99,66 @@ end + context do + + let(:environment) do + { 'JBP_DEFAULT_TEST' => '{bar: {alpha: {one: 3, two: {one: 3}}, bravo: newValue}, foo: lion}' } + end + + it 'overlays operator default matching environment variables' do + + expect(described_class.load('test')).to eq('foo' => { 'one' => '1', 'two' => 2 }, + 'bar' => { 'alpha' => { 'one' => 3, 'two' => 'dog' } }, + 'version' => '1.7.1') + end + + end + + context do + + let(:environment) do + { 'JBP_DEFAULT_TEST' => '{version: 1.8.+}' } + end + + it 'overlays operator default config' do + expect(described_class.load('test')).to eq('foo' => { 'one' => '1', 'two' => 2 }, + 'bar' => { 'alpha' => { 'one' => 'cat', 'two' => 'dog' } }, + 'version' => '1.8.+') + end + + end + + context do + + let(:environment) do + { 'JBP_DEFAULT_TEST' => '{version: 11.+}', + 'JBP_CONFIG_TEST' => '{version: 17.+}' } + end + + it 'overlays operator default config and environment variable config' do + expect(described_class.load('test')).to eq('foo' => { 'one' => '1', 'two' => 2 }, + 'bar' => { 'alpha' => { 'one' => 'cat', 'two' => 'dog' } }, + 'version' => '17.+') + end + + end + + context do + + let(:environment) do + { 'JBP_DEFAULT_TEST' => '{bar: {alpha: {one: 3, two: {one: 3}}, bravo: newValue}}', + 'JBP_CONFIG_TEST' => '{bar: {alpha: {one: 9, two: {one: 3}}, bravo: newValue}}' } + end + + it 'overlays operator default matching and environment variables' do + + expect(described_class.load('test')).to eq('foo' => { 'one' => '1', 'two' => 2 }, + 'bar' => { 'alpha' => { 'one' => 9, 'two' => 'dog' } }, + 'version' => '1.7.1') + end + + end + context do let(:environment) do