xdef

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT

README

xdef

Go Reference

Single source of truth for shared definitions used across all ctx42 modules: label names, environment variable names, placeholder values, and helpers for reading variables from a process environment slice.

Import

import "github.com/ctx42/xdef/pkg/xdef"

Usage

Read image metadata from a container's environment, falling back to sensible defaults when the variables are absent:

env := os.Environ()

// Returns OCI_IMAGE_CREATED value, or current UTC time in RFC3339Nano
// format (truncated to millisecond precision) if not set.
created := xdef.Created(env)

// Returns OCI_IMAGE_REF_NAME value, or a unique "no-ccid-<timestamp>"
// tag if not set.
refName := xdef.ImgRefName(env)

Placeholder constants are provided for unknown build metadata:

labels := map[string]string{
    xdef.LabImgRev:     xdef.PhHash,
    xdef.LabImgVer:     xdef.PhRev,
    xdef.LabImgCreated: xdef.PhTime,
}

Labels and Environment Variables

OCI label Env variable
org.opencontainers.image.created OCI_IMAGE_CREATED
org.opencontainers.image.title OCI_IMAGE_TITLE
org.opencontainers.image.description OCI_IMAGE_DESCRIPTION
org.opencontainers.image.authors OCI_IMAGE_AUTHORS
org.opencontainers.image.source OCI_IMAGE_SOURCE
org.opencontainers.image.version OCI_IMAGE_VERSION
org.opencontainers.image.revision OCI_IMAGE_REVISION
org.opencontainers.image.ref.name OCI_IMAGE_REF_NAME
org.opencontainers.image.base.name OCI_IMAGE_BASE_NAME

License

MIT — see LICENSE.

Directories

Path Synopsis
pkg
xdef
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.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL