puller

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: Apache-2.0 Imports: 17 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 pullers 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
	// AllowNilResult makes Pull return (nil, nil) when Result is nil.
	AllowNilResult bool
	// LayerContent is the raw layer payload (typically a tar.gz archive) copied to the
	// destination writer when PullErr is nil. If nil, the payload is empty.
	LayerContent []byte
	PullCalls    []PullCall
}

MockOCIPuller implements Puller for testing.

func (*MockOCIPuller) Pull added in v0.2.0

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

Pull records the call, writes LayerContent to dst, and returns the preset result.

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, os, arch string, creds auth.CredentialFunc, opts *RegistryOptions, dst io.Writer) (*RegistryResult, error)

Pull resolves ref to its artifact layer and copies the compressed layer payload into dst.

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
	OS   string
	Arch string
	Opts *RegistryOptions
}

PullCall records the arguments of a Pull invocation.

type Puller

type Puller interface {
	Pull(ctx context.Context, ref, os, arch string, creds auth.CredentialFunc, opts *RegistryOptions, dst io.Writer) (*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