fetcher

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fetcher implements a client for the Constellation Resource API.

The fetcher is used to get information from the versions API without having to authenticate with AWS, where the API is currently hosted. This package should be used in user-facing application code most of the time, like the CLI.

Each sub-API included in the Constellation Resource API should define it's resources by implementing types that implement apiObject. The new package can then call this package's Fetch function to get the resource from the API. To modify resources, pkg internal/api/client should be used in a similar fashion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch[T apiObject](ctx context.Context, c HTTPClient, cdnURL string, obj T) (T, error)

Fetch fetches the given apiObject from the public Constellation CDN. Fetch does not require authentication.

func FetchAndVerify added in v2.10.0

func FetchAndVerify[T apiObject](ctx context.Context, c HTTPClient, cdnURL string, obj T, cosignVerifier sigstore.Verifier) (T, error)

FetchAndVerify fetches the given apiObject, checks if it can fetch an accompanying signature and verifies if the signature matches the found object. The public key used to verify the signature is embedded in the verifier argument. FetchAndVerify uses a generic to return a new object of type T. Otherwise the caller would have to cast the interface type to a concrete object, which could fail.

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface for http clients.

func NewHTTPClient

func NewHTTPClient() HTTPClient

NewHTTPClient returns a new http client.

type NotFoundError

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

NotFoundError is an error that is returned when a resource is not found.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

Jump to

Keyboard shortcuts

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