module

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Module errors
	ErrModuleNotFound      = errors.New("failed to locate module")
	ErrModuleUploadFailed  = errors.New("failed to upload module")
	ErrModuleAlreadyExists = errors.New("module already exists")
	ErrModuleListFailed    = errors.New("failed to list module versions")
)

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.ModuleMetrics, instrumentation o11y.Middleware, options ...httptransport.ServerOption) http.Handler

MakeHandler returns a fully initialized http.Handler.

Types

type InmemStorage

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

InmemStorage is a Storage implementation This storage is typically used for testing purposes.

func (*InmemStorage) GetModule

func (s *InmemStorage) GetModule(_ context.Context, namespace, name, provider, version string) (core.Module, error)

GetModule retrieves information about a module from the in-memory storage.

func (*InmemStorage) ListModuleVersions

func (s *InmemStorage) ListModuleVersions(ctx context.Context, namespace, name, provider string) ([]core.Module, error)

func (*InmemStorage) MigrateModules

func (s *InmemStorage) MigrateModules(ctx context.Context, dryRun bool) error

func (*InmemStorage) UploadModule

func (s *InmemStorage) UploadModule(ctx context.Context, namespace, name, provider, version string, body io.Reader) (core.Module, error)

type InmemStorageOption

type InmemStorageOption func(*InmemStorage)

InmemStorageOption provides additional options for the InmemStorage.

func WithInmemArchiveFormat

func WithInmemArchiveFormat(archiveFormat string) InmemStorageOption

WithInmemArchiveFormat configures the module archive format (zip, tar, tgz, etc.)

type Metadata

type Metadata struct {
	Namespace string `hcl:"namespace" json:"namespace"`
	Name      string `hcl:"name" json:"name"`
	Provider  string `hcl:"provider" json:"provider"`
	Version   string `hcl:"version" json:"version"`
}

Metadata provides information about a given module version.

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 {
	GetModule(ctx context.Context, namespace, name, provider, version string) (core.Module, error)
	ListModuleVersions(ctx context.Context, namespace, name, provider string) ([]core.Module, error)
}

Service implements the Module Registry Protocol. For more information see: https://www.terraform.io/docs/internals/module-registry-protocol.html.

func NewService

func NewService(storage Storage) Service

NewService returns a fully initialized Service.

type Spec

type Spec struct {
	Metadata Metadata `hcl:"metadata,block" json:"metadata"`
}

Spec represents a module spec with metadata.

func Parse

func Parse(r io.Reader) (*Spec, error)

Parse parses a module spec.

func ParseFile

func ParseFile(path string) (*Spec, error)

ParseFile parses a module spec file.

func (*Spec) Name

func (s *Spec) Name() string

func (*Spec) Validate

func (s *Spec) Validate() error

Validate ensures that a spec is valid.

type Storage

type Storage interface {
	// GetModule should return an ErrModuleNotFound error if the requested module version cannot be found
	GetModule(ctx context.Context, namespace, name, provider, version string) (core.Module, error)
	ListModuleVersions(ctx context.Context, namespace, name, provider string) ([]core.Module, error)
	UploadModule(ctx context.Context, namespace, name, provider, version string, body io.Reader) (core.Module, error)
}

Storage represents the repository of Terraform modules.

func NewInmemStorage

func NewInmemStorage(options ...InmemStorageOption) Storage

NewInmemStorage returns a fully initialized in-memory storage.

Jump to

Keyboard shortcuts

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