Skip to content

Commit 8726a2e

Browse files
committed
Entry metadata field
1 parent 9dd173a commit 8726a2e

File tree

20 files changed

+295
-119
lines changed

20 files changed

+295
-119
lines changed

docs/faq.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Templating is supported with the following fields:
8282
| `.Entry.Manifest.Labels` | Image labels |
8383
| `.Entry.Manifest.Layers` | Image layers |
8484
| `.Entry.Manifest.Platform` | Platform that the image is runs on. e.g. `linux/amd64` |
85+
| `.Entry.Metadata` | Key-value pair of image metadata specific to each provider |
8586

8687
## Authentication against the registry
8788

docs/notif/script.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
You can call a script when a notification occured. Following environment variables will be passed:
44

55
```
6-
DIUN_VERSION=3.0.0
6+
DIUN_VERSION=4.24.0
77
DIUN_ENTRY_STATUS=new
88
DIUN_HOSTNAME=myserver
99
DIUN_ENTRY_PROVIDER=file
@@ -13,6 +13,13 @@ DIUN_ENTRY_MIMETYPE=application/vnd.docker.distribution.manifest.list.v2+json
1313
DIUN_ENTRY_DIGEST=sha256:216e3ae7de4ca8b553eb11ef7abda00651e79e537e85c46108284e5e91673e01
1414
DIUN_ENTRY_CREATED=2020-03-26 12:23:56 +0000 UTC
1515
DIUN_ENTRY_PLATFORM=linux/amd64
16+
DIUN_ENTRY_METADATA_CTN_COMMAND=diun serve
17+
DIUN_ENTRY_METADATA_CTN_CREATEDAT=2022-12-29 10:46:20 +0100 CET
18+
DIUN_ENTRY_METADATA_CTN_ID=7c71187fad11aa06f951dee0ebd6382ee0030a8228929fc7ea2fccc18f940788
19+
DIUN_ENTRY_METADATA_CTN_NAMES=diun
20+
DIUN_ENTRY_METADATA_CTN_SIZE=0B
21+
DIUN_ENTRY_METADATA_CTN_STATE=running
22+
DIUN_ENTRY_METADATA_CTN_STATUS=Up Less than a second (health: starting)
1623
```
1724

1825
## Configuration

docs/notif/webhook.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The JSON response will look like this:
3535

3636
```json
3737
{
38-
"diun_version": "4.0.0",
38+
"diun_version": "4.24.0",
3939
"hostname": "myserver",
4040
"status": "new",
4141
"provider": "file",
@@ -44,7 +44,16 @@ The JSON response will look like this:
4444
"mime_type": "application/vnd.docker.distribution.manifest.list.v2+json",
4545
"digest": "sha256:216e3ae7de4ca8b553eb11ef7abda00651e79e537e85c46108284e5e91673e01",
4646
"created": "2020-03-26T12:23:56Z",
47-
"platform": "linux/amd64"
47+
"platform": "linux/amd64",
48+
"metadata": {
49+
"ctn_command": "diun serve",
50+
"ctn_createdat": "2022-12-29 10:22:15 +0100 CET",
51+
"ctn_id": "0dbd10e15b31add2c48856fd34451adabf50d276efa466fe19a8ef5fbd87ad7c",
52+
"ctn_names": "diun",
53+
"ctn_size": "0B",
54+
"ctn_state": "running",
55+
"ctn_status": "Up Less than a second (health: starting)"
56+
}
4857
}
4958
```
5059

