Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add env var to http docs #290

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 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,38 @@ Eg: In the following spec, the vars `my_secret_path` and `my_secret_var`, define
</div>
</details>

<details summary="Templating URL from env variables">
<div>
```yaml title="http_user_pass_template.yaml"
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: http-basic-auth-url
namespace: canaries
spec:
http:
- name: test-url-via-env
# The URL can be templated from arbitrary values using the env field and $(.) syntax
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>
</details>

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

## Metrics
Expand Down
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
1 change: 1 addition & 0 deletions styles/ignore/words-with-suggestions.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
actionPrefix
apiVersion
agent_id
aggregatorName
alarmPrefix
Expand Down
Loading