id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:3 | pub(crate) struct PropertiesKeyBuilder {
section_key: Option<SectionKey>,
section_name: Option<SectionName>,
property_name: Option<PropertyName>,
sub_property_name: Option<SubPropertyName>,
}
impl PropertiesKeyBuilder {
pub(crate) fn section_key(mut self, section_key: impl Into<String>) -> Self {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:4 | })
}
}
#[allow(clippy::type_complexity)]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub(crate) struct Properties {
inner: HashMap<PropertiesKey, PropertyValue>,
}
#[allow(dead_code)]
impl Properties {
pub(crate) fn new() -> Self {
Default::default()
}
pub(crate) fn insert(&mut self, ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:5 | /// Returns a reference to the property named `name`
fn get(&self, name: &str) -> Option<&str>;
/// True if there are no properties in this section.
fn is_empty(&self) -> bool;
/// Insert a property into a section
fn insert(&mut self, name: String, value: Property);
}
#[derive(Debug, Clone, Eq, P... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:6 | }
/// An individual configuration profile
///
/// An AWS config may be composed of a multiple named profiles within a [`ProfileSet`](crate::profile::ProfileSet).
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Profile(SectionInner);
impl Profile {
/// Create a new profile
pub fn new(name: impl Into<String>,... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:7 | fn is_empty(&self) -> bool {
self.0.is_empty()
}
fn insert(&mut self, name: String, value: Property) {
self.0.insert(name, value)
}
}
/// A `[sso-session name]` section in the config.
#[derive(Debug, Clone, Eq, PartialEq)]
pub(crate) struct SsoSession(SectionInner);
impl SsoSession {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:8 | }
fn is_empty(&self) -> bool {
self.0.is_empty()
}
fn insert(&mut self, name: String, value: Property) {
self.0.insert(name, value)
}
}
#[cfg(test)]
mod test {
use super::PropertiesKey;
use crate::provider_config::ProviderConfig;
use aws_types::os_shim_internal::{Env, Fs};... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:9 | let provider_config = ProviderConfig::no_configuration().with_env(env).with_fs(fs);
let p = provider_config.try_profile().await.unwrap();
let other_sections = p.other_sections();
assert_eq!(
"http://localhost:3000",
other_sections
.get(&PropertiesKey {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 321 | 380 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/section.rs:10 | assert_eq!(
"http://localhost:2000",
other_sections
.get(&PropertiesKey {
section_key: "services".to_owned(),
section_name: "foo".to_owned(),
property_name: "ec2".to_owned(),
sub_property_name: Some("... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/section.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/section.rs | 361 | 407 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use super::error::{CouldNotReadProfileFile, ProfileFileLoadError};
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_smithy_typ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | /// Load a [`Source`] from a given environment and filesystem.
pub(super) async fn load(
proc_env: &os_shim_internal::Env,
fs: &os_shim_internal::Fs,
profile_files: &ProfileFiles,
) -> Result<Source, ProfileFileLoadError> {
let home = home_dir(proc_env, Os::real());
let mut files = Vec::new();
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | ///
/// Arguments:
/// * `kind`: The type of config file to load
/// * `home_directory`: Home directory to use during home directory expansion
/// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
source: &ProfileFile,
home_directory: &Option<String>,... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | }
};
Default::default()
}
};
let contents = file_contents_to_string(&expanded, data);
(Some(Cow::Owned(expanded)), kind, contents)
}
ProfileFile::FilePath { kind, path } => {
let data = match fs.read_... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | home_dir: &Option<String>,
) -> PathBuf {
let path = path.as_ref();
let mut components = path.components();
let start = components.next();
match start {
None => path.into(), // empty path,
Some(Component::Normal(s)) if s == "~" => {
// do homedir replacement
let p... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | use crate::profile::parser::source::{
expand_home, load, load_config_file, HOME_EXPANSION_FAILURE_WARNING,
};
use crate::profile::parser::ProfileFileLoadError;
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_types::os_shim_internal::{Env, Fs};
use futu... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | /// Run all tests from file-location-tests.json
#[test]
fn run_tests() -> Result<(), Box<dyn Error>> {
let tests = fs::read_to_string("test-data/file-location-tests.json")?;
let tests: SourceTests = serde_json::from_str(&tests)?;
for (i, test) in tests.tests.into_iter().enumerate() {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | &fs,
&env,
)
.now_or_never();
assert!(!logs_contain(HOME_EXPANSION_FAILURE_WARNING));
}
#[traced_test]
#[test]
fn load_config_file_should_emit_warning_when_path_explicitly_set() {
let env = Env::from_slice(&[("AWS_CONFIG_FILE", "~/some/path")]);
let f... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | source.files[1].path,
Some(test_case.credentials_location),
"{}",
&test_case.name
)
} else {
println!(
"NOTE: ignoring test case for {} which does not apply to our platform: \n {}",
&test_case.platform, &tes... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 321 | 380 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:10 | }
/// Test that a linux oriented path expands on windows
#[test]
#[cfg_attr(not(windows), ignore)]
fn test_expand_home_windows() {
let path = "~/.aws/config";
assert_eq!(
expand_home(path, true, &Some("C:\\Users\\name".to_string()),)
.to_str()
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 361 | 420 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:11 | "/custom/path/to/credentials".to_string(),
contents.to_string(),
);
let fs = Fs::from_map(fs);
let env = Env::from_slice(&[]);
let profile_files = ProfileFiles::builder()
.with_file(ProfileFileKind::Credentials, "/custom/path/to/credentials")
.build()... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 401 | 460 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:12 | let profile_files = ProfileFiles::builder()
.with_contents(ProfileFileKind::Config, custom_contents)
.include_default_credentials_file(true)
.include_default_config_file(true)
.build();
let source = load(&env, &fs, &profile_files).await.unwrap();
assert_eq... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 02aa74d2aac3b5cc8dfdd9437bd29983ca385851 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/02aa74d2aac3b5cc8dfdd9437bd29983ca385851/sdk/aws-config/src/profile/parser/source.rs | 441 | 488 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:10 | }
/// Test that a linux oriented path expands on windows
#[test]
#[cfg_attr(not(windows), ignore)]
fn test_expand_home_windows() {
let path = "~/.aws/config";
assert_eq!(
expand_home(path, true, &Some("C:\\Users\\name".to_string()),)
.to_str()
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/source.rs | 361 | 420 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:11 | "/custom/path/to/credentials".to_string(),
contents.to_string(),
);
let fs = Fs::from_map(fs);
let env = Env::from_slice(&[]);
let profile_files = ProfileFiles::builder()
.with_file(ProfileFileKind::Credentials, "/custom/path/to/credentials")
.build()... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/source.rs | 401 | 460 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:12 | .include_default_credentials_file(true)
.include_default_config_file(true)
.build();
let source = load(&env, &fs, &profile_files).await.unwrap();
assert_eq!(3, source.files.len());
assert_eq!("default", source.profile);
assert_eq!(config_contents, source.files[0].... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b398003223f16ed4e63ca33a46660f1bf15b84f1 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b398003223f16ed4e63ca33a46660f1bf15b84f1/sdk/aws-config/src/profile/parser/source.rs | 441 | 486 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use crate::profile::parser::{CouldNotReadProfileFile, ProfileFileLoadError};
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a0ddad15fca029a888f717b770fda078541546c4 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a0ddad15fca029a888f717b770fda078541546c4/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use crate::profile::parser::{CouldNotReadProfileFile, ProfileFileLoadError};
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b4a7b881b8735aad288284e1c140ed40f474d06 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | /// Load a [Source](Source) from a given environment and filesystem.
pub(super) async fn load(
proc_env: &os_shim_internal::Env,
fs: &os_shim_internal::Fs,
profile_files: &ProfileFiles,
) -> Result<Source, ProfileFileLoadError> {
let home = home_dir(proc_env, Os::real());
let mut files = Vec::new()... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b4a7b881b8735aad288284e1c140ed40f474d06 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | home_dir: &Option<String>,
) -> PathBuf {
let path = path.as_ref();
let mut components = path.components();
let start = components.next();
match start {
None => path.into(), // empty path,
Some(Component::Normal(s)) if s == "~" => {
// do homedir replacement
let p... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | f2ad26a064e6748aa85c2e16eec274ea24b4e2ab | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/f2ad26a064e6748aa85c2e16eec274ea24b4e2ab/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | use crate::profile::parser::source::{
expand_home, load, load_config_file, HOME_EXPANSION_FAILURE_WARNING,
};
use crate::profile::parser::ProfileFileLoadError;
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_types::os_shim_internal::{Env, Fs};
use futu... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | f2ad26a064e6748aa85c2e16eec274ea24b4e2ab | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/f2ad26a064e6748aa85c2e16eec274ea24b4e2ab/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | &fs,
&env,
)
.now_or_never();
assert!(!logs_contain(HOME_EXPANSION_FAILURE_WARNING));
}
#[traced_test]
#[test]
fn load_config_file_should_emit_warning_when_path_explicitly_set() {
let env = Env::from_slice(&[("AWS_CONFIG_FILE", "~/some/path")]);
let f... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | f2ad26a064e6748aa85c2e16eec274ea24b4e2ab | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/f2ad26a064e6748aa85c2e16eec274ea24b4e2ab/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | source.files[1].path,
Some(test_case.credentials_location),
"{}",
&test_case.name
)
} else {
println!(
"NOTE: ignoring test case for {} which does not apply to our platform: \n {}",
&test_case.platform, &tes... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | f2ad26a064e6748aa85c2e16eec274ea24b4e2ab | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/f2ad26a064e6748aa85c2e16eec274ea24b4e2ab/sdk/aws-config/src/profile/parser/source.rs | 321 | 380 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:10 | }
/// Test that a linux oriented path expands on windows
#[test]
#[cfg_attr(not(windows), ignore)]
fn test_expand_home_windows() {
let path = "~/.aws/config";
assert_eq!(
expand_home(&path, true, &Some("C:\\Users\\name".to_string()),)
.to_str()
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | f2ad26a064e6748aa85c2e16eec274ea24b4e2ab | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/f2ad26a064e6748aa85c2e16eec274ea24b4e2ab/sdk/aws-config/src/profile/parser/source.rs | 361 | 420 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use crate::profile::credentials::{CouldNotReadProfileFile, ProfileFileError};
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_s... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | fs: &os_shim_internal::Fs,
profile_files: &ProfileFiles,
) -> Result<Source, ProfileFileError> {
let home = home_dir(proc_env, Os::real());
let mut files = Vec::new();
for file in &profile_files.files {
let file = load_config_file(file, &home, fs, proc_env)
.instrument(tracing::debu... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// * `home_directory`: Home directory to use during home directory expansion
/// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
source: &ProfileFile,
home_directory: &Option<String>,
fs: &os_shim_internal::Fs,
environment: &os_shim_interna... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | }
};
let contents = file_contents_to_string(&expanded, data);
(Some(Cow::Owned(expanded)), kind, contents)
}
ProfileFile::FilePath { kind, path } => {
let data = match fs.read_to_end(&path).await {
Ok(data) => data,
Err(e) =... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | let mut components = path.components();
let start = components.next();
match start {
None => path.into(), // empty path,
Some(Component::Normal(s)) if s == "~" => {
// do homedir replacement
let path = match home_dir {
Some(dir) => {
tr... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | };
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_types::os_shim_internal::{Env, Fs};
use futures_util::FutureExt;
use serde::Deserialize;
use std::collections::HashMap;
use std::error::Error;
use std::fs;
use tracing_test::traced_test;
#[tes... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | let tests = fs::read_to_string("test-data/file-location-tests.json")?;
let tests: SourceTests = serde_json::from_str(&tests)?;
for (i, test) in tests.tests.into_iter().enumerate() {
eprintln!("test: {}", i);
check(test)
.now_or_never()
.expect("the... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | .now_or_never();
assert!(!logs_contain(HOME_EXPANSION_FAILURE_WARNING));
}
#[traced_test]
#[test]
fn load_config_file_should_emit_warning_when_path_explicitly_set() {
let env = Env::from_slice(&[("AWS_CONFIG_FILE", "~/some/path")]);
let fs = Fs::from_slice(&[]);
let _sr... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | &test_case.name
)
} else {
println!(
"NOTE: ignoring test case for {} which does not apply to our platform: \n {}",
&test_case.platform, &test_case.name
)
}
}
#[test]
#[cfg_attr(windows, ignore)]
fn test_expand_home() ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 321 | 380 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:10 | #[test]
#[cfg_attr(not(windows), ignore)]
fn test_expand_home_windows() {
let path = "~/.aws/config";
assert_eq!(
expand_home(&path, true, &Some("C:\\Users\\name".to_string()),)
.to_str()
.unwrap(),
"C:\\Users\\name\\.aws\\config"
)... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 361 | 420 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:11 | let fs = Fs::from_map(fs);
let env = Env::from_slice(&[]);
let profile_files = ProfileFiles::builder()
.with_file(ProfileFileKind::Credentials, "/custom/path/to/credentials")
.build();
let source = load(&env, &fs, &profile_files).await.unwrap();
assert_eq!(1, sour... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 401 | 460 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:12 | let source = load(&env, &fs, &profile_files).await.unwrap();
assert_eq!(3, source.files.len());
assert_eq!("default", source.profile);
assert_eq!(config_contents, source.files[0].contents);
assert_eq!(credentials_contents, source.files[1].contents);
assert_eq!(custom_contents, so... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 10fe75faa5af6b46fe6e065e027dae9b0024c645 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/10fe75faa5af6b46fe6e065e027dae9b0024c645/sdk/aws-config/src/profile/parser/source.rs | 441 | 483 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use crate::profile::credentials::{CouldNotReadProfileFile, ProfileFileError};
use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_t... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | profile_files: &ProfileFiles,
) -> Result<Source, ProfileFileError> {
let home = home_dir(proc_env, Os::real());
let mut files = Vec::new();
for file in &profile_files.files {
let file = load_config_file(file, &home, fs, proc_env)
.instrument(tracing::debug_span!("load_config_file", fil... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
source: &ProfileFile,
home_directory: &Option<String>,
fs: &os_shim_internal::Fs,
environment: &os_shim_internal::Env,
) -> Result<File, ProfileFileError> {
let (path, kind, contents) =... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | };
let contents = file_contents_to_string(&expanded, data);
(Some(Cow::Owned(expanded)), kind, contents)
}
ProfileFile::FilePath { kind, path } => {
let data = match fs.read_to_end(&path).await {
Ok(data) => data,
Err(e) => {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | let start = components.next();
match start {
None => path.into(), // empty path,
Some(Component::Normal(s)) if s == "~" => {
// do homedir replacement
let path = match home_dir {
Some(dir) => {
tracing::debug!(home = ?dir, path = ?path, "pe... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles};
use aws_types::os_shim_internal::{Env, Fs};
use futures_util::FutureExt;
use serde::Deserialize;
use std::collections::HashMap;
use std::error::Error;
use std::fs;
use tracing_test::traced_test;
#[test]
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | let tests: SourceTests = serde_json::from_str(&tests)?;
for (i, test) in tests.tests.into_iter().enumerate() {
eprintln!("test: {}", i);
check(test)
.now_or_never()
.expect("these futures should never poll");
}
Ok(())
}
#[traced_te... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | assert!(!logs_contain(HOME_EXPANSION_FAILURE_WARNING));
}
#[traced_test]
#[test]
fn load_config_file_should_emit_warning_when_path_explicitly_set() {
let env = Env::from_slice(&[("AWS_CONFIG_FILE", "~/some/path")]);
let fs = Fs::from_slice(&[]);
let _src = load_config_file(
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | )
} else {
println!(
"NOTE: ignoring test case for {} which does not apply to our platform: \n {}",
&test_case.platform, &test_case.name
)
}
}
#[test]
#[cfg_attr(windows, ignore)]
fn test_expand_home() {
let path = "~/.aws... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 321 | 380 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:10 | #[cfg_attr(not(windows), ignore)]
fn test_expand_home_windows() {
let path = "~/.aws/config";
assert_eq!(
expand_home(&path, true, &Some("C:\\Users\\name".to_string()),)
.to_str()
.unwrap(),
"C:\\Users\\name\\.aws\\config"
);
}
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 361 | 420 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:11 | let fs = Fs::from_map(fs);
let env = Env::from_slice(&[]);
let profile_files = ProfileFiles::builder()
.with_file(ProfileFileKind::Credentials, "/custom/path/to/credentials")
.build();
let source = load(&env, &fs, &profile_files).await.unwrap();
assert_eq!(1, sour... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 401 | 460 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:12 | assert_eq!(3, source.files.len());
assert_eq!("default", source.profile);
assert_eq!(config_contents, source.files[0].contents);
assert_eq!(credentials_contents, source.files[1].contents);
assert_eq!(custom_contents, source.files[2].contents);
}
#[tokio::test]
async fn defau... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | a5211e5fddac2489f076ac62a629feb96e43a003 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/a5211e5fddac2489f076ac62a629feb96e43a003/sdk/aws-config/src/profile/parser/source.rs | 441 | 482 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::{warn, Instrument};
const HOME_... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | }
impl FileKind {
fn default_path(&self) -> &'static str {
match &self {
FileKind::Credentials => "~/.aws/credentials",
FileKind::Config => "~/.aws/config",
}
}
fn override_environment_variable(&self) -> &'static str {
match &self {
FileKind::Con... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// Both the default & the overriding patterns may contain `~/` which MUST be expanded to the users
/// home directory in a platform-aware way (see [`expand_home`](expand_home))
///
/// Arguments:
/// * `kind`: The type of config file to load
/// * `home_directory`: Home directory to use during home directory expansion... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | }
};
// if the file is not valid utf-8, log a warning and use an empty file instead
let data = match String::from_utf8(data) {
Ok(data) => data,
Err(e) => {
tracing::warn!(path = %path, error = %e, "config file did not contain utf-8 encoded data");
Default::default()
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | // if we can't determine the home directory, just leave it as `~`
"~".into()
}
};
let mut path: PathBuf = path.into();
// rewrite the path using system-specific path separators
for component in components {
path.push(com... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | }
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct SourceTests {
tests: Vec<TestCase>,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct TestCase {
name: String,
environment: HashMap<String, String>,
platform: S... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | "[default]\nregion = us-east-1",
);
let fs = Fs::from_map(fs);
let _src = load(&env, &fs).now_or_never();
assert!(logs_contain("config file loaded"));
assert!(logs_contain("performing home directory substitution"));
}
#[traced_test]
#[test]
fn load_config_file_... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | assert_eq!(
source.config_file.path, test_case.config_location,
"{}",
&test_case.name
);
assert_eq!(
source.credentials_file.path, test_case.credentials_location,
"{}",
&test_case.name
)
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | assert_eq!(
expand_home("~/config", false, &None).to_str().unwrap(),
"~\\config"
)
}
}
/// Test that a linux oriented path expands on windows
#[test]
#[cfg_attr(not(windows), ignore)]
fn test_expand_home_windows() {
let path = "~/.aws/conf... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/bd8049d6e9a4d67fa5e3ce4eddf4d8a53beb915a/sdk/aws-config/src/profile/parser/source.rs | 321 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::Instrument;
/// In-memory sourc... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | match &self {
FileKind::Credentials => "~/.aws/credentials",
FileKind::Config => "~/.aws/config",
}
}
fn override_environment_variable(&self) -> &'static str {
match &self {
FileKind::Config => "AWS_CONFIG_FILE",
FileKind::Credentials => "AWS_SHAR... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// * `kind`: The type of config file to load
/// * `home_directory`: Home directory to use during home directory expansion
/// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
kind: FileKind,
home_directory: &Option<String>,
fs: &os_shim_interna... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | Ok(data) => data,
Err(e) => {
tracing::warn!(path = %path, error = %e, "config file did not contain utf-8 encoded data");
Default::default()
}
};
tracing::debug!(path = %path, size = ?data.len(), "config file loaded");
File {
// lossy is OK here, the name of t... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | );
}
// if we can't determine the home directory, just leave it as `~`
"~".into()
}
};
let mut path: PathBuf = path.into();
// rewrite the path using system-specific path separators
for component ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | // ~ is only expanded as a single component (currently)
let path = "~aws/config";
let environment = Env::from_slice(&[]);
assert_eq!(
expand_home(&path, &None, &environment).to_str().unwrap(),
"~aws/config"
);
}
#[derive(Deserialize, Debug)]
#[serde(r... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | use futures_util::FutureExt;
use tracing_test::traced_test;
#[traced_test]
#[test]
fn logs_produced_default() {
let env = Env::from_slice(&[("HOME", "/user/name")]);
let mut fs = HashMap::new();
fs.insert(
"/user/name/.aws/config".to_string(),
"[default]\... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | assert_eq!(source.profile, expected_profile, "{}", &test_case.name);
}
assert_eq!(
source.config_file.path, test_case.config_location,
"{}",
&test_case.name
);
assert_eq!(
source.credentials_file.path, test_c... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | expand_home("~/config", &None, &environment)
.to_str()
.unwrap(),
"~/config"
)
} else {
assert_eq!(
expand_home("~/config", &None, &environment)
.to_str()
.unwrap(),
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 2b49763874a0e2e04ef2f101b047d39ea49140a2 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/2b49763874a0e2e04ef2f101b047d39ea49140a2/sdk/aws-config/src/profile/parser/source.rs | 321 | 349 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use crate::fs_util::{home_dir, Os};
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::Instrument;
/// In-memory sourc... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 8159cb8ff570e4dca718e354c31cecdfadfeb0b8 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | match &self {
FileKind::Credentials => "~/.aws/credentials",
FileKind::Config => "~/.aws/config",
}
}
fn override_environment_variable(&self) -> &'static str {
match &self {
FileKind::Config => "AWS_CONFIG_FILE",
FileKind::Credentials => "AWS_SHAR... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 8159cb8ff570e4dca718e354c31cecdfadfeb0b8 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use crate::fs_util::{home_dir, Os};
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::Instrument;
/// In-memory sour... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | d0c34c38890d36de24c4ba4004253efd83fa26c6 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/d0c34c38890d36de24c4ba4004253efd83fa26c6/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | );
}
// if we can't determine the home directory, just leave it as `~`
"~".into()
}
};
let mut path: PathBuf = path.into();
// rewrite the path using system-specific path separators
for component ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | fd1513091b220e4f4138ea0084650e3712b29840 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/fd1513091b220e4f4138ea0084650e3712b29840/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | use futures_util::FutureExt;
use tracing_test::traced_test;
#[traced_test]
#[test]
fn logs_produced_default() {
let env = Env::from_slice(&[("HOME", "/user/name")]);
let mut fs = HashMap::new();
fs.insert(
"/user/name/.aws/config".to_string(),
"[default]\... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | fd1513091b220e4f4138ea0084650e3712b29840 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/fd1513091b220e4f4138ea0084650e3712b29840/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use crate::fs_util::{home_dir, Os};
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::Instrument;
/// In-memory sour... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b81528930844c611db098b340489915c627a0603 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b81528930844c611db098b340489915c627a0603/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | match &self {
FileKind::Credentials => "~/.aws/credentials",
FileKind::Config => "~/.aws/config",
}
}
fn override_environment_variable(&self) -> &'static str {
match &self {
FileKind::Config => "AWS_CONFIG_FILE",
FileKind::Credentials => "AWS_SHAR... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b81528930844c611db098b340489915c627a0603 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b81528930844c611db098b340489915c627a0603/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// * `kind`: The type of config file to load
/// * `home_directory`: Home directory to use during home directory expansion
/// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
kind: FileKind,
home_directory: &Option<String>,
fs: &os_shim_interna... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b81528930844c611db098b340489915c627a0603 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b81528930844c611db098b340489915c627a0603/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | Ok(data) => data,
Err(e) => {
tracing::warn!(path = %path, error = %e, "config file did not contain utf-8 encoded data");
Default::default()
}
};
tracing::info!(path = %path, size = ?data.len(), "config file loaded");
File {
// lossy is OK here, the name of th... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b81528930844c611db098b340489915c627a0603 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b81528930844c611db098b340489915c627a0603/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | );
}
// if we can't determine the home directory, just leave it as `~`
"~".into()
}
};
let mut path: PathBuf = path.into();
// rewrite the path using system-specific path separators
for component ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | b81528930844c611db098b340489915c627a0603 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/b81528930844c611db098b340489915c627a0603/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::Instrument;
/// In-memory source of profile data
pub struct Source... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | FileKind::Credentials => "~/.aws/credentials",
FileKind::Config => "~/.aws/config",
}
}
fn override_environment_variable(&self) -> &'static str {
match &self {
FileKind::Config => "AWS_CONFIG_FILE",
FileKind::Credentials => "AWS_SHARED_CREDENTIALS_FILE",
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// * `home_directory`: Home directory to use during home directory expansion
/// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
kind: FileKind,
home_directory: &Option<String>,
fs: &os_shim_internal::Fs,
environment: &os_shim_internal::Env... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | Err(e) => {
tracing::warn!(path = %path, error = %e, "config file did not contain utf-8 encoded data");
Default::default()
}
};
tracing::info!(path = %path, size = ?data.len(), "config file loaded");
File {
// lossy is OK here, the name of this file is just for debugg... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | }
// if we can't determine the home directory, just leave it as `~`
"~".into()
}
};
let mut path: PathBuf = path.into();
// rewrite the path using system-specific path separators
for component in components {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | }
}
/// Resolve a home directory given a set of environment variables
fn home_dir(env_var: &os_shim_internal::Env, os: Os) -> Option<String> {
if let Ok(home) = env_var.get("HOME") {
tracing::debug!(src = "HOME", "loaded home directory");
return Some(home);
}
if os == Os::Windows {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | assert_eq!(source.profile, expected_profile, "{}", &test_case.name);
}
assert_eq!(
source.config_file.path, test_case.config_location,
"{}",
&test_case.name
);
assert_eq!(
source.credentials_file.path, test_c... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 321 | 380 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:10 | );
assert_eq!(home_dir(&env, Os::NotWindows), None);
}
#[test]
fn expand_home_no_home() {
let environment = Env::from_slice(&[]);
// there is an edge case around expansion when no home directory exists
// if no home directory can be determined, leave the path as is
i... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 35105d745c9ad8399f112b4a4868804e3b7cfcb0 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/35105d745c9ad8399f112b4a4868804e3b7cfcb0/sdk/aws-config/src/profile/parser/source.rs | 361 | 400 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:2 | FileKind::Credentials => "~/.aws/credentials",
FileKind::Config => "~/.aws/config",
}
}
fn override_environment_variable(&self) -> &'static str {
match &self {
FileKind::Config => "AWS_CONFIG_FILE",
FileKind::Credentials => "AWS_SHARED_CREDENTIALS_FILE",
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 41 | 100 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:3 | /// * `home_directory`: Home directory to use during home directory expansion
/// * `fs`: Filesystem abstraction
/// * `environment`: Process environment abstraction
async fn load_config_file(
kind: FileKind,
home_directory: &Option<String>,
fs: &os_shim_internal::Fs,
environment: &os_shim_internal::Env... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 81 | 140 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:4 | Err(e) => {
tracing::warn!(path = %path, error = %e, "config file did not contain utf-8 encoded data");
Default::default()
}
};
tracing::info!(path = %path, size = ?data.len(), "config file loaded");
File {
// lossy is OK here, the name of this file is just for debugg... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 121 | 180 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:5 | }
// Finally, handle the case where it doesn't begin with some version of `~/`:
// NOTE: in this case we aren't performing path rewriting. This is correct because
// this path comes from an environment variable on the target
// platform, so in that case, the separators should already be ... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 161 | 220 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:6 | if let (Ok(mut drive), Ok(path)) = (home_drive, home_path) {
drive.push_str(&path);
return Some(drive);
}
}
None
}
#[cfg(test)]
mod tests {
use crate::profile::parser::source::{expand_home, home_dir, load, Os};
use aws_types::os_shim_internal::{Env, Fs};
use serde::D... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 201 | 260 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:7 | /// Run all tests from file-location-tests.json
#[test]
fn run_tests() -> Result<(), Box<dyn Error>> {
let tests = fs::read_to_string("test-data/file-location-tests.json")?;
let tests: SourceTests = serde_json::from_str(&tests)?;
for (i, test) in tests.tests.into_iter().enumerate() {
... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 241 | 300 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:8 | if platform_matches {
let source = load(&env, &fs).await;
if let Some(expected_profile) = test_case.profile {
assert_eq!(source.profile, expected_profile, "{}", &test_case.name);
}
assert_eq!(
source.config_file.path, test_case.config_locat... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 281 | 340 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:9 | home_dir(&env, Os::Windows),
Some("C:\\Users\\name".to_string())
);
assert_eq!(home_dir(&env, Os::NotWindows), None);
}
#[test]
fn expand_home_no_home() {
// there is an edge case around expansion when no home directory exists
// if no home directory can be deter... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 5f4378d3e820cebbb6b7e7413d4592c7d5441559 | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/5f4378d3e820cebbb6b7e7413d4592c7d5441559/sdk/aws-config/src/profile/parser/source.rs | 321 | 353 |
awslabs/aws-sdk-rust:sdk/aws-config/src/profile/parser/source.rs:1 | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use aws_types::os_shim_internal;
use std::borrow::Cow;
use std::io::ErrorKind;
use std::path::{Component, Path, PathBuf};
use tracing::Instrument;
/// In-memory source of profile data
pub struct Source... | rust | rust | rust-source | awslabs/aws-sdk-rust | sdk/aws-config/src/profile/parser/source.rs | Apache-2.0 | 74bae11ae1af170e33fb695488f1f514f21884ae | github | sdk | https://github.com/awslabs/aws-sdk-rust/blob/74bae11ae1af170e33fb695488f1f514f21884ae/sdk/aws-config/src/profile/parser/source.rs | 1 | 60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.