mirror

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUpstreamNotFound = errors.New("not found upstream")
)

Functions

func ErrorEncoder

func ErrorEncoder(_ context.Context, err error, w http.ResponseWriter)

ErrorEncoder translates domain specific errors to HTTP status codes

func MakeHandler

func MakeHandler(svc Service, auth endpoint.Middleware, metrics *o11y.MirrorMetrics, instrumentation o11y.Middleware, options ...httptransport.ServerOption) http.Handler

MakeHandler returns a fully initialized http.Handler.

Types

type Archive

type Archive struct {
	Url    string   `json:"url"`
	Hashes []string `json:"hashes,omitempty"`
}

type Copier

type Copier interface {
	// contains filtered or unexported methods
}

func NewCopier

func NewCopier(ctx context.Context, storage Storage) Copier

type EmptyObject

type EmptyObject struct{}

EmptyObject exists to return an `{}` JSON object to match the protocol spec

type ListProviderInstallationResponse

type ListProviderInstallationResponse struct {
	Archives map[string]Archive `json:"archives"`
	// contains filtered or unexported fields
}

type ListProviderVersionsResponse

type ListProviderVersionsResponse struct {
	Versions map[string]EmptyObject `json:"versions"`
	// contains filtered or unexported fields
}

ListProviderVersionsResponse holds the response that is passed to the endpoint

type Middleware

type Middleware func(Service) Service

Middleware is a Service middleware.

func LoggingMiddleware

func LoggingMiddleware() Middleware

LoggingMiddleware is a logging Service middleware.

type Service

type Service interface {
	// ListProviderVersions determines which versions are currently available for a particular provider
	// https://www.terraform.io/docs/internals/provider-network-mirror-protocol.html#list-available-versions
	ListProviderVersions(ctx context.Context, provider *core.Provider) (*ListProviderVersionsResponse, error)

	// ListProviderInstallation returns download URLs and associated metadata for the distribution packages for a particular version of a provider
	// https://www.terraform.io/docs/internals/provider-network-mirror-protocol.html#list-available-installation-packages
	ListProviderInstallation(ctx context.Context, provider *core.Provider) (*ListProviderInstallationResponse, error)

	// RetrieveProviderArchive returns an io.Reader of a zip archive containing the provider binary for a given provider
	RetrieveProviderArchive(ctx context.Context, provider *core.Provider) (*retrieveProviderArchiveResponse, error)
}

Service implements the Provider Network Mirror Protocol. For more information see: https://www.terraform.io/docs/internals/provider-network-mirror-protocol.html

func NewMirror

func NewMirror(s Storage) Service

func NewPullThroughMirror

func NewPullThroughMirror(s Storage, c Copier) Service

type Storage

type Storage interface {
	// ListMirroredProviderVersions returns all matching provider versions for a given hostname, namespace, and name
	// The provider version can be set to narrow-down the search and return only a single provider
	ListMirroredProviders(ctx context.Context, provider *core.Provider) ([]*core.Provider, error)

	// GetMirroredProvider returns the mirrored provider or a core.ProviderError in case it cannot be located
	GetMirroredProvider(ctx context.Context, provider *core.Provider) (*core.Provider, error)

	// UploadMirroredFile uploads a file that belongs to a provider release
	UploadMirroredFile(ctx context.Context, provider *core.Provider, fileName string, reader io.Reader) error

	// MirroredSigningKeys retrieves the signing keys for mirrored providers
	MirroredSigningKeys(ctx context.Context, hostname, namespace string) (*core.SigningKeys, error)

	// UploadMirroredSigningKeys uploads signing keys for mirrored providers
	// Existing signing keys are overwritten
	UploadMirroredSigningKeys(ctx context.Context, hostname, namespace string, signingKeys *core.SigningKeys) error

	// Retrieve the SHA256SUM from storage
	MirroredSha256Sum(ctx context.Context, provider *core.Provider) (*core.Sha256Sums, error)
}

Jump to

Keyboard shortcuts

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