Documentation
¶
Overview ¶
Package xdef provides shared definitions for ctx42 container images: OCI Image Spec label names, their matching container environment variable names, placeholder values for unknown build metadata, and helpers for reading those variables from a process environment slice.
Index ¶
Constants ¶
const ( // LabImgCreated is the OCI Image Spec label for the date and time on which // the image was built. The value must be in RFC3339 format. If the build // date is unknown, set it to "0001-01-01T00:00:00Z". // // Example: 2000-01-02T03:04:05.678Z LabImgCreated = "org.opencontainers.image.created" // LabImgTitle is the OCI Image Spec label for the human-readable name of // the application packaged in the image. // // Example: echo-server LabImgTitle = "org.opencontainers.image.title" // LabImgDesc is the OCI Image Spec label for a human-readable description // of the software packaged in the image. // // Example: Minimal HTTP echo server. LabImgDesc = "org.opencontainers.image.description" // LabImgAuthors is the OCI Image Spec label for the contact details of the // people or organization responsible for the image. LabImgAuthors = "org.opencontainers.image.authors" // LabImgSrc is the OCI Image Spec label for the URL to the source code // repository used to build the image. // // Example: https://github.com/ctx42/xdef.git LabImgSrc = "org.opencontainers.image.source" // LabImgVer is the OCI Image Spec label for the version of the packaged // software. It should match the SCM revision tag. // // Example: v1.2.3 LabImgVer = "org.opencontainers.image.version" // LabImgRev is the OCI Image Spec label for the SCM commit hash from which // the image was built. // // Example: 1a12ec31 LabImgRev = "org.opencontainers.image.revision" // LabImgRefName is the OCI Image Spec annotation for the name of the // image reference (e.g., a registry tag). OCI does not prescribe a specific // format. It may be used, for example, as a CI/CD build tag that uniquely // identifies the pipeline job which produced the image. // // Example: jenkins-project-master-29 LabImgRefName = "org.opencontainers.image.ref.name" // LabImgBaseName is the OCI Image Spec label for the reference of the base // image used to build this image. // // Example: busybox:1.36.1-uclibc LabImgBaseName = "org.opencontainers.image.base.name" )
Docker image labels following OCI Image Spec annotation keys. See: https://specs.opencontainers.org/image-spec/annotations/
const ( // EnvImgCreated is the container environment variable mirroring the // [LabImgCreated] label. It holds the image build date in RFC3339 format. // // Example: 2000-01-02T03:04:05.678Z EnvImgCreated = "OCI_IMAGE_CREATED" // EnvImgTitle is the container environment variable mirroring the // [LabImgTitle] label. It holds the human-readable application name. // // Example: echo-server EnvImgTitle = "OCI_IMAGE_TITLE" // EnvImgAuthors is the container environment variable mirroring the // [LabImgAuthors]. It holds the contact details of the people or // organization responsible for the image. EnvImgAuthors = "OCI_IMAGE_AUTHORS" // EnvImgDesc is the container environment variable mirroring the // [LabImgDesc] label. It holds a human-readable description of the // software packaged in the image. EnvImgDesc = "OCI_IMAGE_DESCRIPTION" // EnvImgSrc is the container environment variable mirroring the // [LabImgSrc]. It holds the URL to the source code repository used to // build the image. // // Example: https://github.com/ctx42/testkit.git EnvImgSrc = "OCI_IMAGE_SOURCE" // EnvImgVer is the container environment variable mirroring the // [LabImgVer] label. It holds the version of the packaged software, // matching the SCM revision tag. // // Example: v1.2.3 EnvImgVer = "OCI_IMAGE_VERSION" // EnvImgRev is the container environment variable mirroring the // [LabImgRev] label. It holds the SCM commit hash from which the image was // built. // // Example: 1a12ec31 EnvImgRev = "OCI_IMAGE_REVISION" // EnvImgRefName is the container environment variable mirroring the // [LabImgRefName] annotation (e.g., a registry tag). OCI does not // prescribe a specific format. It may be used, for example, as a CI/CD build // tag that uniquely identifies the pipeline job which produced the image. // // Example: jenkins-skw-tst-master-29 EnvImgRefName = "OCI_IMAGE_REF_NAME" // EnvImgBaseName is the container environment variable mirroring the // [LabImgBaseName] label. // // Example: busybox:1.36.1-uclibc EnvImgBaseName = "OCI_IMAGE_BASE_NAME" )
Environment variables set in Docker images. The OCI_IMAGE_* variables mirror the OCI Image Spec labels inside the container. The CTX42_* variables are ctx42-specific.
const ( // PhHash defines placeholder unknown hash value. PhHash = "0000000" // PhRev defines placeholder for unknown revision value. PhRev = "v0.0.0" // PhUnknown defines placeholder for unknown values. PhUnknown = "unknown" // PhTime defines placeholder for unknown (zero value) time. PhTime = "0001-01-01T00:00:00Z" )
Placeholders.
Variables ¶
This section is empty.
Functions ¶
func Created ¶
Created returns the value of the EnvImgCreated environment variable. Returns the current UTC date in RFC3339 format if the variable is not set or is empty.
func CreatedStr ¶
func CreatedStr() string
CreatedStr returns the current date in UTC formatted as time.RFC3339Nano, truncated to millisecond precision.
func ImgRefName ¶
ImgRefName returns the value of EnvImgRefName environment variable. When the environment variable is not set, it will return a string formatted like "no-ccid-240808100435-885410365" where the first set of numbers is the current date and the second is the number of nanoseconds.
Types ¶
This section is empty.