Skip to content
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

Ojdbc provider hashicorp #142

Merged
merged 59 commits into from
Mar 14, 2025
Merged
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d088b34
Dedicated Vault centralized config
MouhsinElmajdouby Dec 23, 2024
8292df6
Fix compilation failure for dedicated Vault
MouhsinElmajdouby Dec 23, 2024
4d5553d
restructure HashiCorp package to support dedicated and other types of…
MouhsinElmajdouby Dec 25, 2024
56e27e1
restructure HashiCorp package to support dedicated and other types of…
MouhsinElmajdouby Dec 25, 2024
e9ce2de
Enhance Vault Secrets Manager Implementation with KEY Feature
MouhsinElmajdouby Dec 25, 2024
e497be0
Refactor DedicatedVault Implementation
MouhsinElmajdouby Dec 26, 2024
65111b9
Add unit test
MouhsinElmajdouby Dec 26, 2024
60afbb5
Rename hashicorpvault to hcpdedicatedvault
MouhsinElmajdouby Dec 26, 2024
7e488bb
HCP vault secrets centralized config
MouhsinElmajdouby Jan 2, 2025
2bb0198
Add unit tests for HCP Vault Configuration Provider
MouhsinElmajdouby Jan 2, 2025
8947dd4
Add javadocs and copyright for dedicated vault
MouhsinElmajdouby Jan 3, 2025
9d3a252
Add javadocs and copyright for dedicated vault
MouhsinElmajdouby Jan 3, 2025
49d620b
Cleanup and Update authentication parsing to use switch-case logic
MouhsinElmajdouby Jan 3, 2025
ac10d60
Optimize HCP Vault integration and enhance Javadocs for HCP Vault Secret
MouhsinElmajdouby Jan 6, 2025
c58a92b
Fix Javadoc formatting in HcpVaultSecretsManagerFactory
MouhsinElmajdouby Jan 6, 2025
cf21f69
Add error handling for missing secrets in configuration
MouhsinElmajdouby Jan 6, 2025
a05ade6
Add example-test.properties file
MouhsinElmajdouby Jan 7, 2025
10b88f5
Add Readme.md file
MouhsinElmajdouby Jan 8, 2025
fe11cb5
Update Readme
MouhsinElmajdouby Jan 8, 2025
82e4c8c
Add support for optional 'key' parameter in VaultDedicated and VaultS…
MouhsinElmajdouby Jan 9, 2025
8e250ea
Update targeted version in Readme.md
MouhsinElmajdouby Jan 9, 2025
46d468f
Enhance unit tests
MouhsinElmajdouby Jan 9, 2025
230e004
Add samples for centralized configuration
MouhsinElmajdouby Jan 9, 2025
2d69b8b
rename HCP Vault providers and switch secret-name usage in hcpvaultse…
MouhsinElmajdouby Jan 10, 2025
ee20e70
Implement caching mechanism for HCP Vault Secrets bearer token
MouhsinElmajdouby Jan 15, 2025
f6548e8
Add userpass authentication method for hcp vault dedicated && update …
MouhsinElmajdouby Jan 16, 2025
b14c54b
Add new unit Tests for userpass authentication method && update the e…
MouhsinElmajdouby Jan 16, 2025
7574923
Added AppRole authentication, updated token caching to use the driver…
MouhsinElmajdouby Jan 22, 2025
bd2c5c3
Fix readme file and rename some classes
MouhsinElmajdouby Jan 23, 2025
12dfa91
Add GitHub authentication to hcpvaultdedicated, refactor utils, updat…
MouhsinElmajdouby Jan 29, 2025
1583908
Fix Javadoc formatting
MouhsinElmajdouby Jan 29, 2025
be66175
Add Credentials File Authentication for HCP Vault Secret & Improve Fi…
MouhsinElmajdouby Feb 5, 2025
209775e
Add AUTO-DETECT authentication method for both hcp vault secret and h…
MouhsinElmajdouby Feb 13, 2025
754f1ac
make 'admin' as VAULT_NAMESPACE parameter default value
MouhsinElmajdouby Feb 13, 2025
a18a1d6
Merge origin/main into ojdbc-provider-hashicorp and adapt provider to…
MouhsinElmajdouby Feb 17, 2025
1386139
Update unit tests for both hcp vault dedicated and vault secrets && f…
MouhsinElmajdouby Feb 19, 2025
8f5a2f1
Integrate Hashicorp into GitHub Actions pipeline
MouhsinElmajdouby Feb 19, 2025
4e3db01
debugging
MouhsinElmajdouby Feb 19, 2025
0c325a2
debugging
MouhsinElmajdouby Feb 19, 2025
348e884
debugging
MouhsinElmajdouby Feb 19, 2025
9b27641
debugging
MouhsinElmajdouby Feb 19, 2025
0db80e0
integrate HashiCorp and clean up secrets handling in Github Action Pi…
MouhsinElmajdouby Feb 19, 2025
72724fb
Improve the error messages and do some refactoring for both hcp vault…
MouhsinElmajdouby Feb 21, 2025
7a0e094
set the HCP_ORG_ID, HCP_PROJECT_ID and HCP_APP_NAME as environment va…
MouhsinElmajdouby Feb 21, 2025
c098452
remove the extra character '\n'
MouhsinElmajdouby Feb 21, 2025
0519720
fix tests
MouhsinElmajdouby Feb 21, 2025
513fd46
Update Readme.md && update copyrights && update javadocs
MouhsinElmajdouby Feb 24, 2025
91d2b35
Fix Javadoc issue
MouhsinElmajdouby Feb 25, 2025
52c489f
Address Review Comment
MouhsinElmajdouby Feb 27, 2025
9862296
Fix javadocs
MouhsinElmajdouby Feb 27, 2025
fbe6a01
cleanup
MouhsinElmajdouby Mar 4, 2025
3880711
Update GitHub Actions workflow to use actions/cache@v4
MouhsinElmajdouby Mar 4, 2025
4fe6435
Refactor parameter constants and enhance attribute methods and improv…
MouhsinElmajdouby Mar 7, 2025
97daec0
cleanup
MouhsinElmajdouby Mar 7, 2025
698ce23
Update the auto-detect auth method && passe default values at parsing…
MouhsinElmajdouby Mar 10, 2025
15de171
cleanup
MouhsinElmajdouby Mar 12, 2025
588889f
Address review comments
MouhsinElmajdouby Mar 13, 2025
f437c34
Address review comment
MouhsinElmajdouby Mar 13, 2025
1e7a43d
merge main into ojdbc-provider-hashicorp
MouhsinElmajdouby Mar 13, 2025
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
26 changes: 26 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ jobs:
AWS_REGION: ${{ secrets.TEST_AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
VAULT_ADDR: ${{ secrets.TEST_VAULT_ADDR }}
HCP_ORG_ID: ${{ secrets.TEST_HCP_ORG_ID }}
HCP_PROJECT_ID: ${{ secrets.TEST_HCP_PROJECT_ID }}
HCP_APP_NAME: ${{ secrets.TEST_HCP_APP_NAME }}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
@@ -127,6 +131,27 @@ jobs:
AWS_SECRETS_MANAGER_URL=${{ secrets.TEST_AWS_SECRETS_MANAGER_URL }}\n
" >> ojdbc-provider-aws/test.properties
# Generate ojdbc-provider-hashicorp/test.properties
echo -e "VAULT_ADDR=${{ secrets.TEST_VAULT_ADDR }}\n
DEDICATED_VAULT_SECRET_PATH=${{ secrets.TEST_DEDICATED_VAULT_SECRET_PATH }}\n
DEDICATED_VAULT_SECRET_PATH_WITH_MULTIPLE_KEYS=${{ secrets.TEST_DEDICATED_VAULT_SECRET_PATH_WITH_MULTIPLE_KEYS }}\n
VAULT_USERNAME=${{ secrets.TEST_VAULT_USERNAME }}\n
VAULT_PASSWORD=${{ secrets.TEST_VAULT_PASSWORD }}\n
VAULT_NAMESPACE=${{ secrets.TEST_VAULT_NAMESPACE }}\n
ROLE_ID=${{ secrets.TEST_ROLE_ID }}\n
SECRET_ID=${{ secrets.TEST_SECRET_ID }}\n
GITHUB_TOKEN=${{ secrets.TEST_GITHUB_TOKEN }}\n
KEY=${{ secrets.TEST_KEY }}\n
HCP_ORG_ID=${{ secrets.TEST_HCP_ORG_ID }}\n
HCP_PROJECT_ID=${{ secrets.TEST_HCP_PROJECT_ID }}\n
HCP_APP_NAME=${{ secrets.TEST_HCP_APP_NAME }}\n
HCP_CLIENT_ID=${{ secrets.TEST_HCP_CLIENT_ID }}\n
HCP_CLIENT_SECRET=${{ secrets.TEST_HCP_CLIENT_SECRET }}\n
SECRET_NAME=${{ secrets.TEST_SECRET_NAME }}\n
SECRET_NAME_WITH_MULTIPLE_KEYS=${{ secrets.TEST_SECRET_NAME_WITH_MULTIPLE_KEYS }}\n
" >> ojdbc-provider-hashicorp/test.properties
- name: Run tests with Maven
run: mvn -B test --file pom.xml

@@ -143,3 +168,4 @@ jobs:
rm ojdbc-provider-jackson-oson/test.properties
rm ojdbc-provider-aws/test.properties
rm ojdbc-provider-hashicorp/test.properties
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@ Each module of this project contains a set of providers.
<dd>Providers for integration with Oracle Cloud Infrastructure (OCI).</dd>
<dt><a href="ojdbc-provider-azure/README.md">Oracle JDBC Azure Providers</a></dt>
<dd>Providers for integration with Microsoft Azure</dd>
<dt><a href="ojdbc-provider-hashicorp/README.md">Oracle JDBC HashiCorp Providers</a></dt>
<dd>Providers for integration with Hashicorp</dd>
</dl>
<u>The next one contains a provider for Open Telemetry:</u>
<dl>
Original file line number Diff line number Diff line change
@@ -40,6 +40,10 @@

import oracle.jdbc.provider.factory.ResourceFactory;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

import static java.lang.String.format;
import static java.util.Collections.emptyMap;

@@ -137,11 +141,10 @@ default <T> T getRequired(Parameter<T> parameter)

if (value != null)
return value;

String name = getName(parameter);
throw new IllegalStateException(format(
"No value defined for parameter \"%s\"",
name != null ? name : parameter.toString()));
"No value defined for parameter \"%s\"",
name != null ? name : parameter.toString()));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid changes that only add/remove empty spaces.


