Skip to content

docs(updated): Add secret example documentation and updater actions #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/updater.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: updater
on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 5' # every Friday at 07:00 Colombia Time
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Check for updates
run: ./gradlew internalTask --action UPDATE_DEPENDENCIES
- name: Check for changes
id: git_changes
run: |
git diff --name-only
if [[ $(git diff --name-only) ]]; then
echo "Changes detected!"
echo "HAS_CHANGES=true" >> $GITHUB_ENV
else
echo "No changes detected!"
echo "HAS_CHANGES=false" >> $GITHUB_ENV
fi
- name: Create Pull Request
if: env.HAS_CHANGES == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PA_TOKEN }}
committer: Dependencies Bot <[email protected]>
commit-message: 'fix(deps): update dependencies'
title: 'fix(deps): update dependencies'
body: 'This PR updates dependencies to latest versions'
branch: 'feature/autoupdate-deps'
base: 'master'
labels: 'dependencies'
reviewers: 'juancgalvis'
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {
id 'org.sonarqube' version '6.0.1.5171'
id 'org.springframework.boot' version '3.4.1' apply false
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'co.com.bancolombia.cleanArchitecture' version '3.20.8'
id 'co.com.bancolombia.cleanArchitecture' version '3.20.12'
}

repositories {
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/reactive-commons/1-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ public class MyRabbitMQConfig {
}
```

Please refer to [Configuration Properties](/reactive-commons-java/docs/reactive-commons/configuration-properties)
Or with secrets [Loading properties from a secret](/reactive-commons-java/docs/reactive-commons/configuration-properties#loading-properties-from-a-secret)

The 5.x.x stable version of Reactive Commons has been merged with the deprecated `-eda` variant, this means that
the `async-commons-rabbit-starter` artifact is now the only one to use.

Expand Down
71 changes: 71 additions & 0 deletions docs/docs/reactive-commons/9-configuration-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public class MyDomainConfig {
}
```

## Loading properties from a secret

Additionally, if you want to set only connection properties you can use the `AsyncPropsDomain.RabbitSecretFiller` class.

```java
Expand All @@ -115,6 +117,75 @@ public AsyncPropsDomain.RabbitSecretFiller customFiller() {
// customize asyncProps here by domain
};
}
```

For example if you use the [Secrets Manager](https://github.com/bancolombia/secrets-manager) project, you may use
the next code to load the properties from a secret:

1. Create a class with the properties that you will load from the secret:
```java
import lombok.Builder;
import lombok.Data;
import org.reactivecommons.async.rabbit.config.RabbitProperties;

@Data
@Builder
public class RabbitConnectionProperties {
private String hostname;
private String password;
private String username;
private Integer port;
private String virtualhost;
private boolean ssl;

public RabbitProperties toRabbitProperties() {
var rabbitProperties = new RabbitProperties();
rabbitProperties.setHost(this.hostname);
rabbitProperties.setUsername(this.username);
rabbitProperties.setPassword(this.password);
rabbitProperties.setPort(this.port);
rabbitProperties.setVirtualHost(this.virtualhost);
rabbitProperties.getSsl().setEnabled(this.ssl); // To enable SSL
return rabbitProperties;
}
}
```
2. Use the `SecretsManager` to load the properties from the secret:

```java
import co.com.bancolombia.secretsmanager.api.GenericManager;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.reactivecommons.async.rabbit.config.RabbitProperties;
import org.reactivecommons.async.rabbit.config.props.AsyncPropsDomain;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.GenericArrayType;

@Log4j2
@Configuration
public class AsyncEventBusConfig {

// TODO: You should create the GenericManager bean as indicated in Secrets Manager library
@Bean
public AsyncPropsDomain.RabbitSecretFiller rabbitSecretFiller(GenericManager genericManager) {
return (domain, props) -> {
if (props.getSecret() != null) {
log.info("Loading RabbitMQ connection properties from secret: {}", props.getSecret());
props.setConnectionProperties(getFromSecret(genericManager, props.getSecret()));
log.info("RabbitMQ connection properties loaded successfully with host: '{}'",
props.getConnectionProperties().getHost());
}
};
}

@SneakyThrows
private RabbitProperties getFromSecret(GenericManager genericManager, String secretName) {
return genericManager.getSecret(secretName, RabbitConnectionProperties.class).toRabbitProperties();
}
}

```

</TabItem>
Expand Down
Loading