Skip to content

Commit 955a77e

Browse files
author
Christopher Frost
committed
Merge branch 'dsyer-patch-1'
2 parents 378f420 + 4703e4d commit 955a77e

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,36 @@ The following are _very_ simple examples for deploying the artifact types that w
2727
## Configuration and Extension
2828
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.
2929

30-
Buildpack 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. The value of the variable should be valid inline yaml, referred to as `flow style` in the yaml spec. For example, to change the default version of Java to 7 and adjust the memory heuristics apply this environment variable to the application.
30+
Buildpack 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. 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 7 and adjust the memory heuristics apply this environment variable to the application.
3131

3232
```bash
33-
$ cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '[jre: { version: 1.7.0_+ }]'
33+
$ cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{jre: { version: 1.7.0_+ }}'
3434
```
3535

3636
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.
3737

3838
```bash
39-
$ cf set-env my-application JBP_CONFIG_REPOSITORY '[default_repository_root: "http://repo.example.io"]'
39+
$ cf set-env my-application JBP_CONFIG_REPOSITORY '{default_repository_root: "http://repo.example.io"}'
40+
```
41+
42+
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.
43+
44+
```bash
45+
$ cf set-env my-application JBP_CONFIG_JAVA_MAIN '{arguments: "-server.port=\$PORT -foo=bar"}'
4046
```
4147

4248
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.
4349

4450
```bash
4551
env:
46-
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '[enabled: false]'
52+
JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{enabled: false}'
4753
```
4854

4955
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.
5056

5157
```bash
5258
env:
53-
JBP_CONFIG_TOMCAT: '[tomcat: { version: 8.0.+ }]'
59+
JBP_CONFIG_TOMCAT: '{tomcat: { version: 8.0.+ }}'
5460
```
5561

5662
See the [Environment Variables][] documentation for more information.
@@ -168,3 +174,4 @@ This buildpack is released under version 2.0 of the [Apache License][].
168174
[Pull requests]: http://help.github.com/send-pull-requests
169175
[Running Cloud Foundry locally]: http://docs.cloudfoundry.org/deploying/run-local.html
170176
[Spring Boot]: http://projects.spring.io/spring-boot/
177+
[Wikipedia]: https://en.wikipedia.org/wiki/YAML#Basic_components_of_YAML

spec/java_buildpack/util/configuration_utils_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@
5959
end
6060

6161
it 'load configuration file and clean nil values' do
62-
expect(described_class.load('test', true)).to eq('foo' => { 'one' => '1', 'two' => 2 },
63-
'bar' => { 'alpha' => { 'one' => 'cat', 'two' => 'dog' } },
64-
'version' => '1.7.1')
62+
expect(described_class.load('test', true)).to eq('foo' => { 'one' => '1', 'two' => 2 },
63+
'bar' => { 'alpha' => { 'one' => 'cat', 'two' => 'dog' } },
64+
'version' => '1.7.1')
6565
end
6666

6767
context do
6868

6969
let(:environment) do
70-
{ 'JBP_CONFIG_TEST' => '[bar: {alpha: {one: 3, two: {one: 3}}, bravo: newValue}, foo: lion]' }
70+
{ 'JBP_CONFIG_TEST' => '{bar: {alpha: {one: 3, two: {one: 3}}, bravo: newValue}, foo: lion}' }
7171
end
7272

7373
it 'overlays matching environment variables' do
@@ -82,7 +82,7 @@
8282
context do
8383

8484
let(:environment) do
85-
{ 'JBP_CONFIG_TEST' => 'version: 1.8.+' }
85+
{ 'JBP_CONFIG_TEST' => '{version: 1.8.+}' }
8686
end
8787

8888
it 'overlays simple matching environment variable' do
@@ -96,7 +96,7 @@
9696
context do
9797

9898
let(:environment) do
99-
{ 'JBP_CONFIG_TEST' => 'version 1.8.+' }
99+
{ 'JBP_CONFIG_TEST' => 'Not an array or a hash' }
100100
end
101101

102102
it 'raises an exception when invalid override value is specified' do

0 commit comments

Comments
 (0)