Skip to content

Commit

Permalink
Multi line shell
Browse files Browse the repository at this point in the history
  • Loading branch information
rylev committed Oct 14, 2020
1 parent abea944 commit 3f89163
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
components: rustfmt

- name: fmt
run:
run: |
cargo fmt --all -- --check
./scripts/check_json_format.sh
if: matrix.rust == 'nightly'
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

for f in sdk/*
do
echo "Publishing $f"
echo "Publishing $f"
cd $f
cargo publish
sleep 20
Expand Down
2 changes: 1 addition & 1 deletion sdk/key_vault/examples/backup_secret.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azure_identity::ClientSecretCredential;
use azure_key_vault::{KeyVaultClient, RecoveryLevel};
use azure_key_vault::KeyVaultClient;
use std::env;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion sdk/key_vault/examples/delete_secret.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azure_identity::ClientSecretCredential;
use azure_key_vault::{KeyVaultClient, RecoveryLevel};
use azure_key_vault::KeyVaultClient;
use std::env;

#[tokio::main]
Expand Down
6 changes: 1 addition & 5 deletions sdk/key_vault/examples/get_secret.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<<<<<<< HEAD:sdk/keyvault/examples/get_secret.rs
use azure_auth_aad::ClientSecretCredential;
use azure_keyvault::KeyVaultClient;
=======
use azure_identity::ClientSecretCredential;
use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/examples/get_secret.rs
use std::env;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion sdk/key_vault/examples/get_secret_versions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azure_identity::ClientSecretCredential;
use azure_key_vault::{KeyVaultClient, RecoveryLevel};
use azure_key_vault::KeyVaultClient;
use std::env;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion sdk/key_vault/examples/list_secrets.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azure_identity::ClientSecretCredential;
use azure_key_vault::{KeyVaultClient, RecoveryLevel};
use azure_key_vault::KeyVaultClient;
use std::env;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion sdk/key_vault/examples/restore_secret.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use azure_identity::ClientSecretCredential;
use azure_key_vault::{KeyVaultClient, RecoveryLevel};
use azure_key_vault::KeyVaultClient;
use std::env;

#[tokio::main]
Expand Down
6 changes: 1 addition & 5 deletions sdk/key_vault/examples/set_secret.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<<<<<<< HEAD:sdk/keyvault/examples/set_secret.rs
use azure_auth_aad::ClientSecretCredential;
use azure_keyvault::KeyVaultClient;
=======
use azure_identity::ClientSecretCredential;
use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/examples/set_secret.rs
use std::env;

#[tokio::main]
Expand Down
95 changes: 7 additions & 88 deletions sdk/key_vault/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@ pub(crate) const API_VERSION: &str = "7.0";
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/client.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
/// let creds = DefaultCredential::default();
/// let client = KeyVaultClient::new(&creds, &"test-keyvault");
=======
/// use azure_key_vault::KeyVaultClient;
/// let client = KeyVaultClient::new(&"{client_id}", &"{client_secret}", &"{tenant_id}", &"test-keyvault");
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/client.rs
/// use azure_identity::DefaultCredential;
/// let creds = DefaultCredential::default();
/// let client = KeyVaultClient::new(&creds, &"test-key-vault");
/// ```
#[derive(Debug)]
pub struct KeyVaultClient<'a, T> {
Expand All @@ -37,15 +32,10 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/client.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
/// use azure_key_vault::KeyVaultClient;
/// use azure_identity::DefaultCredential;
/// let creds = DefaultCredential::default();
/// let client = KeyVaultClient::with_endpoint_suffix(&creds, &"test-keyvault", "vault.azure.net".to_owned());
=======
/// use azure_key_vault::KeyVaultClient;
/// let client = KeyVaultClient::with_endpoint_suffix(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault", "vault.azure.net".to_owned());
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/client.rs
/// ```
pub fn with_endpoint_suffix(
token_credential: &'a T,
Expand All @@ -59,72 +49,6 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
endpoint_suffix,
keyvault_endpoint: endpoint,
token: None,
<<<<<<< HEAD:sdk/keyvault/src/client.rs
=======
token_expiration: None,
}
}

/// Creates a new `KeyVaultClient` with a pre-existing AAD token.
///
/// # Example
///
/// ```no_run
/// use azure_key_vault::KeyVaultClient;
/// use chrono::{Utc, Duration};
/// use oauth2::AccessToken;
/// let client = KeyVaultClient::with_aad_token(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault", AccessToken::new(String::new()), Utc::now() + Duration::days(14));
/// ```
pub fn with_aad_token(
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
aad_token: AccessToken,
aad_token_expiration: DateTime<Utc>,
) -> Self {
let endpoint = format!("https://{}.{}", keyvault_name, PUBLIC_ENDPOINT_SUFFIX);
Self {
aad_client_id,
aad_client_secret,
aad_tenant_id,
keyvault_name,
endpoint_suffix: PUBLIC_ENDPOINT_SUFFIX.to_owned(),
keyvault_endpoint: endpoint,
token: Some(aad_token),
token_expiration: Some(aad_token_expiration),
}
}

/// Creates a new `KeyVaultClient` with a pre-existing AAD token.
///
/// # Example
///
/// ```no_run
/// use azure_key_vault::KeyVaultClient;
/// use chrono::{Utc, Duration};
/// use oauth2::AccessToken;
/// let client = KeyVaultClient::with_aad_token(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault", AccessToken::new(String::new()), Utc::now() + Duration::days(14));
/// ```
pub fn with_aad_token_and_endpoint_suffix(
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
aad_token: AccessToken,
aad_token_expiration: DateTime<Utc>,
) -> Self {
let endpoint = format!("https://{}.{}", keyvault_name, PUBLIC_ENDPOINT_SUFFIX);
Self {
aad_client_id,
aad_client_secret,
aad_tenant_id,
keyvault_name,
endpoint_suffix: PUBLIC_ENDPOINT_SUFFIX.to_owned(),
keyvault_endpoint: endpoint,
token: Some(aad_token),
token_expiration: Some(aad_token_expiration),
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/client.rs
}
}

Expand All @@ -133,15 +57,10 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/client.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
/// use azure_key_vault::KeyVaultClient;
/// use azure_identity::DefaultCredential;
/// let creds = DefaultCredential::default();
/// let client = KeyVaultClient::new(&creds, &"test-keyvault");
=======
/// use azure_key_vault::KeyVaultClient;
/// let client = KeyVaultClient::new(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault");
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/client.rs
/// ```
pub fn new(token_credential: &'a T, keyvault_name: &'a str) -> Self {
KeyVaultClient::with_endpoint_suffix(
Expand Down
72 changes: 14 additions & 58 deletions sdk/key_vault/src/secret.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::KeyVaultClient;
use crate::{client::API_VERSION, KeyVaultError};
use anyhow::{Context, Result};
use azure_auth_aad::TokenCredential;
use azure_identity::TokenCredential;
use chrono::serde::ts_seconds;
use chrono::{DateTime, Utc};
use getset::Getters;
Expand Down Expand Up @@ -113,12 +113,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -146,12 +142,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -194,12 +186,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// Lists all the secrets in the Key Vault.
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -259,12 +247,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -335,12 +319,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -388,12 +368,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -433,12 +409,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::{KeyVaultClient, RecoveryLevel};
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::{KeyVaultClient, RecoveryLevel};
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -481,12 +453,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::{KeyVaultClient, RecoveryLevel};
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::{KeyVaultClient, RecoveryLevel};
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
/// use chrono::{Utc, Duration};
///
Expand Down Expand Up @@ -549,12 +517,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -593,12 +557,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::KeyVaultClient;
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::KeyVaultClient;
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -646,12 +606,8 @@ impl<'a, T: TokenCredential> KeyVaultClient<'a, T> {
/// # Example
///
/// ```no_run
<<<<<<< HEAD:sdk/keyvault/src/secret.rs
/// use azure_keyvault::{KeyVaultClient, RecoveryLevel};
/// use azure_auth_aad::DefaultCredential;
=======
/// use azure_key_vault::{KeyVaultClient, RecoveryLevel};
>>>>>>> Rename keyvault to key_vault:sdk/key_vault/src/secret.rs
/// use azure_identity::DefaultCredential;
/// use tokio::runtime::Runtime;
///
/// async fn example() {
Expand Down Expand Up @@ -684,8 +640,8 @@ mod tests {
use super::*;

use async_trait;
use azure_auth_aad::{TokenCredential, TokenResponse};
use azure_sdk_core::errors::AzureError;
use azure_core::errors::AzureError;
use azure_identity::{TokenCredential, TokenResponse};
use chrono::{Duration, Utc};
use mockito::{mock, Matcher};
use oauth2::AccessToken;
Expand Down

0 comments on commit 3f89163

Please sign in to comment.