Skip to content

Commit

Permalink
chore: update for clippy warnings (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrlna authored Feb 12, 2021
1 parent aaca7a9 commit 83a743a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 311 deletions.
14 changes: 7 additions & 7 deletions crates/houston/src/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ pub struct Opts {
}

impl Profile {
fn base_dir(config: &Config) -> Result<PathBuf, HoustonProblem> {
Ok(config.home.join("profiles"))
fn base_dir(config: &Config) -> PathBuf {
config.home.join("profiles")
}

fn dir(name: &str, config: &Config) -> Result<PathBuf, HoustonProblem> {
Ok(Profile::base_dir(config)?.join(name))
fn dir(name: &str, config: &Config) -> PathBuf {
Profile::base_dir(config).join(name)
}

/// Writes an api_key to the filesystem (`$APOLLO_CONFIG_HOME/profiles/<profile_name>/.sensitive`).
Expand Down Expand Up @@ -73,7 +73,7 @@ impl Profile {
/// Loads and deserializes configuration from the file system for a
/// specific profile.
pub fn load(name: &str, config: &Config, opts: LoadOpts) -> Result<Profile, HoustonProblem> {
if Profile::dir(name, config)?.exists() {
if Profile::dir(name, config).exists() {
if opts.sensitive {
let sensitive = Sensitive::load(name, config)?;
return Ok(Profile { sensitive });
Expand All @@ -86,7 +86,7 @@ impl Profile {

/// Deletes profile data from file system.
pub fn delete(name: &str, config: &Config) -> Result<(), HoustonProblem> {
let dir = Profile::dir(name, config)?;
let dir = Profile::dir(name, config);
tracing::debug!(dir = ?dir);
Ok(fs::remove_dir_all(dir).map_err(|e| match e.kind() {
std::io::ErrorKind::NotFound => HoustonProblem::ProfileNotFound(name.to_string()),
Expand All @@ -96,7 +96,7 @@ impl Profile {

/// Lists profiles based on directories in `$APOLLO_CONFIG_HOME/profiles`
pub fn list(config: &Config) -> Result<Vec<String>, HoustonProblem> {
let profiles_dir = Profile::base_dir(config)?;
let profiles_dir = Profile::base_dir(config);
let mut profiles = vec![];

// if profiles dir doesn't exist return empty vec
Expand Down
8 changes: 4 additions & 4 deletions crates/houston/src/profile/sensitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ pub struct Sensitive {
}

impl Sensitive {
fn path(profile_name: &str, config: &Config) -> Result<PathBuf, HoustonProblem> {
Ok(Profile::dir(profile_name, config)?.join(".sensitive"))
fn path(profile_name: &str, config: &Config) -> PathBuf {
Profile::dir(profile_name, config).join(".sensitive")
}

/// Serializes to toml and saves to file system at `$APOLLO_CONFIG_HOME/<profile_name>/.sensitive`.
pub fn save(&self, profile_name: &str, config: &Config) -> Result<(), HoustonProblem> {
let path = Sensitive::path(profile_name, config)?;
let path = Sensitive::path(profile_name, config);
let data = toml::to_string(self)?;

if let Some(dirs) = &path.parent() {
Expand All @@ -32,7 +32,7 @@ impl Sensitive {

/// Opens and deserializes `$APOLLO_CONFIG_HOME/<profile_name>/.sensitive`.
pub fn load(profile_name: &str, config: &Config) -> Result<Sensitive, HoustonProblem> {
let path = Sensitive::path(profile_name, config)?;
let path = Sensitive::path(profile_name, config);
let data = fs::read_to_string(&path)?;
tracing::debug!(path = ?path, data_len = ?data.len());
Ok(toml::from_str(&data)?)
Expand Down
298 changes: 1 addition & 297 deletions installers/npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/command/config/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ mod tests {
fn it_can_set_default_api_key() {
let config = get_config(None);

Profile::set_api_key(DEFAULT_PROFILE, &config, DEFAULT_KEY.into()).unwrap();
Profile::set_api_key(DEFAULT_PROFILE, &config, DEFAULT_KEY).unwrap();
let result = Profile::get_api_key(DEFAULT_PROFILE, &config).unwrap();
assert_eq!(result, DEFAULT_KEY);
}
Expand All @@ -83,7 +83,7 @@ mod tests {
fn it_can_set_custom_api_key() {
let config = get_config(None);

Profile::set_api_key(CUSTOM_PROFILE, &config, CUSTOM_KEY.into()).unwrap();
Profile::set_api_key(CUSTOM_PROFILE, &config, CUSTOM_KEY).unwrap();
let result = Profile::get_api_key(CUSTOM_PROFILE, &config).unwrap();
assert_eq!(result, CUSTOM_KEY);
}
Expand Down
Loading

0 comments on commit 83a743a

Please sign in to comment.