ocitest

package
v1.223.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package ocitest provides an in-process OCI registry for tests, so tests never depend on real network access or a real container registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRegistry

func NewRegistry(t *testing.T, repoTag string, files map[string]string) string

NewRegistry starts an in-process OCI registry serving a single image built from files (archive path -> content, one uncompressed-tar layer). It returns the bare image reference "127.0.0.1:PORT/repoTag" (no "oci://" prefix, no scheme) -- callers building a component source.uri prefix it with "oci://" themselves. The go-containerregistry name.ParseReference function treats "127.0.0.1:PORT" addresses as plain HTTP automatically (see go-containerregistry's pkg/name/registry.go reLoopback), so no Insecure option is needed. The registry's httptest.Server is closed automatically via t.Cleanup.

func NewZipRegistry

func NewZipRegistry(t *testing.T, repoTag string, files map[string]string) string

NewZipRegistry starts an in-process OCI registry serving a single image whose sole layer is a ZIP archive with media type "archive/zip" -- the format OpenTofu's native "install modules from OCI registries" feature uses (see https://opentofu.org, artifactType application/vnd.opentofu.modulepkg). Unlike NewRegistry's layer, this one is not gzip-wrapped: the blob is the raw zip bytes, matching what real OpenTofu module-package registries serve.

Types

This section is empty.

Jump to

Keyboard shortcuts

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