Skip to content

Commit

Permalink
[Subscriptions Release] - pre tag commit: 'rhsm-subscriptions-1.0.76'.
Browse files Browse the repository at this point in the history
  • Loading branch information
mstead committed Nov 16, 2021
2 parents 30fd795 + f5f0e0c commit 509f7b3
Show file tree
Hide file tree
Showing 204 changed files with 7,214 additions and 1,507 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ config/
#VS Code
.project
.settings
bin
/**/bin/*
!bin/hawtio-proxy.sh
!bin/insert-mock-hosts
.vscode
.editorconfig

Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,59 @@ RBAC_USE_STUB=true ./gradlew bootRun
* `CLOUDIGRADE_PORT`: cloudigrade service port
* `CLOUDIGRADE_MAX_CONNECTIONS`: max concurrent connections to cloudigrade service

### Clowder

Clowder exposes the services it provides in an Openshift config map. This config map appears
in the container as a JSON file located by default at the path defined by `ACG_CONFIG` environment
variable (typically `/cdapp/cdappconfig.json`). The `ClowderJsonEnvironmentPostProcessor` takes
this JSON file and flattens it into Java style properties (with the namespace `clowder` prefixed).
For example,

```json
{ "kafka": {
"brokers": [{
"hostname": "localhost"
}]
}}
```

Becomes `clowder.kafka.brokers[0].hostname`. These properties are then passed into the Spring
Environment and may be used elsewhere (the `ClowderJsonEnvironmentPostProcessor` runs *before*
most other environment processing classes).

The pattern we follow is to assign the Clowder style properties to an **intermediate** property
that follows Spring Boot's environment variable
[binding conventions](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config.typesafe-configuration-properties.relaxed-binding.environment-variables)

It is important to note, this intermediate property ***must*** be given a default via the `$
{value:default}` syntax. If a default is not provided *and* the Clowder JSON is not available
(such as in development runs), Spring will fail to start because the `clowder.` property will
not resolve to anything.

An example of an intermediate property would be

```
KAFKA_BOOTSTRAP_HOST=${clowder.kafka.brokers[0].hostname:localhost}
```

This pattern has the useful property of allowing us to override any Clowder settings (in
development, for example) with environment variables since a value specified in the environment
has a higher [precedence](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config)
than values defined in config data files (e.g. `application.properties`).

The intermediate property is then assigned to any actual property that we wish to use, e.g.
`spring.kafka.bootstrap-servers`. Thus, it is trivial to either allow a value to be specified
by Clowder, overridden from Clowder via environment variable, or not given by Clowder at all and
instead based on a default.

A Clowder environment can be simulated in development by pointing the `ACG_CONFIG` environment var
to a mock Clowder JSON file.

E.g.
```
$ ACG_CONFIG=$(pwd)/swatch-core/src/test/resources/test-clowder-config.json ./gradlew bootRun
```

## Deploy to Openshift

Prerequisite secrets:
Expand Down
Loading

0 comments on commit 509f7b3

Please sign in to comment.