/**
@@ -159,4 +162,17 @@ default <T> T getRequired(Parameter<T> parameter)
*/
ParameterSetBuilder copyBuilder();

/**
* Filters the parameters from the {@link ParameterSet} based on the provided
* relevant keys.
*
* This method extracts only the parameters whose names are included
* in the specified array.
*
* @param relevantKeys An array of parameter names to include in the filtered
* result.
* @return A map containing only the filtered parameters.
*/
Map<String, Object> filterParameters(String[] relevantKeys);

}
Original file line number Diff line number Diff line change
@@ -38,9 +38,7 @@

package oracle.jdbc.provider.parameter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

final class ParameterSetImpl implements ParameterSet {
@@ -102,7 +100,7 @@ public ParameterSetBuilder copyBuilder() {
ParameterSetBuilder builder = ParameterSet.builder();

for (Map.Entry<Parameter<?>, Object> parameterValue
: parameterValues.entrySet()) {
: parameterValues.entrySet()) {
@SuppressWarnings("unchecked")
Parameter<Object> parameter = (Parameter<Object>) parameterValue.getKey();
Object value = parameterValue.getValue();
@@ -124,6 +122,28 @@ public boolean equals(Object other) {
&& ((ParameterSetImpl)other).parameterValues.equals(parameterValues);
}

/**
* Retrieves the relevant parameter key-value pairs.
*/
private Map<String, Object> getParameterKeyValuePairs() {
return parameterNames.entrySet().stream()
.filter(entry -> parameterValues.get(entry.getKey()) != null)
.collect(Collectors.toMap(
Map.Entry::getValue,
entry -> parameterValues.get(entry.getKey())
));
}

@Override
public Map<String, Object> filterParameters(String[] relevantKeys) {
Map<String, Object> allParameters = getParameterKeyValuePairs();
List<String> relevantKeysList = Arrays.asList(relevantKeys);

return allParameters.entrySet().stream()
.filter(entry -> relevantKeysList.contains(entry.getKey()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

/**
* Returns a key=value style text representation of this set, with parameter
* names as keys, and the result of calling {@code toString()} on parameter
Original file line number Diff line number Diff line change
@@ -113,11 +113,11 @@ public Builder addParameter(String name, Parameter<String> parameter) {

@Override
public Builder addParameter(
String name, Parameter<String> parameter, String defaultValue) {
String name, Parameter<String> parameter, String defaultValue) {
addParameterParser(
name,
(builder) -> builder.add(name, parameter, defaultValue),
(value, builder) -> builder.add(name, parameter, value));
name,
(builder) -> builder.add(name, parameter, defaultValue),
(value, builder) -> builder.add(name, parameter, value));
return this;
}

Loading