-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from mikeee/implement-bulksecret-retrieval
Implement bulksecret retrieval
- Loading branch information
Showing
7 changed files
with
140 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Before you run the example make sure local redis state store is running by executing: | ||
``` | ||
docker ps | ||
``` | ||
|
||
1. To run the example we need to first build the examples using the following command: | ||
|
||
``` | ||
cargo build --examples | ||
``` | ||
|
||
2. Run the example with dapr using the following command: | ||
|
||
<!-- STEP | ||
name: Run app example | ||
output_match_mode: substring | ||
match_order: none | ||
expected_stdout_lines: | ||
- '== APP == Found secret1 with value: TestSecret1' | ||
- '== APP == Found secret2 with value: TestSecret2' | ||
- '== APP == Found secret3 with value: TestSecret3' | ||
background: true | ||
sleep: 15 | ||
timeout_seconds: 30 | ||
--> | ||
|
||
```bash | ||
dapr run --app-id=rustapp --dapr-grpc-port 3500 --resources-path ./resources/ cargo run -- --example secrets-bulk | ||
``` | ||
|
||
<!-- END_STEP --> | ||
|
||
If everything went well you should see the following output along with dapr logs: | ||
``` | ||
== APP == Found secret1 with value: TestSecret1 | ||
== APP == Found secret2 with value: TestSecret2 | ||
== APP == Found secret3 with value: TestSecret3 | ||
``` | ||
_Note: The order of the secrets returned is not ordered_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// Get the Dapr port and create a connection | ||
let port: u16 = std::env::var("DAPR_GRPC_PORT")?.parse()?; | ||
let addr = format!("https://127.0.0.1:{}", port); | ||
|
||
// Create the client | ||
let mut client = dapr::Client::<dapr::client::TonicClient>::connect(addr).await?; | ||
|
||
let secret_store = "localsecretstore"; | ||
|
||
let secrets_response = client.get_bulk_secret(secret_store, None).await?; | ||
|
||
for (secret_name, secret_content) in &secrets_response.data { | ||
println!( | ||
"Found {} with value: {}", | ||
secret_name, | ||
&secret_content.secrets.get(secret_name).unwrap() | ||
); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: Component | ||
metadata: | ||
name: localsecretstore | ||
namespace: default | ||
spec: | ||
type: secretstores.local.file | ||
version: v1 | ||
metadata: | ||
- name: secretsFile | ||
value: secrets.json | ||
- name: nestedSeparator | ||
value: ":" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"secret1": "TestSecret1", | ||
"secret2": "TestSecret2", | ||
"secret3": "TestSecret3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters