client

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Login authenticates against the given registry endpoint using username and password.
	Login(ctx context.Context, registry, user, pass string) error

	// Push uploads the local file at path to the specified reference
	// (e.g., registry/repo:tag) in the remote registry.
	Push(ctx context.Context, reference, path string) error

	// Pull downloads the artifact identified by reference from the registry
	// and returns its raw data bytes.
	Pull(ctx context.Context, reference string) ([]byte, error)
}

Client defines the interface for interacting with remote artifact registries over HTTP or OCI protocols. It supports login, push, and pull operations.

func NewClient

func NewClient(cfg *config.Config, reference string) Client

NewClient constructs a Client implementation based on the reference type. HTTP(S) references use an HTTP client; OCI references use an OCI client. Default fallback is OCI client for any non-HTTP references.

func NewOCIClient

func NewOCIClient(cfg *config.Config) Client

NewOCIClient returns a new OCIClient initialized with the given configuration.

type HTTPClient

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

HTTPClient provides basic HTTP(S) access for fetching remote Makefile artifacts. It implements the Client interface with no-op Login and Push methods.

func NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient returns a new HTTPClient using the default HTTP client.

func (*HTTPClient) Login

func (h *HTTPClient) Login(ctx context.Context, registry, user, pass string) error

Login is a no-op for HTTPClient since HTTP references do not require authentication.

func (*HTTPClient) Pull

func (h *HTTPClient) Pull(ctx context.Context, reference string) (data []byte, err error)

Pull performs an HTTP GET request to fetch the artifact data from the given URL. It returns the raw response body bytes or an error on non-200 status codes or failures.

func (*HTTPClient) Push

func (h *HTTPClient) Push(ctx context.Context, reference, path string) error

Push is a no-op for HTTPClient as pushing over HTTP is not supported.

type OCIClient

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

OCIClient provides an implementation of Client for OCI registries. It uses oras and go-containerregistry to authenticate, push, and pull artifacts.

func (*OCIClient) Login

func (c *OCIClient) Login(ctx context.Context, registry, user, pass string) error

Login authenticates to the specified OCI registry using the provided credentials. Successful login is persisted in the configuration file for future operations.

func (*OCIClient) Pull

func (c *OCIClient) Pull(ctx context.Context, reference string) ([]byte, error)

Pull downloads the artifact data for the given reference from the OCI registry. It retrieves the manifest and returns the contents of the first layer (Makefile data).

func (*OCIClient) Push

func (c *OCIClient) Push(ctx context.Context, reference, path string) error

Push uploads the local file at path as an OCI artifact to the given reference. It tags the artifact with the reference identifier and pushes it to the remote repository.

Jump to

Keyboard shortcuts

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