cloud-config-client-autoconfig

Auto Configuration for creating Config Clients

License

License

Categories

Categories

CLI User Interface Auto Application Layer Libs Code Generators config Configuration
GroupId

GroupId

io.github.piszmog
ArtifactId

ArtifactId

cloud-config-client-autoconfig
Last Version

Last Version

3.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

cloud-config-client-autoconfig
Auto Configuration for creating Config Clients
Project URL

Project URL

https://github.com/Piszmog/cloud-config-client-autoconfig
Source Code Management

Source Code Management

https://github.com/Piszmog/cloud-config-client-autoconfig/tree/master

Download cloud-config-client-autoconfig

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.piszmog/cloud-config-client-autoconfig/ -->
<dependency>
    <groupId>io.github.piszmog</groupId>
    <artifactId>cloud-config-client-autoconfig</artifactId>
    <version>3.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.piszmog/cloud-config-client-autoconfig/
implementation 'io.github.piszmog:cloud-config-client-autoconfig:3.3.0'
// https://jarcasting.com/artifacts/io.github.piszmog/cloud-config-client-autoconfig/
implementation ("io.github.piszmog:cloud-config-client-autoconfig:3.3.0")
'io.github.piszmog:cloud-config-client-autoconfig:jar:3.3.0'
<dependency org="io.github.piszmog" name="cloud-config-client-autoconfig" rev="3.3.0">
  <artifact name="cloud-config-client-autoconfig" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.piszmog', module='cloud-config-client-autoconfig', version='3.3.0')
)
libraryDependencies += "io.github.piszmog" % "cloud-config-client-autoconfig" % "3.3.0"
[io.github.piszmog/cloud-config-client-autoconfig "3.3.0"]

Dependencies

compile (4)

Group / Artifact Type Version
io.github.piszmog : cloud-config-client jar 3.2.0
com.fasterxml.jackson.dataformat : jackson-dataformat-properties jar
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar
org.springframework.boot : spring-boot-configuration-processor Optional jar

provided (2)

Group / Artifact Type Version
io.pivotal.spring.cloud : spring-cloud-services-starter-config-client jar
io.pivotal.spring.cloud : spring-cloud-services-config-client-autoconfigure jar

test (5)

Group / Artifact Type Version
org.spockframework : spock-core jar 1.3-groovy-2.5
org.codehaus.groovy : groovy-all pom 3.0.7
net.bytebuddy : byte-buddy jar
org.objenesis : objenesis jar 3.1
cglib : cglib jar 3.3.0

Project Modules

There are no modules declared in this project.

Cloud Config Client AutoConfig

Maven Central

Description

Spring Auto-configuration library for Cloud Config Client.

Cloud Config Client AutoConfig 3.3.x is compatible with

Dependency Version
Spring Boot 2.4.x
Spring Cloud Services 3.2.x.RELEASE

Cloud Config Client AutoConfig 3.2.x is compatible with

Dependency Version
Spring Boot 2.2.x - 2.3.x
Spring Cloud Services 3.1.x.RELEASE

Cloud Config Client AutoConfig 2.x is compatible with

Dependency Version
Spring Boot 2.1.x
Spring Cloud Services 2.x.x.RELEASE

Cloud Config Client AutoConfig 1.x is compatible with

Dependency Version
Spring Boot 1.5.x
Spring Cloud Services 1.5.x.RELEASE

Creates Spring Beans for DecryptConfigClient, EncryptConfigClient, FileConfigClient, and PublicKeyClient. Simply inject the beans where needed.

Usage

To use, add the following as a dependency,

<dependency>
    <groupId>io.github.piszmog</groupId>
    <artifactId>cloud-config-client-autoconfig</artifactId>
    <version>${cloud-config-client-autoconfig.version}</version>
</dependency>

Local Config Server

Local Config Server is considered a locally running application setup as a Config Server. (see Spring Config Server).

Spring Cloud Config Server (PCF)

When deploying applications to PCF, a Config Server service can be created to. Once created, applications deployed to the space can bind to the service.

Disabling Clients

To disable any of the clients, add the following to the application's configuration file.

cloud:
  config:
    client:
      decrypt:
        enabled: false
      encrypt:
        enabled: false
      file:
        enabled: false
      publickey:
        enabled: false

Loading Files

FileConfigClient bean allows for the ability to pull down files either from a specified branch or from the default branch.

If pulling from the default branch, files must be located in a subdirectory.

Adding JSON Files as Property Sources

The Config Server Client will only pull down .properties and .yml/.yaml files for an application's configuration (property sources). As more microservices move to code by configuration, these files can get very large and hard to maintain. Splitting configurations out into JSON files that do not need to follow the Config Server's naming convention can help to better organize an application configuration.

Leveraging the FileConfigClient bean, JSON files can be loaded as property sources. This allows for ConfigurationProperties to have JSON values be injected into their fields.

To add a file as a property source, update the application configuration to have the following,

cloud:
  config:
    client:
      file:
        resources:
          - directory: <sub-directory path>
            files:
              - <file>
              - <file>
              ...
          - directory: <sub-directory path>
            files:
              - <file>
              - <file>
              ...
          ...

Where,

  • <sub-directory path> is the directory path to the following files -- example nonprod/example or configs
    • Sub-directory must not be null or blank.
  • <file> is the JSON, YAML, or Properties file to load that is located in the specified sub-directory

Specifying Configuration

Adding JSON files to be property sources can either be done in the bootstrap.yml (embedded with the application), in an embedded application configuration, or in the Config Server.

Versions

Version
3.3.0
3.2.1
3.2
3.1
3.0
2.4
2.3
2.2
2.1
2.0
1.2
1.1
1.0