core

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

Documentation

Index

Constants

View Source
const (
	ProviderPrefix    = "terraform-provider-"
	ProviderExtension = ".zip"
)

Variables

View Source
var (
	// Transport errors
	ErrVarMissing = errors.New("variable missing")

	// Auth errors
	ErrUnauthorized = errors.New("unauthorized")           // Middleware error
	ErrInvalidToken = errors.New("failed to verify token") // Provider error

	// Storage errors
	ErrObjectNotFound      = errors.New("failed to locate object")
	ErrObjectAlreadyExists = errors.New("object already exists")
)

Functions

func GenericError

func GenericError(err error) int

GenericError returns the HTTP status code for module-agnostic boring-registry errors

func HandleErrorResponse

func HandleErrorResponse(err error, w http.ResponseWriter)

HandleErrorResponse handles the HTTP response for errors

func Sha256Checksum

func Sha256Checksum(r io.Reader) ([]byte, error)

Sha256Checksum returns the SHA256 checksum of the stream passed to the io.Reader

Types

type GPGPublicKey

type GPGPublicKey struct {
	KeyID      string `json:"key_id,omitempty"`
	ASCIIArmor string `json:"ascii_armor,omitempty"`
	Source     string `json:"source,omitempty"`
	SourceURL  string `json:"source_url,omitempty"`
}

type Module

type Module struct {
	Namespace   string `json:"namespace"`
	Name        string `json:"name"`
	Provider    string `json:"provider"`
	Version     string `json:"version"`
	DownloadURL string `json:"download_url"`
}

Module represents Terraform module metadata.

func (*Module) ID

func (m *Module) ID(version bool) string

ID returns the module metadata in a compact format.

type Platform

type Platform struct {
	OS   string `json:"os,omitempty"`
	Arch string `json:"arch,omitempty"`
}

Platform is a copy from provider.Platform

type Provider

type Provider struct {
	Hostname            string      `json:"hostname,omitempty"`
	Namespace           string      `json:"namespace,omitempty"`
	Name                string      `json:"name,omitempty"`
	Version             string      `json:"version,omitempty"`
	OS                  string      `json:"os,omitempty"`
	Arch                string      `json:"arch,omitempty"`
	Filename            string      `json:"filename,omitempty"`
	DownloadURL         string      `json:"download_url,omitempty"`
	Shasum              string      `json:"shasum,omitempty"`
	SHASumsURL          string      `json:"shasums_url,omitempty"`
	SHASumsSignatureURL string      `json:"shasums_signature_url,omitempty"`
	SigningKeys         SigningKeys `json:"signing_keys,omitempty"`
	Platforms           []Platform  `json:"platforms,omitempty"`
}

Provider copied from provider.Provider Provider represents Terraform provider metadata.

func NewProviderFromArchive

func NewProviderFromArchive(filename string) (Provider, error)

func (*Provider) ArchiveFileName

func (p *Provider) ArchiveFileName() string

func (*Provider) Clone

func (p *Provider) Clone() *Provider

Clone returns a deep copy of the struct

func (*Provider) ShasumFileName

func (p *Provider) ShasumFileName() string

func (*Provider) ShasumSignatureFileName

func (p *Provider) ShasumSignatureFileName() string

type ProviderError

type ProviderError struct {
	Reason     string
	Provider   *Provider
	StatusCode int
}

func (ProviderError) Error

func (p ProviderError) Error() string

type ProviderOption

type ProviderOption func(option *providerOption)

type ProviderVersion

type ProviderVersion struct {
	Namespace string     `json:"namespace,omitempty"`
	Name      string     `json:"name,omitempty"`
	Version   string     `json:"version,omitempty"`
	Protocols []string   `json:"protocols,omitempty"`
	Platforms []Platform `json:"platforms,omitempty"`
}

The ProviderVersion is a copy from provider.ProviderVersion

type ProviderVersions

type ProviderVersions struct {
	Versions []ProviderVersion `json:"versions,omitempty"`
}

type Sha256Sums

type Sha256Sums struct {
	Entries  map[string][]byte
	Filename string
}

func NewSha256Sums

func NewSha256Sums(filename string, r io.Reader) (*Sha256Sums, error)

func (*Sha256Sums) Checksum

func (s *Sha256Sums) Checksum(fileName string) (string, error)

Checksum returns the corresponding stringified checksum for the archive file name parameter

func (*Sha256Sums) Name

func (s *Sha256Sums) Name() (string, error)

Name returns the name of the provider of the SHA256SUMS file

type SigningKeys

type SigningKeys struct {
	GPGPublicKeys []GPGPublicKey `json:"gpg_public_keys,omitempty"`
}

SigningKeys represents the signing-keys.json that we expect in the storage backend https://github.com/boring-registry/boring-registry#gpg-public-key-format

func (*SigningKeys) IsValidSha256Sums

func (s *SigningKeys) IsValidSha256Sums(sha256Sums, sha256SumsSig []byte) error

IsValidSha256Sums verifies whether the GPG signature of to the SHA256SUMS file was created with a private key corresponding to one of the public keys in SigningKeys

Jump to

Keyboard shortcuts

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