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

feat: embed jp functions docs (cherry-pick #1980) #2020

Merged
merged 1 commit into from
Sep 26, 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
25 changes: 17 additions & 8 deletions pkg/engine/functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func GetFunctions() []functions.FunctionEntry {
Arguments: []functions.ArgSpec{
{Types: []functions.JpType{functions.JpString}},
},
Handler: jpEnv,
Handler: jpEnv,
Description: "Returns the value of the environment variable passed in argument.",
}, {
Name: k8sGet,
Arguments: []functions.ArgSpec{
Expand All @@ -37,7 +38,8 @@ func GetFunctions() []functions.FunctionEntry {
{Types: []functions.JpType{functions.JpString}},
{Types: []functions.JpType{functions.JpString}},
},
Handler: jpKubernetesGet,
Handler: jpKubernetesGet,
Description: "Gets a resource from a Kubernetes cluster.",
}, {
Name: k8sList,
Arguments: []functions.ArgSpec{
Expand All @@ -46,7 +48,8 @@ func GetFunctions() []functions.FunctionEntry {
{Types: []functions.JpType{functions.JpString}},
{Types: []functions.JpType{functions.JpString}, Optional: true},
},
Handler: jpKubernetesList,
Handler: jpKubernetesList,
Description: "Lists resources from a Kubernetes cluster.",
}, {
Name: k8sExists,
Arguments: []functions.ArgSpec{
Expand All @@ -56,33 +59,38 @@ func GetFunctions() []functions.FunctionEntry {
{Types: []functions.JpType{functions.JpString}},
{Types: []functions.JpType{functions.JpString}},
},
Handler: jpKubernetesExists,
Handler: jpKubernetesExists,
Description: "Checks if a given resource exists in a Kubernetes cluster.",
}, {
Name: k8sResourceExists,
Arguments: []functions.ArgSpec{
{Types: []functions.JpType{functions.JpAny}},
{Types: []functions.JpType{functions.JpString}},
{Types: []functions.JpType{functions.JpString}},
},
Handler: jpKubernetesResourceExists,
Handler: jpKubernetesResourceExists,
Description: "Checks if a given resource type is available in a Kubernetes cluster.",
}, {
Name: k8sServerVersion,
Arguments: []functions.ArgSpec{
{Types: []functions.JpType{functions.JpAny}},
},
Handler: jpKubernetesServerVersion,
Handler: jpKubernetesServerVersion,
Description: "Returns the version of a Kubernetes cluster.",
}, {
Name: metricsDecode,
Arguments: []functions.ArgSpec{
{Types: []functions.JpType{functions.JpString}},
},
Handler: jpMetricsDecode,
Handler: jpMetricsDecode,
Description: "Decodes metrics in the Prometheus text format.",
}, {
Name: trimSpace,
Arguments: []functions.ArgSpec{
{Types: []functions.JpType{functions.JpString}},
},
Handler: jpTrimSpace,
Handler: jpTrimSpace,
Description: "Trims leading and trailing spaces from the string passed in argument.",
}, {
Name: asString,
Arguments: []functions.ArgSpec{
Expand All @@ -103,5 +111,6 @@ func GetFunctions() []functions.FunctionEntry {
}
return nil, nil
},
Description: "Returns the passed in argument converted into a string.",
}}
}
6 changes: 4 additions & 2 deletions website/docs/reference/jp/examples/as_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

## Description


Returns the passed in argument converted into a string.

## Examples

TODO
```
as_string('foobar') == 'foobar'
```
6 changes: 4 additions & 2 deletions website/docs/reference/jp/examples/env.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

## Description


Returns the value of the environment variable passed in argument.

## Examples

TODO
```
env('MY_ENV_VAR') == 'foo'
```
6 changes: 4 additions & 2 deletions website/docs/reference/jp/examples/trim_space.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

## Description


Trims leading and trailing spaces from the string passed in argument.

## Examples

TODO
```
trim_space(' foobar ') == 'foobar'
```
12 changes: 10 additions & 2 deletions website/docs/reference/jp/examples/x_k8s_exists.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

## Description


Checks if a given resource exists in a Kubernetes cluster.

## Examples

TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_exists($client, 'apps/v1', 'Deployment', 'crossplane-system', 'crossplane')
```
12 changes: 10 additions & 2 deletions website/docs/reference/jp/examples/x_k8s_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

## Description


Gets a resource from a Kubernetes cluster.

## Examples

TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_get($client, 'apps/v1', 'Deployment', 'crossplane-system', 'crossplane')
```
12 changes: 10 additions & 2 deletions website/docs/reference/jp/examples/x_k8s_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

## Description


Lists resources from a Kubernetes cluster.

## Examples

TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_list($client, 'apps/v1', 'Deployment', 'crossplane-system')
```
12 changes: 10 additions & 2 deletions website/docs/reference/jp/examples/x_k8s_resource_exists.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@

## Description


Checks if a given resource type is available in a Kubernetes cluster.

## Examples

TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_resource_exists($client, 'apps/v1', 'Deployment')
```
8 changes: 6 additions & 2 deletions website/docs/reference/jp/examples/x_k8s_server_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@

## Description


Returns the version of a Kubernetes cluster.

## Examples

TODO
```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_server_version($client)
```
2 changes: 1 addition & 1 deletion website/docs/reference/jp/examples/x_metrics_decode.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Description


Decodes metrics in the Prometheus text format.

## Examples

Expand Down
18 changes: 9 additions & 9 deletions website/docs/reference/jp/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@

| Name | Signature | Description |
|---|---|---|
| [env](./examples/env.md) | `env(string)` | |
| [x_k8s_get](./examples/x_k8s_get.md) | `x_k8s_get(any, string, string, string, string)` | |
| [x_k8s_list](./examples/x_k8s_list.md) | `x_k8s_list(any, string, string, string)` | |
| [x_k8s_exists](./examples/x_k8s_exists.md) | `x_k8s_exists(any, string, string, string, string)` | |
| [x_k8s_resource_exists](./examples/x_k8s_resource_exists.md) | `x_k8s_resource_exists(any, string, string)` | |
| [x_k8s_server_version](./examples/x_k8s_server_version.md) | `x_k8s_server_version(any)` | |
| [x_metrics_decode](./examples/x_metrics_decode.md) | `x_metrics_decode(string)` | |
| [trim_space](./examples/trim_space.md) | `trim_space(string)` | |
| [as_string](./examples/as_string.md) | `as_string(any)` | |
| [env](./examples/env.md) | `env(string)` | Returns the value of the environment variable passed in argument. |
| [x_k8s_get](./examples/x_k8s_get.md) | `x_k8s_get(any, string, string, string, string)` | Gets a resource from a Kubernetes cluster. |
| [x_k8s_list](./examples/x_k8s_list.md) | `x_k8s_list(any, string, string, string)` | Lists resources from a Kubernetes cluster. |
| [x_k8s_exists](./examples/x_k8s_exists.md) | `x_k8s_exists(any, string, string, string, string)` | Checks if a given resource exists in a Kubernetes cluster. |
| [x_k8s_resource_exists](./examples/x_k8s_resource_exists.md) | `x_k8s_resource_exists(any, string, string)` | Checks if a given resource type is available in a Kubernetes cluster. |
| [x_k8s_server_version](./examples/x_k8s_server_version.md) | `x_k8s_server_version(any)` | Returns the version of a Kubernetes cluster. |
| [x_metrics_decode](./examples/x_metrics_decode.md) | `x_metrics_decode(string)` | Decodes metrics in the Prometheus text format. |
| [trim_space](./examples/trim_space.md) | `trim_space(string)` | Trims leading and trailing spaces from the string passed in argument. |
| [as_string](./examples/as_string.md) | `as_string(any)` | Returns the passed in argument converted into a string. |

4 changes: 3 additions & 1 deletion website/jp/examples/as_string.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
TODO
```
as_string('foobar') == 'foobar'
```
4 changes: 3 additions & 1 deletion website/jp/examples/env.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
TODO
```
env('MY_ENV_VAR') == 'foo'
```
4 changes: 3 additions & 1 deletion website/jp/examples/trim_space.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
TODO
```
trim_space(' foobar ') == 'foobar'
```
10 changes: 9 additions & 1 deletion website/jp/examples/x_k8s_exists.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_exists($client, 'apps/v1', 'Deployment', 'crossplane-system', 'crossplane')
```
10 changes: 9 additions & 1 deletion website/jp/examples/x_k8s_get.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_get($client, 'apps/v1', 'Deployment', 'crossplane-system', 'crossplane')
```
10 changes: 9 additions & 1 deletion website/jp/examples/x_k8s_list.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_list($client, 'apps/v1', 'Deployment', 'crossplane-system')
```
10 changes: 9 additions & 1 deletion website/jp/examples/x_k8s_resource_exists.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
TODO
!!! info "Clustered resources"

For clustered resources, you can leave the namespace empty `''`.

```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_resource_exists($client, 'apps/v1', 'Deployment')
```
6 changes: 5 additions & 1 deletion website/jp/examples/x_k8s_server_version.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
TODO
```
# `$client` is a binding pointing to a Kubernetes client

x_k8s_server_version($client)
```
Loading