-
Notifications
You must be signed in to change notification settings - Fork 330
Migrate keyvault to pipeline #962
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8548e15
move keyvault to pipelines
demoray a1adf8d
remove reqwest from prereq
demoray ff4c7d7
fmt
demoray e21f0d8
Merge branch 'main' into migrate-keyvault-to-pipeline
demoray 448f835
update to use streams instead of internal loops
demoray 5958f9b
rename structs per previous pr feedback
demoray ec732de
use more direct responses
demoray 7982df1
fix doc tests
demoray f848611
remove debugging println
demoray 2f8cb71
remove unused feature
demoray c8b4f4d
Merge branch 'main' into migrate-keyvault-to-pipeline
demoray 67a9b36
address feedback
demoray 979893d
remove debug print
demoray af80079
remove endpoint as it's not needed anymore
demoray 2ed2fe7
remove extra clone
demoray c41de36
use core's TimeoutPolicy
demoray 482f2e8
address comments
demoray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,25 +1,19 @@ | ||
| use azure_identity::{ClientSecretCredential, TokenCredentialOptions}; | ||
| use azure_identity::DefaultAzureCredentialBuilder; | ||
| use azure_security_keyvault::SecretClient; | ||
| use std::env; | ||
| use std::sync::Arc; | ||
| use std::{env, sync::Arc}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let client_id = env::var("CLIENT_ID").expect("Missing CLIENT_ID environment variable."); | ||
| let client_secret = | ||
| env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET environment variable."); | ||
| let tenant_id = env::var("TENANT_ID").expect("Missing TENANT_ID environment variable."); | ||
| let keyvault_url = | ||
| env::var("KEYVAULT_URL").expect("Missing KEYVAULT_URL environment variable."); | ||
| let secret_name = env::var("SECRET_NAME").expect("Missing SECRET_NAME environment variable."); | ||
|
|
||
| let creds = Arc::new(ClientSecretCredential::new( | ||
| azure_core::new_http_client(), | ||
| tenant_id, | ||
| client_id, | ||
| client_secret, | ||
| TokenCredentialOptions::default(), | ||
| )); | ||
| let creds = Arc::new( | ||
| DefaultAzureCredentialBuilder::new() | ||
| .exclude_managed_identity_credential() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is always excluded in our examples, should we perhaps think about inverting this and requiring users who want it, to opt into it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #1016 |
||
| .build(), | ||
| ); | ||
|
|
||
| let client = SecretClient::new(&keyvault_url, creds)?; | ||
| client.delete(secret_name).into_future().await?; | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,28 +1,25 @@ | ||
| use azure_identity::{ClientSecretCredential, TokenCredentialOptions}; | ||
| use azure_identity::DefaultAzureCredentialBuilder; | ||
| use azure_security_keyvault::SecretClient; | ||
| use std::env; | ||
| use std::sync::Arc; | ||
| use futures::stream::StreamExt; | ||
| use std::{env, sync::Arc}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let client_id = env::var("CLIENT_ID").expect("Missing CLIENT_ID environment variable."); | ||
| let client_secret = | ||
| env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET environment variable."); | ||
| let tenant_id = env::var("TENANT_ID").expect("Missing TENANT_ID environment variable."); | ||
| async fn main() -> azure_core::Result<()> { | ||
| let keyvault_url = | ||
| env::var("KEYVAULT_URL").expect("Missing KEYVAULT_URL environment variable."); | ||
|
|
||
| let creds = Arc::new(ClientSecretCredential::new( | ||
| azure_core::new_http_client(), | ||
| tenant_id, | ||
| client_id, | ||
| client_secret, | ||
| TokenCredentialOptions::default(), | ||
| )); | ||
| let creds = Arc::new( | ||
| DefaultAzureCredentialBuilder::new() | ||
| .exclude_managed_identity_credential() | ||
| .build(), | ||
| ); | ||
|
|
||
| let client = SecretClient::new(&keyvault_url, creds)?; | ||
|
|
||
| let secrets = client.list_secrets().into_future().await?; | ||
| dbg!(&secrets); | ||
| let mut stream = client.list_secrets().into_stream(); | ||
| while let Some(response) = stream.next().await { | ||
| dbg!(&response?); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.