Skip to content

Commit 454e18d

Browse files
authored
docs(updated): Add secret example documentation and updater actions (#131)
* docs(updated): Add secret example documentation and updater actions
1 parent 595f3e8 commit 454e18d

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed

.github/workflows/updater.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: updater
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 12 * * 5' # every Friday at 07:00 Colombia Time
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up JDK 17
12+
uses: actions/setup-java@v4
13+
with:
14+
distribution: 'temurin'
15+
java-version: 17
16+
- name: Check for updates
17+
run: ./gradlew internalTask --action UPDATE_DEPENDENCIES
18+
- name: Check for changes
19+
id: git_changes
20+
run: |
21+
git diff --name-only
22+
if [[ $(git diff --name-only) ]]; then
23+
echo "Changes detected!"
24+
echo "HAS_CHANGES=true" >> $GITHUB_ENV
25+
else
26+
echo "No changes detected!"
27+
echo "HAS_CHANGES=false" >> $GITHUB_ENV
28+
fi
29+
- name: Create Pull Request
30+
if: env.HAS_CHANGES == 'true'
31+
uses: peter-evans/create-pull-request@v6
32+
with:
33+
token: ${{ secrets.PA_TOKEN }}
34+
committer: Dependencies Bot <[email protected]>
35+
commit-message: 'fix(deps): update dependencies'
36+
title: 'fix(deps): update dependencies'
37+
body: 'This PR updates dependencies to latest versions'
38+
branch: 'feature/autoupdate-deps'
39+
base: 'master'
40+
labels: 'dependencies'
41+
reviewers: 'juancgalvis'

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ plugins {
1515
id 'org.sonarqube' version '6.0.1.5171'
1616
id 'org.springframework.boot' version '3.4.1' apply false
1717
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
18-
id 'co.com.bancolombia.cleanArchitecture' version '3.20.8'
18+
id 'co.com.bancolombia.cleanArchitecture' version '3.20.12'
1919
}
2020

2121
repositories {

docs/docs/reactive-commons/1-getting-started.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public class MyRabbitMQConfig {
112112
}
113113
```
114114

115+
Please refer to [Configuration Properties](/reactive-commons-java/docs/reactive-commons/configuration-properties)
116+
Or with secrets [Loading properties from a secret](/reactive-commons-java/docs/reactive-commons/configuration-properties#loading-properties-from-a-secret)
117+
115118
The 5.x.x stable version of Reactive Commons has been merged with the deprecated `-eda` variant, this means that
116119
the `async-commons-rabbit-starter` artifact is now the only one to use.
117120

docs/docs/reactive-commons/9-configuration-properties.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public class MyDomainConfig {
105105
}
106106
```
107107

108+
## Loading properties from a secret
109+
108110
Additionally, if you want to set only connection properties you can use the `AsyncPropsDomain.RabbitSecretFiller` class.
109111

110112
```java
@@ -115,6 +117,75 @@ public AsyncPropsDomain.RabbitSecretFiller customFiller() {
115117
// customize asyncProps here by domain
116118
};
117119
}
120+
```
121+
122+
For example if you use the [Secrets Manager](https://github.com/bancolombia/secrets-manager) project, you may use
123+
the next code to load the properties from a secret:
124+
125+
1. Create a class with the properties that you will load from the secret:
126+
```java
127+
import lombok.Builder;
128+
import lombok.Data;
129+
import org.reactivecommons.async.rabbit.config.RabbitProperties;
130+
131+
@Data
132+
@Builder
133+
public class RabbitConnectionProperties {
134+
private String hostname;
135+
private String password;
136+
private String username;
137+
private Integer port;
138+
private String virtualhost;
139+
private boolean ssl;
140+
141+
public RabbitProperties toRabbitProperties() {
142+
var rabbitProperties = new RabbitProperties();
143+
rabbitProperties.setHost(this.hostname);
144+
rabbitProperties.setUsername(this.username);
145+
rabbitProperties.setPassword(this.password);
146+
rabbitProperties.setPort(this.port);
147+
rabbitProperties.setVirtualHost(this.virtualhost);
148+
rabbitProperties.getSsl().setEnabled(this.ssl); // To enable SSL
149+
return rabbitProperties;
150+
}
151+
}
152+
```
153+
2. Use the `SecretsManager` to load the properties from the secret:
154+
155+
```java
156+
import co.com.bancolombia.secretsmanager.api.GenericManager;
157+
import lombok.SneakyThrows;
158+
import lombok.extern.log4j.Log4j2;
159+
import org.reactivecommons.async.rabbit.config.RabbitProperties;
160+
import org.reactivecommons.async.rabbit.config.props.AsyncPropsDomain;
161+
import org.springframework.context.annotation.Bean;
162+
import org.springframework.context.annotation.Configuration;
163+
164+
import java.lang.reflect.GenericArrayType;
165+
166+
@Log4j2
167+
@Configuration
168+
public class AsyncEventBusConfig {
169+
170+
// TODO: You should create the GenericManager bean as indicated in Secrets Manager library
171+
@Bean
172+
public AsyncPropsDomain.RabbitSecretFiller rabbitSecretFiller(GenericManager genericManager) {
173+
return (domain, props) -> {
174+
if (props.getSecret() != null) {
175+
log.info("Loading RabbitMQ connection properties from secret: {}", props.getSecret());
176+
props.setConnectionProperties(getFromSecret(genericManager, props.getSecret()));
177+
log.info("RabbitMQ connection properties loaded successfully with host: '{}'",
178+
props.getConnectionProperties().getHost());
179+
}
180+
};
181+
}
182+
183+
@SneakyThrows
184+
private RabbitProperties getFromSecret(GenericManager genericManager, String secretName) {
185+
return genericManager.getSecret(secretName, RabbitConnectionProperties.class).toRabbitProperties();
186+
}
187+
}
188+
118189
```
119190

120191
</TabItem>

0 commit comments

Comments
 (0)