Skip to content

Commit bee4b3f

Browse files
committed
fix build?
1 parent 4e8eaa5 commit bee4b3f

15 files changed

Lines changed: 57 additions & 61 deletions

File tree

teller-cli/src/scan.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ pub async fn run(teller: &Teller, args: &ScanArgs) -> Result<Response> {
4545
Cell::new(
4646
m.query
4747
.provider
48-
.map_or_else(|| "n/a".to_string(), |p| p.kind.to_string())
49-
.to_string(),
48+
.map_or_else(|| "n/a".to_string(), |p| p.kind.to_string()),
5049
),
5150
Cell::new(m.query.path.map_or_else(|| "n/a".to_string(), |p| p.path)),
5251
]);

teller-cli/src/wizard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl AppConfig {
113113
match providers.get(*provider_name) {
114114
Some(p) => selected.push(p.clone()),
115115
_ => return Err(Error::ProviderNotFound((*provider_name).to_string())),
116-
};
116+
}
117117
}
118118

119119
Ok(selected)

teller-core/src/export.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use std::collections::BTreeMap;
2+
use std::fmt::Write as _;
23
use std::str::FromStr;
4+
use std::sync::LazyLock;
35

46
use csv::WriterBuilder;
5-
use lazy_static::lazy_static;
67
use serde_derive::{Deserialize, Serialize};
78
use serde_variant::to_variant_name;
89
use strum::EnumIter;
@@ -11,14 +12,12 @@ use teller_providers::config::KV;
1112

1213
use crate::{Error, Result};
1314

14-
lazy_static! {
15-
pub static ref POSSIBLE_VALUES: String = {
16-
let providers: Vec<String> = Format::iter()
17-
.map(|provider| provider.to_string())
18-
.collect();
19-
providers.join(", ")
20-
};
21-
}
15+
pub static POSSIBLE_VALUES: LazyLock<String> = LazyLock::new(|| {
16+
let providers: Vec<String> = Format::iter()
17+
.map(|provider| provider.to_string())
18+
.collect();
19+
providers.join(", ")
20+
});
2221

