Skip to content

Commit

Permalink
docs: add content tabs in code examples in reference section (#3005)
Browse files Browse the repository at this point in the history
Signed-off-by: vishalvivekm <[email protected]>
Signed-off-by: Vivek Vishal <[email protected]>
  • Loading branch information
vishalvivekm authored Feb 20, 2024
1 parent 8e68e34 commit cf0c170
Show file tree
Hide file tree
Showing 16 changed files with 315 additions and 277 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ kustomize
kustomizeconfig
kwi
kwv
kwds
kyverno
lastword
Lato
Expand Down
1 change: 1 addition & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ config:
allowed_elements:
- details
- summary
- a
github-admonition: true
max-one-sentence-per-line: true

Expand Down
30 changes: 30 additions & 0 deletions docs/docs/assets/crd/examples/configmap-for-deno-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: scheduled-deployment
spec:
function:
configMapRef:
name: scheduled-deployment-cm-1
---
apiVersion: v1
kind: ConfigMap
metadata:
name: scheduled-deployment-1
data:
code: |
let text = Deno.env.get("DATA");
let data;
if (text != "") {
data = JSON.parse(text);
}
let targetDate = new Date(data.targetDate)
let dateTime = new Date();
if(targetDate < dateTime) {
console.log("Date has passed - ok");
Deno.exit(0);
} else {
console.log("It's too early - failing");
Deno.exit(1);
}
console.log(targetDate);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: keptntaskdefinition-sample
spec:
deno:
configMapRef:
name: dev-configmap
13 changes: 13 additions & 0 deletions docs/docs/assets/crd/examples/functionref-for-deno-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: slack-notification-dev
spec:
deno:
functionRef:
name: slack-notification
parameters:
map:
textMessage: "This is my configuration"
secureParameters:
secret: slack-token
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: hello-keptn-http
spec:
deno:
httpRef:
url: "https://www.example.com/yourscript.js"
15 changes: 15 additions & 0 deletions docs/docs/assets/crd/examples/inline-script-for-deno-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: lifecycle.keptn.sh/v1beta1
kind: KeptnTaskDefinition
metadata:
name: hello-keptn-inline
spec:
deno:
inline:
code: |
let text = Deno.env.get("DATA");
let data;
let name;
data = JSON.parse(text);
name = data.name
console.log("Hello, " + name + " new");
10 changes: 10 additions & 0 deletions docs/docs/assets/crd/examples/old-version-synopsis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: metrics.keptn.sh/v1alpha2
kind: KeptnMetricsProvider
metadata:
name: prometheus | dynatrace |dql
namespace: <namespace>
spec:
targetServer: "<data-provider-url>"
secretKeyRef:
name: dt-api-token
key: DT_TOKEN
9 changes: 9 additions & 0 deletions docs/docs/assets/crd/examples/synopsis-for-all-runners.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: lifecycle.keptn.sh/v?alpha?
kind: KeptnTaskDefinition
metadata:
name: <task-name>
spec: |
deno | python | container
...
retries: <integer>
timeout: <duration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: lifecycle.keptn.sh/v?alpha?
kind: KeptnTaskDefinition
metadata:
name: <task-name>
spec:
container: |
name: <container-name>
image: <image-name>
<other fields>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: lifecycle.keptn.sh/v?alpha?
kind: KeptnTaskDefinition
metadata:
name: <task-name>
spec:
deno: |
inline | httpRef | functionRef | ConfigMapRef
parameters: |
map:
textMessage: "This is my configuration"
secureParameters:
secret: <secret-name>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: lifecycle.keptn.sh/v?alpha?
kind: KeptnTaskDefinition
metadata:
name: <task-name>
spec:
python: |
inline | httpRef | functionRef | ConfigMapRef
parameters: |
map:
textMessage: "This is my configuration"
secureParameters:
secret: <secret-name>
12 changes: 12 additions & 0 deletions docs/docs/assets/crd/examples/yaml-synopsis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: metrics.keptn.sh/v1beta1
kind: KeptnMetricsProvider
metadata:
name: <data-source-instance-name>
namespace: <namespace>
spec:
type: prometheus | dynatrace | dql | datadog
targetServer: "<data-source-url>"
secretKeyRef:
name: <secret-name>
key: <secret-key-that-holds-token>
optional: true | false
92 changes: 37 additions & 55 deletions docs/docs/reference/crd-reference/metricsprovider.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,7 @@ for each metric definition by its name.
## Yaml Synopsis

```yaml
apiVersion: metrics.keptn.sh/v1beta1
kind: KeptnMetricsProvider
metadata:
name: <data-source-instance-name>
namespace: <namespace>
spec:
type: prometheus | dynatrace | dql | datadog
targetServer: "<data-source-url>"
secretKeyRef:
name: <secret-name>
key: <secret-key-that-holds-token>
optional: true | false
{% include "../../assets/crd/examples/yaml-synopsis.yaml" %}
```

## Fields
Expand Down Expand Up @@ -99,49 +88,51 @@ For detailed information please look at the [Examples section](#examples).

## Examples

### Prometheus
<!-- markdownlint-disable MD046 -->

An example of Prometheus as a metrics provider with a Secret holding
the authentication data looks like the following:
=== "Prometheus"

```yaml
{% include "./assets/keptnmetricsprovider-prometheus.yaml" %}
```
An example of Prometheus as a metrics provider with a Secret holding
the authentication data looks like the following:

> **Note**
> Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary,
> as `user` and `password` key names are required to be present in the linked Secret.
> Setting this field won't have any effect.
```yaml
{% include "./assets/keptnmetricsprovider-prometheus.yaml" %}
```
> **Note**
Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary,
as `user` and `password` key names are required to be present in the linked Secret.
Setting this field won't have any effect.

### Datadog
=== "Datadog"

An example of Datadog as a metrics provider with a Secret holding
the authentication data looks like the following:
An example of Datadog as a metrics provider with a Secret holding
the authentication data looks like the following:

```yaml
{% include "./assets/keptnmetricsprovider-datadog.yaml" %}
```
> **Note**
Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary,
as `DD_CLIENT_API_KEY` and `DD_CLIENT_API_KEY` key names must be
present in the linked Secret.
Setting this field has no effect.

```yaml
{% include "./assets/keptnmetricsprovider-datadog.yaml" %}
```
=== "Dynatrace and DQL"

> **Note**
> Setting the `.spec.secretKeyRef.key` field in `KeptnMetricsProvider` is not necessary,
> as `DD_CLIENT_API_KEY` and `DD_CLIENT_API_KEY` key names must be
> present in the linked Secret.
> Setting this field has no effect.
An example of Dynatrace as a metrics provider with a Secret holding
the authentication data looks like the following:

### Dynatrace and DQL
```yaml
{% include "./assets/keptnmetricsprovider-dynatrace.yaml" %}
```

An example of Dynatrace as a metrics provider with a Secret holding
the authentication data looks like the following:

```yaml
{% include "./assets/keptnmetricsprovider-dynatrace.yaml" %}
```
> **Note**
When using Dynatrace as metrics provider you can
define the key name of your DT token stored in a secret,
which is not possible for Datadog or Prometheus.
For this example `myCustomTokenKey` was used.

> **Note**
> When using Dynatrace as metrics provider you can
> define the key name of your DT token stored in a secret,
> which is not possible for Datadog or Prometheus.
> For this example `myCustomTokenKey` was used.
<!-- markdownlint-enable MD046 -->

## Files

Expand All @@ -164,16 +155,7 @@ only specified the `metadata.name` field
that identified the data provider (`prometheus`, `dynatrace`, or `dql`):

```yaml
apiVersion: metrics.keptn.sh/v1alpha2
kind: KeptnMetricsProvider
metadata:
name: prometheus | dynatrace |dql
namespace: <namespace>
spec:
targetServer: "<data-provider-url>"
secretKeyRef:
name: dt-api-token
key: DT_TOKEN
{% include "../../assets/crd/examples/old-version-synopsis.yaml" %}
```

Also note that, for the v1alpha1 and v1alpha2 API versions,
Expand Down
Loading

0 comments on commit cf0c170

Please sign in to comment.