registry

package
v0.0.0-...-cc99f5b Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright 2022 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package registry provides tools for interacting with a Terraform custom registry

Copyright 2022 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2022 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2022 Gravitational, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProviderTarball

func IsProviderTarball(fn string) bool

IsProviderTarball tests if a given string is a Houston-compatible filename indicating a terraform-provider plugin type

func VersionsFilePath

func VersionsFilePath(prefix, namespace, name string) string

Types

type Download

type Download struct {
	Protocols    []string    `json:"protocols"`
	OS           string      `json:"os"`
	Arch         string      `json:"arch"`
	Filename     string      `json:"filename"`
	DownloadURL  string      `json:"download_url"`
	ShaURL       string      `json:"shasums_url"`
	SignatureURL string      `json:"shasums_signature_url"`
	Sha          string      `json:"shasum"`
	SigningKeys  SigningKeys `json:"signing_keys"`
}

Download describes the file specific download package for a given platform & provider version. If a provider supports multiple OSs & architectures, the registry will contain multiple Download records, one for each unique architecture/OS pair.

func NewDownloadFromRepackResult

func NewDownloadFromRepackResult(info *RepackResult, protocols []string, objectStoreURL string) (*Download, error)

NewDownloadFromRepackResult creates a new, fully-populated Download object from the result of repacking a Houston-compatible tarball into a Terraform registry-compatible zip archive

func (*Download) Save

func (dl *Download) Save(indexDir, namespace, name string, version semver.Version) (string, error)

Save serializes a Download record to JSON and writes it to the appropriate Provider Registry Protocol-defined location in a registry directory tree, i.e.

indexDir/:namespace/:name/:version/download/:os/:arch

type FileNames

type FileNames struct {
	Zip string
	Sum string
	Sig string
}

FileNames describes the location of a registry-compatible zipfile and its associated sidecar files

type GpgPublicKey

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

GpgPublicKey describes a (the public half) of a GPG key used to sign a provider zipfile.

type Platform

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

Platform encodes an OS/Arch pair

type RepackResult

type RepackResult struct {
	filename.Info
	FileNames
	Sha256        []byte
	SigningEntity *openpgp.Entity
}

RepackResult describes a fully-repacked provider and all of its sidecar files

func RepackProvider

func RepackProvider(dstDir string, srcFileName string, signingEntity *openpgp.Entity) (*RepackResult, error)

RepackProvider takes a provider tarball and repacks it as a zipfile compatible with a terraform provider registry, generating all the required sidecar files as well. Returns a `RepackResult` instance containing the location of the generated files and information about the packed plugin

For more information on the output files, see the Terraform Provider Registry Protocol documentation:

https://www.terraform.io/internals/provider-registry-protocol

func (*RepackResult) Sha256String

func (r *RepackResult) Sha256String() string

Sha256String formats the binary SHA256 as a hex string

type SigningKeys

type SigningKeys struct {
	GpgPublicKeys []GpgPublicKey `json:"gpg_public_keys"`
}

SigningKeys describes the key (or keys) that signed a given download. As per the registry protocol, only GPG keys are supported for now.

type Version

type Version struct {
	Version   semver.Version `json:"version"`
	Protocols []string       `json:"protocols"`
	Platforms []Platform     `json:"platforms"`
}

Version describes tha compatability and available platforms for a given provider version

type Versions

type Versions struct {
	Versions []Version `json:"versions"`
}

Versions is a Go representation of the Terraform Registry Protocol `versions` file

func LoadVersionsFile

func LoadVersionsFile(filename string) (Versions, error)

LoadVersionsFile reads and parses a versions structure from the file at the supplied filesystem location

func (*Versions) Save

func (idx *Versions) Save(filename string) error

Save formats and writes the version list to the supplied filesystem location.

Jump to

Keyboard shortcuts

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