storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidArtifactType = errors.New("invalid image's artifact type")

Functions

func As

func As[T Artifact](as []Artifact) ([]T, error)

func Context

func Context(ctx context.Context, r Storage) context.Context

func ErrCode

func ErrCode(err error) int

func Error

func Error(w http.ResponseWriter, err error)

func IsErrorCode

func IsErrorCode(err error, code string) bool

func IsNotFound

func IsNotFound(err error) bool

func MustAs

func MustAs[T Artifact](as []Artifact) []T

func Options

func Options(ctx context.Context) options

func WithOptions

func WithOptions(ctx context.Context, opts ...Option) context.Context

Types

type Artifact

type Artifact interface {
	io.ReadCloser
	// Name is the name of the artifact, e.g. "jq".
	Name() string
	// Path is the path of the artifact in the repository.
	Path() string
	// Arch is the architecture of the artifact.
	Arch() string
	// Version is the version of the artifact.
	Version() string
	// Size is the binary size of the artifact.
	Size() int64
	Digest() digest.Digest
}

func AsArtifact

func AsArtifact[T Artifact](as []T) []Artifact

type ArtifactInfo

type ArtifactInfo interface {
	Name() string
	Version() string
	Arch() string
	Path() string
	Size() int64
	Digest() digest.Digest
	Meta() []byte
}

type Codec

type Codec = codec.Codec[Artifact]

type File

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

func NewFile

func NewFile(name string, data []byte) *File

func (*File) Arch

func (f *File) Arch() string

func (*File) Close

func (f *File) Close() error

func (*File) Digest

func (f *File) Digest() digest.Digest

func (*File) Name

func (f *File) Name() string

func (*File) Path

func (f *File) Path() string

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

func (*File) Size

func (f *File) Size() int64

func (*File) Version

func (f *File) Version() string

type MiddlewareFunc

type MiddlewareFunc = func(repoVar string) mux.MiddlewareFunc

func Middleware

func Middleware(ar Repository) MiddlewareFunc

type Option

type Option func(o *options)

func WithArtifactTags

func WithArtifactTags() Option

func WithHost

func WithHost(host string) Option

func WithKey

func WithKey(key []byte) Option

func WithRegistryOptions

func WithRegistryOptions(opts ...registry.Option) Option

func WithRepo

func WithRepo(repo string) Option

type Repository

type Repository interface {
	Index(ctx context.Context, priv string, artifacts ...Artifact) ([]Artifact, error)
	GenerateKeypair() (string, string, error)
	KeyNames() (string, string)
	Codec() Codec
	Name() string
}

type Storage

type Storage interface {
	Init(ctx context.Context) error
	Stat(ctx context.Context, file string) (ArtifactInfo, error)
	Open(ctx context.Context, name string) (io.ReadCloser, error)
	Write(ctx context.Context, a Artifact) error
	Delete(ctx context.Context, name string) error
	Artifacts(ctx context.Context) ([]Artifact, error)
	ServeFile(w http.ResponseWriter, r *http.Request, name string) error
	Size(ctx context.Context) (int64, error)
	Key() string
	Close() error
}

func FromContext

func FromContext(ctx context.Context) Storage

func NewStorage

func NewStorage(ctx context.Context, name string, repo Repository) (Storage, error)

Jump to

Keyboard shortcuts

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