Skip to content

Commit

Permalink
chore: add env var to http docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Sep 30, 2024
1 parent 82f6534 commit dc75252
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
47 changes: 42 additions & 5 deletions canary-checker/docs/reference/1-http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ spec:
{field: "responseContent", description: "Expected response content", scheme: "string"},
{field: "thresholdMillis", description: "Request timeout", default: 5000, scheme: "int"},
{field: "maxSSLExpiry", description: "Max SSL expiry days", scheme: "int"},
{field: "insecureSkipVerify", description: "Skip TLS verification", scheme: "bool"}
{field: "insecureSkipVerify", description: "Skip TLS verification", scheme: "bool"},
{field: "env", description: "Setup environment variables that are accessible while templating", scheme: "[]EnvVar"},
]}/>
### TLS Config
Expand Down Expand Up @@ -68,6 +69,14 @@ spec:
</details>
### OAuth
<Fields rows={[
{field: "tokenURL", description: "URL for OAuth Token", scheme: "string"},
{field: "scope", description: "Scope for OAuth token request", scheme: "[]string"},
{field: "params", description: "Parameters for OAuth", scheme: "map[string]string"},
]}/>
### Result Variables
Result variables can be used in `test`, `display` and `transform` [expressions](../concepts/expressions)
Expand Down Expand Up @@ -107,9 +116,7 @@ spec:
</div>
</details>

### OAuth

### Template Body Variables
## Template Body Variables

| Name | Scheme |
| ----------------------------- | ------------------- |
Expand All @@ -129,6 +136,37 @@ Eg: In the following spec, the vars `my_secret_path` and `my_secret_var`, define
</div>
</details>

<details summary="Templating authentication from env variables">
<div>
```yaml title="http_user_pass_template.yaml"
apiVersion: canaries.flanksource.com/v1

Check failure on line 142 in canary-checker/docs/reference/1-http.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-http.mdx#L142

[Flanksource.Spelling] Is 'apiVersion' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'apiVersion' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-http.mdx", "range": {"start": {"line": 142, "column": 1}}}, "severity": "ERROR"}
kind: Canary
metadata:
name: http-basic-auth-url
namespace: canaries
spec:
http:
- name: test-url-via-env
# The URL can be templated from arbritrary values using the env field and $(.) syntax

Check failure on line 150 in canary-checker/docs/reference/1-http.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] canary-checker/docs/reference/1-http.mdx#L150

[Flanksource.Spelling] Is 'arbritrary' spelled correctly? Is it missing code formatting?
Raw output
{"message": "[Flanksource.Spelling] Is 'arbritrary' spelled correctly? Is it missing code formatting?", "location": {"path": "canary-checker/docs/reference/1-http.mdx", "range": {"start": {"line": 150, "column": 39}}}, "severity": "ERROR"}
url: $(.url)
env:
- name: url
value: https://hello:[email protected]/basic-auth/hello/world2
- name: test-basic-via-env
# the url can be constructed from multiple variables
url: https://$(.user):$(.pass)@httpbin.demo.aws.flanksource.com/basic-auth/hello/world
templateBody: true
body: |
{{. | toJSONPretty " " }}
responseCodes: [200]
env:
- name: user
value: hello
- name: pass
value: world
```
</div>

See <CommonLink to="gotemplate" anchor="escaping">Escaping variables</CommonLink>

## Metrics
Expand All @@ -154,4 +192,3 @@ Status class is one of `1xx`, `2xx`, `3xx`, `4xx`, `5xx`
```yaml title="metrics.yaml" file=../../../modules/canary-checker/fixtures/minimal/metrics-transformed.yaml
```
</div>
</details>
5 changes: 5 additions & 0 deletions canary-checker/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export default async function createConfigAsync() {
label: 'GitHub',
position: 'right',
},
{
href: 'https://cloud-native.slack.com/messages/canary-checker/',
label: 'Slack',
position: 'right',
},
],
},
colorMode: {
Expand Down

0 comments on commit dc75252

Please sign in to comment.