Docker Digest
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
Description
The dockerdigest resource resolves a container image tag to the digest it currently points at, so deployments can pin an immutable reference instead of a mutable tag.
- source
Returns the digest for
imageandtag, in the formjenkins/jenkins:lts-jdk11@sha256:….- condition
Checks that an image exists in the registry for the given digest -
digestwhen set, otherwise the source output. A missing image reportsthe Docker image <ref> doesn’t exist.rather than erroring.- target
Not supported - a target fails with
Target not supported for the plugin Docker Digest. Write the digest into a file with the "Yaml" or "File" resources.
Note | An scm is accepted but ignored, logging scm is not supported, ignoring. The lookup always goes to the registry. |
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| architecture | string | “architecture” defines the platform of the container image, as “ compatible:
remark:
example:
| |
| digest | string | “digest” defines the container image digest to check. compatible:
default: the output of the associated source. remark:
example:
| |
| hidetag | boolean | “hidetag” removes the tag from the source output. compatible:
default: false remark:
| |
| image | string | “image” defines the container image name. compatible:
example:
| |
| password | string | “password” defines the container registry password used for authentication. default:
credentials are retrieved from the local environment, such as remark:
| |
| tag | string | “tag” defines the container image tag. compatible:
default: latest remark:
example:
| |
| token | string | “token” defines the container registry bearer token used for authentication. default:
credentials are retrieved from the local environment, such as remark:
| |
| username | string | “username” defines the container registry username used for authentication. default:
credentials are retrieved from the local environment, such as remark:
|
imageMandatory, e.g.
updatecli/updatecli.tagDefaults to
latest. It must not already contain a digest (a value starting with@is rejected withinvalid tag <image>: only contain a digest).architectureDefaults to
amd64. Unset, the digest returned is that of the image index, valid on any platform; set, it is the digest of that one platform’s image. The two are different values for the same tag.digestCondition only, defaulting to the source output.
hidetagSource only. Changes the shape of the returned value.
hidetag
By default the source keeps the tag alongside the digest, which stays readable in a diff while still pinning the exact image:
index.docker.io/jenkins/jenkins:lts-jdk11@sha256:ce782db15ab...With hidetag: true the tag is dropped:
index.docker.io/jenkins/jenkins@sha256:ce782db15ab...Authentication
Credentials are given inline on the spec. Depending on the registry, how you obtain a token differs.
Important | Storing credentials in an unencrypted manifest is a bad practice. Read them from the environment with '{{ requiredEnv "TOKEN" }}'. |
GHCR
GitHub uses a personal access token (see Creating a personal access token).
DockerHub
The simplest route is to run docker login and read the token from ~/.docker/config.json:
"auths": {
"https://index.docker.io/v1/": {
"auth": "token"
}
},Example
This example uses a Go template, updatecli.tpl, with values from values.yaml, so that {{ requiredEnv "…" }} can read the GitHub token from the environment.
# updatecli.tpl
sources:
lastDockerDigest:
kind: dockerdigest
spec:
image: "jenkins/jenkins"
tag: "lts-jdk11"
targets:
imageTag:
name: "jenkins/jenkins:lts-jdk11 docker digest"
kind: yaml
spec:
file: "config/default/jenkins-release.yaml"
key: "jenkins.master.imageTag"
scm:
github:
user: "{{ .github.user }}"
email: "{{ .github.email }}"
owner: "jenkins-infra"
repository: "charts"
token: "{{ requiredEnv .github.token }}"
username: "{{ .github.username }}"
branch: "master"# values.yaml
github:
user: "updatebot"
email: "updatebot@olblak.com"
username: "jenkins-infra-bot"
token: "UPDATECLI_GITHUB_TOKEN"
branch: "master"
owner: "olblak"
repository: "charts"What it says:
- Source
Retrieve the digest of
jenkins/jenkins:lts-jdk11from DockerHub.- Target
Update the YAML key
jenkins.master.imageTaginconfig/default/jenkins-release.yamlin the GitHub repositoryjenkins-infra/charts.
Links
The
dockerimageresource - to find a tag rather than resolve one