Documentation
¶
Overview ¶
Package oci wraps the shared giantswarm/klaus-oci library and adds klausctl-specific helpers such as CLI cache paths, plugin directory resolution, and container mount path computation.
All OCI media types, metadata types, annotation constants, and the ORAS-based Client come from the shared library. klausctl code should import this package rather than klaus-oci directly to avoid import alias churn.
Index ¶
- Constants
- Variables
- func BuildRef(p config.Plugin) string
- func HasSOULFile(personalityDir string) bool
- func LatestSemverTag(tags []string) string
- func MergePlugins(personalityPlugins []PluginReference, userPlugins []config.Plugin) []config.Plugin
- func PluginDirs(plugins []config.Plugin) []string
- func PluginFromReference(ref PluginReference) config.Plugin
- func PluginRefsFromSpec(refs []PluginReference) []config.Plugin
- func PullPlugins(ctx context.Context, plugins []config.Plugin, pluginsDir string, w io.Writer) error
- func RepositoryFromRef(ref string) string
- func ResolveArtifactRef(ctx context.Context, ref, registryBase, namePrefix string) (string, error)
- func ResolveCreateRefs(ctx context.Context, personality, toolchain string, plugins []string) (string, string, []string, error)
- func ResolvePluginRefs(ctx context.Context, plugins []config.Plugin) ([]config.Plugin, error)
- func ShortPluginName(repository string) string
- func ShortToolchainName(repository string) string
- func SplitNameTag(ref string) (string, string)
- func ToolchainRegistryRef(name string) string
- type ArtifactInfo
- type ArtifactKind
- type CacheEntry
- type Client
- type ClientOption
- type PersonalityMeta
- type PersonalityResult
- type PersonalitySpec
- type PluginMeta
- type PluginReference
- type PullResult
- type PushResult
- type TagLister
- type ToolchainMeta
Constants ¶
const ( MediaTypePluginConfig = klausoci.MediaTypePluginConfig MediaTypePluginContent = klausoci.MediaTypePluginContent MediaTypePersonalityConfig = klausoci.MediaTypePersonalityConfig MediaTypePersonalityContent = klausoci.MediaTypePersonalityContent AnnotationKlausType = klausoci.AnnotationKlausType AnnotationKlausName = klausoci.AnnotationKlausName AnnotationKlausVersion = klausoci.AnnotationKlausVersion TypePlugin = klausoci.TypePlugin TypePersonality = klausoci.TypePersonality TypeToolchain = klausoci.TypeToolchain )
Re-exported media type and annotation constants.
const ( DefaultPluginRegistry = "gsoci.azurecr.io/giantswarm/klaus-plugins" DefaultPersonalityRegistry = "gsoci.azurecr.io/giantswarm/klaus-personalities" DefaultToolchainRegistry = "gsoci.azurecr.io/giantswarm" )
DefaultRegistries defines the default OCI registry base paths for each artifact type, used by the list --remote commands.
const RegistryAuthEnvVar = "KLAUSCTL_REGISTRY_AUTH"
RegistryAuthEnvVar is the environment variable checked for base64-encoded Docker config JSON credentials. This supplements the default Docker/Podman config file resolution and is primarily useful in CI/headless environments where `az acr login` is not available.
Variables ¶
var ( NewClient = klausoci.NewClient WithPlainHTTP = klausoci.WithPlainHTTP WithRegistryAuthEnv = klausoci.WithRegistryAuthEnv PluginArtifact = klausoci.PluginArtifact PersonalityArtifact = klausoci.PersonalityArtifact IsCached = klausoci.IsCached ReadCacheEntry = klausoci.ReadCacheEntry ShortName = klausoci.ShortName TruncateDigest = klausoci.TruncateDigest )
Re-exported constructors, options, and helpers.
Functions ¶
func HasSOULFile ¶ added in v0.0.10
HasSOULFile reports whether a pulled personality directory contains a SOUL.md.
func LatestSemverTag ¶ added in v0.0.16
LatestSemverTag returns the highest semver tag from the given list. Tags that are not valid semver are ignored.
func MergePlugins ¶ added in v0.0.10
func MergePlugins(personalityPlugins []PluginReference, userPlugins []config.Plugin) []config.Plugin
MergePlugins merges personality plugins with user-configured plugins. User plugins take precedence: if a personality plugin and a user plugin share the same repository, the user's version is kept. Personality-only plugins are appended after user plugins.
func PluginDirs ¶
PluginDirs returns the container-internal mount paths for the given plugins. Each plugin is mounted at /var/lib/klaus/plugins/<shortName>.
func PluginFromReference ¶ added in v0.0.10
func PluginFromReference(ref PluginReference) config.Plugin
PluginFromReference converts a klaus-oci PluginReference to a config.Plugin.
func PluginRefsFromSpec ¶ added in v0.0.16
func PluginRefsFromSpec(refs []PluginReference) []config.Plugin
PluginRefsFromSpec converts personality spec plugin references to config.Plugin entries.
func PullPlugins ¶
func PullPlugins(ctx context.Context, plugins []config.Plugin, pluginsDir string, w io.Writer) error
PullPlugins pulls all configured plugins to the local plugins directory. Each plugin is stored at <pluginsDir>/<shortName>/. Plugins are cached by digest and skipped if already up-to-date. Progress messages are written to w.
Plugins with a "latest" tag or no tag are resolved to the latest semver tag from the registry before pulling.
func RepositoryFromRef ¶ added in v0.0.16
RepositoryFromRef extracts the repository part from an OCI reference, stripping the tag or digest suffix. Handles both repo:tag and repo@sha256:digest formats. Port-only colons (e.g. localhost:5000/repo) are preserved.
func ResolveArtifactRef ¶ added in v0.0.16
ResolveArtifactRef resolves a short artifact name or OCI reference to a fully-qualified reference with its latest semver tag from the registry.
If the ref already has a tag other than "latest" (or a digest), it is returned as-is. Short names (no "/") are expanded using registryBase and namePrefix (e.g. "go" with prefix "klaus-" becomes "klaus-go").
When no tag is provided or the tag is "latest", the registry is queried for all tags and the highest semver tag is selected.
func ResolveCreateRefs ¶ added in v0.0.16
func ResolveCreateRefs(ctx context.Context, personality, toolchain string, plugins []string) (string, string, []string, error)
ResolveCreateRefs resolves personality, toolchain, and plugin short names to full OCI references with proper semver tags from the registry.
func ResolvePluginRefs ¶ added in v0.0.16
ResolvePluginRefs resolves a slice of config.Plugin entries, replacing "latest" or empty tags with the actual latest semver tag from the registry. Plugins with non-"latest" tags or digests are left unchanged.
func ShortPluginName ¶
ShortPluginName extracts the last segment of a repository path. e.g. "gsoci.azurecr.io/giantswarm/klaus-plugins/gs-platform" -> "gs-platform"
func ShortToolchainName ¶ added in v0.0.12
ShortToolchainName extracts the toolchain name from a full repository path, stripping both the registry prefix and the "klaus-" convention. e.g. "gsoci.azurecr.io/giantswarm/klaus-go" -> "go"
func SplitNameTag ¶ added in v0.0.16
SplitNameTag splits "name:tag" into name and tag. If no colon is present, tag is empty.
func ToolchainRegistryRef ¶ added in v0.0.9
ToolchainRegistryRef returns the full registry reference for a toolchain image name. Toolchains use the pattern gsoci.azurecr.io/giantswarm/klaus-<name>.
Types ¶
type ArtifactInfo ¶ added in v0.0.9
type ArtifactInfo = klausoci.ArtifactInfo
Re-exported types from the shared klaus-oci library.
type ArtifactKind ¶ added in v0.0.9
type ArtifactKind = klausoci.ArtifactKind
Re-exported types from the shared klaus-oci library.
type CacheEntry ¶ added in v0.0.3
type CacheEntry = klausoci.CacheEntry
Re-exported types from the shared klaus-oci library.
type Client ¶ added in v0.0.3
Re-exported types from the shared klaus-oci library.
func NewDefaultClient ¶ added in v0.0.9
func NewDefaultClient(opts ...ClientOption) *Client
NewDefaultClient creates an OCI client configured with the standard klausctl credential resolution: Docker/Podman config files plus the KLAUSCTL_REGISTRY_AUTH environment variable.
type ClientOption ¶ added in v0.0.3
type ClientOption = klausoci.ClientOption
Re-exported types from the shared klaus-oci library.
type PersonalityMeta ¶ added in v0.0.9
type PersonalityMeta = klausoci.PersonalityMeta
Re-exported types from the shared klaus-oci library.
type PersonalityResult ¶ added in v0.0.10
type PersonalityResult struct {
// Spec is the parsed personality.yaml content.
Spec PersonalitySpec
// Dir is the local directory where the personality was pulled.
Dir string
// ShortName is the short name extracted from the OCI reference.
ShortName string
}
PersonalityResult holds the outcome of resolving a personality artifact.
func ResolvePersonality ¶ added in v0.0.10
func ResolvePersonality(ctx context.Context, ref, personalitiesDir string, w io.Writer) (*PersonalityResult, error)
ResolvePersonality pulls a personality OCI artifact and parses its spec. The personality is stored at <personalitiesDir>/<shortName>/.
type PersonalitySpec ¶ added in v0.0.9
type PersonalitySpec = klausoci.PersonalitySpec
Re-exported types from the shared klaus-oci library.
func LoadPersonalitySpec ¶ added in v0.0.10
func LoadPersonalitySpec(dir string) (PersonalitySpec, error)
LoadPersonalitySpec reads and parses a personality.yaml from the given directory.
type PluginMeta ¶ added in v0.0.3
type PluginMeta = klausoci.PluginMeta
Re-exported types from the shared klaus-oci library.
type PluginReference ¶ added in v0.0.9
type PluginReference = klausoci.PluginReference
Re-exported types from the shared klaus-oci library.
type PullResult ¶ added in v0.0.3
type PullResult = klausoci.PullResult
Re-exported types from the shared klaus-oci library.
type PushResult ¶ added in v0.0.3
type PushResult = klausoci.PushResult
Re-exported types from the shared klaus-oci library.
type TagLister ¶ added in v0.0.16
TagLister can list tags for an OCI repository. Implemented by *Client; declared as an interface to allow unit testing without network access.
type ToolchainMeta ¶ added in v0.0.9
type ToolchainMeta = klausoci.ToolchainMeta
Re-exported types from the shared klaus-oci library.