Skip to content

Commit

Permalink
Merge branch 'fix-dotenv-quote' of github.com:tellerops/teller into f…
Browse files Browse the repository at this point in the history
…ix-dotenv-quote
  • Loading branch information
jondot committed May 15, 2024
2 parents c1fc9cc + 546ae5c commit ad55573
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 19 deletions.
2 changes: 1 addition & 1 deletion teller-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct NewArgs {
}

async fn load_teller(config: Option<String>) -> eyre::Result<Teller> {
let config_arg = config.unwrap_or_else(|| "teller.yml".to_string());
let config_arg = config.unwrap_or_else(|| DEFAULT_FILE_PATH.to_string());
let config_path = Path::new(&config_arg);
let teller = Teller::from_yaml(config_path).await?;
Ok(teller)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions teller-cli/tests/cmd/export.trycmd
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
```console
$ teller -c teller.yml export yaml
$ teller export yaml
FOO_BAR: foo
FOO_BAZ: baz
PRINT_MOOD: happy
PRINT_NAME: linus


$ teller -c teller.yml export csv
$ teller export csv
FOO_BAR,foo
PRINT_NAME,linus
FOO_BAZ,baz
PRINT_MOOD,happy


$ teller -c teller.yml export json
$ teller export json
{"FOO_BAR":"foo","FOO_BAZ":"baz","PRINT_MOOD":"happy","PRINT_NAME":"linus"}

$ teller -c teller.yml export env
$ teller export env
FOO_BAR=foo
PRINT_NAME=linus
FOO_BAZ=baz
PRINT_MOOD=happy


$ teller -c teller.yml sh
$ teller sh
#!/bin/sh
export FOO_BAR='foo'
export PRINT_NAME='linus'
export FOO_BAZ='baz'
export PRINT_MOOD='happy'


$ teller -c teller.yml env
$ teller env
FOO_BAR=foo
PRINT_NAME=linus
FOO_BAZ=baz
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions teller-cli/tests/cmd/redact.in/one.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PRINT_NAME=linus
FOO_BAR=foo
EMPTY=""
2 changes: 2 additions & 0 deletions teller-cli/tests/cmd/redact.in/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hello linus,
I just read that you made linux.
2 changes: 2 additions & 0 deletions teller-cli/tests/cmd/redact.in/two.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PRINT_MOOD=happy
FOO_BAZ=baz
6 changes: 6 additions & 0 deletions teller-cli/tests/cmd/redact.trycmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```console
$ teller redact --in text.txt
hello [REDACTED],
I just read that you made linux.

```
File renamed without changes.
2 changes: 1 addition & 1 deletion teller-cli/tests/cmd/run.trycmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```console
$ teller -c teller.yml run --reset --shell -- node index.js
$ teller run --reset --shell -- node index.js
hello from nodejs
linus
happy
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions teller-cli/tests/cmd/scan.trycmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
```console
$ teller -c teller.yml scan
$ teller scan
scanning for 4 item(s) in .
2:9 ./one.env fo*** dotenv one.env
2:9 ./two.env ba*** dotenv two.env
1:12 ./two.env ha*** dotenv two.env
1:12 ./one.env li*** dotenv one.env
found 4 result(s)

$ teller -c teller.yml scan -a
$ teller scan -a
scanning for 4 item(s) in .
2:9 ./one.env fo*** dotenv one.env
2:9 ./two.env ba*** dotenv two.env
Expand All @@ -16,7 +16,7 @@ scanning for 4 item(s) in .
1:12 ./one.env li*** dotenv one.env
found 5 result(s)

$ teller -c teller.yml scan -b
$ teller scan -b
scanning for 4 item(s) in .
2:9 ./one.env fo*** dotenv one.env
2:9 ./two.env ba*** dotenv two.env
Expand Down
11 changes: 11 additions & 0 deletions teller-cli/tests/cmd/template.in/.teller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
providers:
dot1:
kind: dotenv
maps:
- id: one
path: one.env
dot2:
kind: dotenv
maps:
- id: two
path: two.env
2 changes: 1 addition & 1 deletion teller-cli/tests/cmd/template.trycmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```console
$ teller -c teller.yml template --in config-templ.t
$ teller template --in config-templ.t
production_var: linus
production_mood: happy

Expand Down
17 changes: 10 additions & 7 deletions teller-core/src/redact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ impl Redactor {
if self.has_match(message, kvs) {
let mut redacted = message.to_string();
for kv in kvs {
redacted = redacted.replace(
&kv.value,
kv.meta
.as_ref()
.and_then(|m| m.redact_with.as_ref())
.map_or("[REDACTED]", |s| s.as_str()),
);
// only replace values with at least 2 chars
if kv.value.len() >= 2 {
redacted = redacted.replace(
&kv.value,
kv.meta
.as_ref()
.and_then(|m| m.redact_with.as_ref())
.map_or("[REDACTED]", |s| s.as_str()),
);
}
}
Cow::Owned(redacted)
} else {
Expand Down

0 comments on commit ad55573

Please sign in to comment.