docs/providers/docker.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,28 @@ Include created and exited containers too (default `false`).
173173
174174
You can configure more finely the way to analyze the image of your container through Docker labels:
175175
176-
| Name | Default | Description |
177-
|---------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
178-
| `diun.enable` | | Set to true to enable image analysis of this container |
179-
| `diun.regopt` | | [Registry options](../config/regopts.md) name to use |
180-
| `diun.watch_repo` | `false` | Watch all tags of this container image ([be careful](../faq.md#docker-hub-rate-limits) with this setting) |
181-
| `diun.notify_on` | `new;update` | Semicolon separated list of status to be notified: `new`, `update` |
182-
| `diun.sort_tags` | `reverse` | [Sort tags method](../faq.md#tags-sorting-when-using-watch_repo) if `diun.watch_repo` enabled. One of `default`, `reverse`, `semver`, `lexicographical` |
183-
| `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them |
184-
| `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` |
185-
| `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` |
186-
| `diun.hub_link` | _automatic_ | Set registry hub link for this image |
187-
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
176+
| Name | Default | Description |
177+
|---------------------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
178+
| `diun.enable` | | Set to true to enable image analysis of this container |
179+
| `diun.regopt` | | [Registry options](../config/regopts.md) name to use |
180+
| `diun.watch_repo` | `false` | Watch all tags of this container image ([be careful](../faq.md#docker-hub-rate-limits) with this setting) |
181+
| `diun.notify_on` | `new;update` | Semicolon separated list of status to be notified: `new`, `update` |
182+
| `diun.sort_tags` | `reverse` | [Sort tags method](../faq.md#tags-sorting-when-using-watch_repo) if `diun.watch_repo` enabled. One of `default`, `reverse`, `semver`, `lexicographical` |
183+
| `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them |
184+
| `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` |
185+
| `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` |
186+
| `diun.hub_link` | _automatic_ | Set registry hub link for this image |
187+
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
188+
| `diun.metadata.*` | See [below](#default-metadata) | Additional metadata that can be used in [notification template](../faq.md#notification-template) (e.g. `diun.metadata.foo=bar`) |
189+
190+
## Default metadata
191+
192+
| Key | Description |
193+
|-------------------------------|-------------------------|
194+
| `diun.metadata.ctn_id` | Container ID |
195+
| `diun.metadata.ctn_names` | Container names |
196+
| `diun.metadata.ctn_command` | Container command |
197+
| `diun.metadata.ctn_createdat` | Container creation date |
198+
| `diun.metadata.ctn_state` | Container state |
199+
| `diun.metadata.ctn_status` | Container status |
200+
| `diun.metadata.ctn_size` | Container size |

docs/providers/dockerfile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ providers:
3737
# syntax=docker/dockerfile:1.2
3838

3939
# diun.platform=linux/amd64
40+
# diun.metadata.foo=bar
4041
FROM alpine:latest
4142

4243
# diun.watch_repo=true
@@ -117,3 +118,4 @@ The following annotations can be added as comments before the target instruction
117118
| `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` |
118119
| `diun.hub_link` | _automatic_ | Set registry hub link for this image |
119120
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
121+
| `diun.metadata.*` | | Additional metadata that can be used in [notification template](../faq.md#notification-template) (e.g. `metadata.foo=bar`) |

docs/providers/file.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ providers:
4848
regopt: myregistry
4949

5050
# Watch coreos/hyperkube image on quay.io (Quay) and assume latest tag.
51+
# Add foo=bar metadata to be used in notification template.
5152
- name: quay.io/coreos/hyperkube
53+
metadata:
54+
foo: bar
5255

5356
# Watch crazymax/swarm-cronjob image and assume docker.io registry and latest tag
5457
# with registry options named 'docker.io/crazymax' (image selector).
@@ -186,3 +189,4 @@ The configuration file(s) defines a slice of images to analyze with the followin
186189
| `platform.os` | _automatic_ | Operating system to use as custom platform |
187190
| `platform.arch` | _automatic_ | CPU architecture to use as custom platform |
188191
| `platform.variant` | _automatic_ | Variant of the CPU to use as custom platform |
192+
| `metadata.*` | | Additional metadata that can be used in [notification template](../faq.md#notification-template) (e.g. `metadata.foo=bar`) |

docs/providers/kubernetes.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,27 @@ Enable watch by default. If false, pods that don't have `diun.enable: "true"` an
282282

283283
You can configure more finely the way to analyze the image of your pods through Kubernetes annotations:
284284

285-
| Name | Default | Description |
286-
|---------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
287-
| `diun.enable` | | Set to true to enable image analysis of this pod |
288-
| `diun.regopt` | | [Registry options](../config/regopts.md) name to use |
289-
| `diun.watch_repo` | `false` | Watch all tags of this pod image ([be careful](../faq.md#docker-hub-rate-limits) with this setting) |
290-
| `diun.notify_on` | `new;update` | Semicolon separated list of status to be notified: `new`, `update`. |
291-
| `diun.sort_tags` | `reverse` | [Sort tags method](../faq.md#tags-sorting-when-using-watch_repo) if `diun.watch_repo` enabled. One of `default`, `reverse`, `semver`, `lexicographical` |
292-
| `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them |
293-
| `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` |
294-
| `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` |
295-
| `diun.hub_link` | _automatic_ | Set registry hub link for this image |
296-
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
285+
| Name | Default | Description |
286+
|---------------------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
287+
| `diun.enable` | | Set to true to enable image analysis of this pod |
288+
| `diun.regopt` | | [Registry options](../config/regopts.md) name to use |
289+
| `diun.watch_repo` | `false` | Watch all tags of this pod image ([be careful](../faq.md#docker-hub-rate-limits) with this setting) |
290+
| `diun.notify_on` | `new;update` | Semicolon separated list of status to be notified: `new`, `update`. |
291+
| `diun.sort_tags` | `reverse` | [Sort tags method](../faq.md#tags-sorting-when-using-watch_repo) if `diun.watch_repo` enabled. One of `default`, `reverse`, `semver`, `lexicographical` |
292+
| `diun.max_tags` | `0` | Maximum number of tags to watch if `diun.watch_repo` enabled. `0` means all of them |
293+
| `diun.include_tags` | | Semicolon separated list of regular expressions to include tags. Can be useful if you enable `diun.watch_repo` |
294+
| `diun.exclude_tags` | | Semicolon separated list of regular expressions to exclude tags. Can be useful if you enable `diun.watch_repo` |
295+
| `diun.hub_link` | _automatic_ | Set registry hub link for this image |
296+
| `diun.platform` | _automatic_ | Platform to use (e.g. `linux/amd64`) |
297+
| `diun.metadata.*` | See [below](#default-metadata) | Additional metadata that can be used in [notification template](../faq.md#notification-template) (e.g. `diun.metadata.foo=bar`) |
298+
299+
## Default metadata
300+
301+
| Key | Description |
302+
|-------------------------------|-------------------|
303+
| `diun.metadata.pod_name` | Pod name |
304+
| `diun.metadata.pod_status` | Pod status |
305+
| `diun.metadata.pod_namespace` | Pod namespace |
306+
| `diun.metadata.pod_createdat` | Pod creation date |
307+
| `diun.metadata.ctn_name` | Container name |
308+
| `diun.metadata.ctn_command` | Container command |

0 commit comments

Comments
 (0)