modregistry

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("module not found")

Functions

This section is empty.

Types

type CheckedModule

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

CheckedModule represents module content that has passed the same checks made by Client.PutModule. The caller should not mutate any of the values returned by its methods.

func CheckModule

func CheckModule(m module.Version, blobr io.ReaderAt, size int64) (*CheckedModule, error)

CheckModule checks a module's zip file before uploading it. This does the same checks that Client.PutModule does, so can be used to avoid doing duplicate work when an uploader wishes to do more checks that are implemented by that method.

Note that the returned CheckedModule value contains r, so will be invalidated if r is closed.

func (*CheckedModule) ModFile

func (m *CheckedModule) ModFile() *modfile.File

Version returns the parsed contents of the modules cue.mod/module.cue file.

func (*CheckedModule) ModFileContent

func (m *CheckedModule) ModFileContent() []byte

ModFileContent returns the raw contents of the modules cue.mod/module.cue file.

func (*CheckedModule) Version

func (m *CheckedModule) Version() module.Version

Version returns the version that the module will be tagged as.

func (*CheckedModule) Zip

func (m *CheckedModule) Zip() *zip.Reader

Zip returns the reader for the module's zip archive.

type Client

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

Client represents a OCI-registry-backed client that provides a store for CUE modules.

func NewClient

func NewClient(registry ociregistry.Interface) *Client

NewClient returns a new client that talks to the registry at the given hostname.

func (*Client) GetModule

func (c *Client) GetModule(ctx context.Context, m module.Version) (*Module, error)

GetModule returns the module instance for the given version. It returns an error that satisfies errors.Is(ErrNotFound) if the module is not present in the store at this version.

func (*Client) ModuleVersions

func (c *Client) ModuleVersions(ctx context.Context, m string) ([]string, error)

ModuleVersions returns all the versions for the module with the given path.

func (*Client) PutCheckedModule

func (c *Client) PutCheckedModule(ctx context.Context, m *CheckedModule) error

PutCheckedModule is like Client.PutModule except that it allows the caller to do some additional checks (see CheckModule for more info).

func (*Client) PutModule

func (c *Client) PutModule(ctx context.Context, m module.Version, r io.ReaderAt, size int64) error

PutModule puts a module whose contents are held as a zip archive inside f. It assumes all the module dependencies are correctly resolved and present inside the cue.mod/module.cue file.

TODO check deps are resolved correctly? Or is that too domain-specific for this package? Is it a problem to call zip.CheckZip twice?

type Module

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

Module represents a CUE module instance.

func (*Module) GetZip

func (m *Module) GetZip(ctx context.Context) (io.ReadCloser, error)

GetZip returns a reader that can be used to read the contents of the zip archive containing the module files. The reader should be closed after use, and the contents should not be assumed to be correct until the close error has been checked.

func (*Module) ModuleFile

func (m *Module) ModuleFile(ctx context.Context) ([]byte, error)

ModuleFile returns the contents of the cue.mod/module.cue file.

Jump to

Keyboard shortcuts

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