2322
#[derive(Serialize, Deserialize, Debug, Clone, EnumIter)]
2423
pub enum Format {
@@ -49,7 +48,7 @@ impl FromStr for Format {
4948
.collect::<BTreeMap<String, Self>>();
5049

5150
providers.get(input).map_or_else(
52-
|| Err(&POSSIBLE_VALUES as &'static str),
51+
|| Err(POSSIBLE_VALUES.as_str()),
5352
|provider| Ok(provider.clone()),
5453
)
5554
}
@@ -75,15 +74,15 @@ impl Format {
7574
out.push_str("#!/bin/sh\n");
7675

7776
for kv in kvs {
78-
out.push_str(&format!("export {}='{}'\n", kv.key, kv.value));
77+
let _ = writeln!(out, "export {}='{}'", kv.key, kv.value);
7978
}
8079
out
8180
}
8281

8382
fn export_env(kvs: &[KV]) -> String {
8483
let mut out = String::new();
8584
for kv in kvs {
86-
out.push_str(&format!("{}={}\n", kv.key, kv.value));
85+
let _ = writeln!(out, "{}={}", kv.key, kv.value);
8786
}
8887
out
8988
}

teller-core/src/scan.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ fn get_visual_position(text: &[u8], byte_position: usize) -> Option<(usize, usiz
2828
.iter()
2929
.take(byte_position)
3030
.rposition(|c| *c == b'\n')
31-
.map(|pos| pos + 1)
32-
.unwrap_or(0);
31+
.map_or(0, |pos| pos + 1);
3332

3433
let len = UnicodeWidthStr::width(
3534
String::from_utf8_lossy(&text[last_ln_start..byte_position]).as_ref(),

teller-core/src/teller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl Teller {
130130
/// # Errors
131131
///
132132
/// This function will return an error if command fails
133-
pub async fn run<'a>(&self, cmd: &[&str], opts: &exec::Opts<'a>) -> Result<Output> {
133+
pub async fn run(&self, cmd: &[&str], opts: &exec::Opts<'_>) -> Result<Output> {
134134
let cmd = shell_words::join(cmd);
135135
let kvs = self.collect().await?;
136136
let res = exec::cmd(

teller-providers/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl KV {
124124
from_key: from_key.to_string(),
125125
path: Some(PathInfo {
126126
path: pm.path.clone(),
127-
id: pm.id.to_string(),
127+
id: pm.id.clone(),
128128
}),
129129
provider: Some(provider),
130130
meta: Some(MetaInfo {

teller-providers/src/providers/aws_secretsmanager.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn handle_get_err(
4242
GetSecretValueError::ResourceNotFoundException(_) => {
4343
if mode == &Mode::Get {
4444
Err(Error::NotFound {
45-
path: pm.path.to_string(),
45+
path: pm.path.clone(),
4646
msg: "not found".to_string(),
4747
})
4848
} else {
@@ -53,12 +53,12 @@ fn handle_get_err(
5353
e => {
5454
if e.to_string().contains("marked deleted") {
5555
Err(Error::NotFound {
56-
path: pm.path.to_string(),
56+
path: pm.path.clone(),
5757
msg: "not found".to_string(),
5858
})
5959
} else {
6060
Err(Error::GetError {
61-
path: pm.path.to_string(),
61+
path: pm.path.clone(),
6262
msg: e.to_string(),
6363
})
6464
}
@@ -73,7 +73,7 @@ fn handle_del_err(e: SdkError<DeleteSecretError>, pm: &PathMap) -> Result<()> {
7373
Ok(())
7474
}
7575
e => Err(Error::DeleteError {
76-
path: pm.path.to_string(),
76+
path: pm.path.clone(),
7777
msg: e.to_string(),
7878
}),
7979
}
@@ -207,8 +207,7 @@ async fn put_data(
207207
msg: e.to_string(),
208208
path: pm.path.clone(),
209209
})?;
210-
};
211-
210+
}
212211
Ok(())
213212
}
214213

teller-providers/src/providers/dotenv.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//!
1616
//!
1717
#![allow(clippy::borrowed_box)]
18+
use std::fmt::Write as _;
1819
use std::fs::File;
1920
use std::io::prelude::*;
2021
use std::{
@@ -74,21 +75,21 @@ fn load(path: &Path, mode: &Mode) -> Result<BTreeMap<String, String>> {
7475

7576
if mode == &Mode::Get {
7677
let metadata = content.metadata().map_err(|e| Error::GetError {
77-
path: format!("{path:?}"),
78+
path: path.display().to_string(),
7879
msg: format!("could not get file metadata. err: {e:?}"),
7980
})?;
8081

8182
if metadata.len() == 0 {
8283
return Err(Error::NotFound {
83-
path: format!("{path:?}"),
84+
path: path.display().to_string(),
8485
msg: "file is empty".to_string(),
8586
});
8687
}
8788
}
8889

8990
for res in dotenvy::Iter::new(&content) {
9091
let (k, v) = res.map_err(|e| Error::GetError {
91-
path: format!("{path:?}"),
92+
path: path.display().to_string(),
9293
msg: e.to_string(),
9394
})?;
9495
env.insert(k, v);
@@ -109,11 +110,11 @@ fn save(path: &Path, data: &BTreeMap<String, String>) -> Result<String> {
109110
None
110111
};
111112

112-
let value = json_value.unwrap_or_else(|| v.to_string());
113+
let value = json_value.unwrap_or_else(|| v.clone());
113114
if value.chars().any(char::is_whitespace) && !value.starts_with(['"', '\'']) {
114-
out.push_str(&format!("{k}=\"{value}\"\n"));
115+
let _ = writeln!(out, "{k}=\"{value}\"");
115116
} else {
116-
out.push_str(&format!("{k}={value}\n"));
117+
let _ = writeln!(out, "{k}={value}");
117118
}
118119
}
119120

@@ -141,7 +142,7 @@ impl Provider for Dotenv {
141142
pm,
142143
|data| {
143144
for kv in kvs {
144-
data.insert(kv.key.to_string(), kv.value.to_string());
145+
data.insert(kv.key.clone(), kv.value.clone());
145146
}
146147
},
147148
&Mode::Put,
@@ -175,8 +176,8 @@ impl Dotenv {
175176
{
176177
if mode == &Mode::Put && self.opts.create_on_put {
177178
Self::create_empty_file(&pm.path).map_err(|e| Error::GetError {
178-
path: format!("{:?}", pm.path),
179-
msg: format!("could not create file: {:?}. err: {e:?}", pm.path),
179+
path: pm.path.clone(),
180+
msg: format!("could not create file: {}. err: {e:?}", pm.path),
180181
})?;
181182
}
182183
let file = Path::new(&pm.path);

teller-providers/src/providers/etcd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl Provider for Etcd {
185185
.await
186186
.map_err(|err| to_err(pm, err))?;
187187
}
188-
};
188+
}
189189
drop(client);
190190

191191
Ok(())

teller-providers/src/providers/google_secretmanager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl Provider for GoogleSecretManager {
302302

303303
if out.is_empty() {
304304
return Err(Error::NotFound {
305-
path: pm.path.to_string(),
305+
path: pm.path.clone(),
306306
msg: "path not found".to_string(),
307307
});
308308
}

0 commit comments

Comments
 (0)