puller

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package puller provides a way to pull OCI images from a registry. It uses the oras library to pull images.

Index

Constants

View Source
const (
	// Rulesfile represents a rules file artifact.
	Rulesfile ArtifactType = "rulesfile"
	// Plugin represents a plugin artifact.
	Plugin ArtifactType = "plugin"
	// Asset represents an artifact consumed by another plugin.
	Asset ArtifactType = "asset"

	// FalcoRulesfileConfigMediaType is the MediaType for rule's config layer.
	FalcoRulesfileConfigMediaType = "application/vnd.cncf.falco.rulesfile.config.v1+json"

	// FalcoRulesfileLayerMediaType is the MediaType for rules.
	FalcoRulesfileLayerMediaType = "application/vnd.cncf.falco.rulesfile.layer.v1+tar.gz"

	// FalcoPluginConfigMediaType is the MediaType for plugin's config layer.
	FalcoPluginConfigMediaType = "application/vnd.cncf.falco.plugin.config.v1+json"

	// FalcoPluginLayerMediaType is the MediaType for plugins.
	FalcoPluginLayerMediaType = "application/vnd.cncf.falco.plugin.layer.v1+tar.gz"

	// FalcoAssetConfigMediaType is the MediaType for asset's config layer.
	FalcoAssetConfigMediaType = "application/vnd.cncf.falco.asset.config.v1+json"

	// FalcoAssetLayerMediaType is the MediaType for assets.
	FalcoAssetLayerMediaType = "application/vnd.cncf.falco.asset.layer.v1+tar.gz"

	// DefaultTag is the default tag reference to be used when none is provided.
	DefaultTag = "latest"
)

Variables

This section is empty.

Functions

func MakeTarGz added in v0.2.0

func MakeTarGz(filename string, content []byte) ([]byte, error)

MakeTarGz creates a minimal valid tar.gz archive containing a single file with the given name and content. Useful for seeding mock filesystems in tests.

Types

type ArtifactConfig

type ArtifactConfig struct {
	// It's the unique name used by the index
	Name         string                `json:"name,omitempty"`
	Version      string                `json:"version,omitempty"`
	Dependencies []ArtifactDependency  `json:"dependencies,omitempty"`
	Requirements []ArtifactRequirement `json:"requirements,omitempty"`
}

ArtifactConfig is the struct stored in the config layer of rulesfile and plugin artifacts. Each type fills only the fields of interest.

type ArtifactDependency

type ArtifactDependency struct {
	Name         string       `json:"name"`
	Version      string       `json:"version"`
	Alternatives []Dependency `json:"alternatives,omitempty"`
}

ArtifactDependency represents the artifact's depedendency to be stored in the config.

type ArtifactRequirement

type ArtifactRequirement struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ArtifactRequirement represents the artifact's requirement to be stored in the config.

type ArtifactType

type ArtifactType string

ArtifactType represents a rules file or a plugin. Used to select the right mediaType when interacting with the registry.

func (*ArtifactType) Set

func (e *ArtifactType) Set(v string) error

Set an ArtifactType.

func (ArtifactType) String

func (e ArtifactType) String() string

String returns a string representation of ArtifactType.

func (*ArtifactType) Type

func (e *ArtifactType) Type() string

Type returns a string representing this type.

type Dependency

type Dependency struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Dependency represent a dependency with its own name and version.

type MockOCIPuller added in v0.2.0

type MockOCIPuller struct {
	// Result is returned on a successful pull. Must be set when PullErr is nil.
	Result *RegistryResult
	// PullErr is returned instead of pulling when set.
	PullErr error
	// FS is the filesystem used to write the archive on a successful pull.
	// When set, Pull writes a minimal valid tar.gz archive to destDir/Result.Filename
	// so that the caller (e.g. Manager.StoreFromOCI) can open and extract it.
	FS        filesystem.FileSystem
	PullCalls []PullCall
}

MockOCIPuller implements Puller for testing.

func (*MockOCIPuller) Pull added in v0.2.0

func (m *MockOCIPuller) Pull(ctx context.Context, ref, destDir, os, arch string, creds auth.CredentialFunc, opts *RegistryOptions) (*RegistryResult, error)

Pull records the call and returns the preset result or error. When FS is set and Result is non-nil, it writes a minimal tar.gz archive to destDir/Result.Filename before returning so the full StoreFromOCI path can proceed.

type OciPuller added in v0.2.0

type OciPuller struct {
	// contains filtered or unexported fields
}

OciPuller implements the Puller interface for OCI artifacts. It holds optional default RegistryOptions that are used when no per-pull options are provided.

func NewOciPuller added in v0.2.0

func NewOciPuller(defaults *RegistryOptions) *OciPuller

NewOciPuller creates a new puller with optional default registry options. Pass nil to use system defaults (HTTPS, system CAs).

func (*OciPuller) Pull added in v0.2.0

func (p *OciPuller) Pull(ctx context.Context, ref, destDir, os, arch string, creds auth.CredentialFunc, opts *RegistryOptions) (*RegistryResult, error)

Pull an artifact from a remote registry. Ref format follows: REGISTRY/REPO[:TAG|@DIGEST]. Ex. localhost:5000/hello:latest. When opts is non-nil it overrides the puller defaults entirely.

type PullCall added in v0.2.0

type PullCall struct {
	Ref     string
	DestDir string
	OS      string
	Arch    string
	Opts    *RegistryOptions
}

PullCall records the arguments of a Pull invocation.

type Puller

type Puller interface {
	Pull(ctx context.Context, ref, destDir, os, arch string, creds auth.CredentialFunc, opts *RegistryOptions) (*RegistryResult, error)
}

Puller defines the interface for pulling OCI artifacts.

type RegistryOptions added in v0.2.0

type RegistryOptions struct {
	PlainHTTP          bool
	InsecureSkipVerify bool
}

RegistryOptions contains resolved registry transport configuration. nil = use system defaults (HTTPS, system CAs).

type RegistryResult

type RegistryResult struct {
	RootDigest string
	Digest     string
	Config     ArtifactConfig
	Type       ArtifactType
	Filename   string
}

RegistryResult represents a generic result that is generated when interacting with a remote OCI registry.

Jump to

Keyboard shortcuts

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