Skip to content

Commit

Permalink
support optional field
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad committed May 9, 2024
1 parent 7df7f0c commit ab6ebf3
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions keyscope/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.16", features = [
"env-filter",
], optional = true }

service_policy_kit = { git = "https://github.com/SpectralOps/service-policy-kit", rev = "451c74d" }
service_policy_kit = { git = "https://github.com/SpectralOps/service-policy-kit", rev = "57543eb" }
serde = { version = "1.0.200" }
serde_derive = "1.0.200"
serde_yaml = { version = "0.9.34" }
Expand Down
7 changes: 6 additions & 1 deletion keyscope/src/bin/cli/out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ pub const fn provider_not_found() -> &'static str {
pub fn requirements_results(provider: &Provider, params: &[Param]) -> String {
let params_str: String = params
.iter()
.map(|p| format!(" - param: {}\n desc: {}", p.name, p.desc))
.map(|p| {
format!(
" - param: {}\n desc: {}\n optional: {}",
p.name, p.desc, p.optional
)
})
.collect::<Vec<_>>()
.join("\n");

Expand Down
4 changes: 4 additions & 0 deletions keyscope/src/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,15 @@ providers:
desc: AWS ID
- name: aws_2
desc: AWS secret
- name: aws_3
desc: AWS token
optional: true
uri: https://sts.amazonaws.com
method: post
aws_auth:
key: "{{aws_1}}"
secret: "{{aws_2}}"
token: "{{aws_3}}"
service: "sts"
headers:
content-type:
Expand Down
1 change: 1 addition & 0 deletions keyscope/tests/cmd/external-config.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $ keyscope requirements custom --config config.yaml --no-banner
provider custom requires:
- param: custom_1
desc: custom token
optional: false

To use from the CLI, run:
keyscope validate custom -p PARAM1 PARAM2 ...
Expand Down
2 changes: 1 addition & 1 deletion keyscope/tests/cmd/providers.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ asana:validation
keyscope validate asana -p asana_1

aws:validation
keyscope validate aws -p aws_1 aws_2
keyscope validate aws -p aws_1 aws_2 aws_3

bingmaps:validation
keyscope validate bingmaps -p bingmaps_1
Expand Down
2 changes: 1 addition & 1 deletion keyscope/tests/cmd/reporter.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Ran 1 interactions with 1 checks in [..]
```console
$ keyscope validate tester -p arg1 -p arg2 --no-banner --reporter json
? 1
{"interactions":[{"examples":{"err":{"request_id":null,"status_code":"500"},"ok":{"body":"hello","request_id":null,"status_code":"201"}},"invalid":{"request_id":null,"status_code":"5//d//d"},"request":{"desc":"Tester: valid key","id":"tester:validation","method":"post","params":[{"desc":"hookbin ID (https://hookb.in)","name":"tester_1"},{"desc":"fake key to put as a query param","name":"tester_2"}],"uri":"https://hookb.in/{{tester_1}}?q={{tester_1}}"},"response":{"request_id":null,"status_code":"200"}}],"results":[{"duration":{"nanos":[..],"secs":[..]},"error":"error sending request for url (https://hookb.in/arg1?q=arg1)","kind":"content","request":{"desc":"Tester: valid key","id":"tester:validation","method":"post","params":[{"desc":"hookbin ID (https://hookb.in)","name":"tester_1"},{"desc":"fake key to put as a query param","name":"tester_2"}],"uri":"https://hookb.in/{{tester_1}}?q={{tester_1}}"},"response":null,"violations":[]}]}
{"interactions":[{"examples":{"err":{"request_id":null,"status_code":"500"},"ok":{"body":"hello","request_id":null,"status_code":"201"}},"invalid":{"request_id":null,"status_code":"5//d//d"},"request":{"desc":"Tester: valid key","id":"tester:validation","method":"post","params":[{"desc":"hookbin ID (https://hookb.in)","name":"tester_1","optional":false},{"desc":"fake key to put as a query param","name":"tester_2","optional":false}],"uri":"https://hookb.in/{{tester_1}}?q={{tester_1}}"},"response":{"request_id":null,"status_code":"200"}}],"results":[{"duration":{"nanos":838195959,"secs":0},"error":"error sending request for url (https://hookb.in/arg1?q=arg1)","kind":"content","request":{"desc":"Tester: valid key","id":"tester:validation","method":"post","params":[{"desc":"hookbin ID (https://hookb.in)","name":"tester_1","optional":false},{"desc":"fake key to put as a query param","name":"tester_2","optional":false}],"uri":"https://hookb.in/{{tester_1}}?q={{tester_1}}"},"response":null,"violations":[]}]}

```

Expand Down
2 changes: 2 additions & 0 deletions keyscope/tests/cmd/requirements.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ $ keyscope requirements tester --no-banner
provider tester requires:
- param: tester_1
desc: hookbin ID (https://hookb.in)
optional: false
- param: tester_2
desc: fake key to put as a query param
optional: false

To use from the CLI, run:
keyscope validate tester -p PARAM1 PARAM2 ...
Expand Down

0 comments on commit ab6ebf3

Please sign in to comment.