Documentation ¶
Index ¶
- func Copy(ctx context.Context, req *CopyReq) error
- type Archive
- type Artifacts
- func (a *Artifacts) AddBinary(version, platform, arch, binaryPath string) error
- func (a *Artifacts) AddReleaseManifest(ctx context.Context, path, version string) error
- func (a *Artifacts) AddReleaseVersionToIndex(version string)
- func (a *Artifacts) CopyReleaseArtifactsBetweenRemoteBucketsForVersion(ctx context.Context, srcBucketName string, destS3Client *s3.Client, ...) error
- func (a *Artifacts) CreateVersionedRegistryManifest(ctx context.Context) error
- func (a *Artifacts) CreateZipArchive(sourceBinaryPath, zipFilePath string) error
- func (a *Artifacts) DownloadFromTFC(ctx context.Context, tfcreq *TFCDownloadReq) error
- func (a *Artifacts) ExtractProviderBinaries(ctx context.Context, tfcreq *TFCPromoteReq) error
- func (a *Artifacts) HasVersion(ctx context.Context, version string) (bool, error)
- func (a *Artifacts) HashZipArchive(path string) (string, error)
- func (a *Artifacts) Insert(version, platform, arch string, archive *Archive)
- func (a *Artifacts) InsertTFCRelease(version string, release *TFCRelease)
- func (a *Artifacts) LoadRemoteIndex(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
- func (a *Artifacts) LoadRemoteReleaseMetedataForVersion(ctx context.Context, s3Client *s3.Client, bucket, providerID, version string) error
- func (a *Artifacts) PublishToGithubRelease(ctx context.Context, req *GithubReleaseCreateReq) error
- func (a *Artifacts) PublishToRemoteBucket(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
- func (a *Artifacts) PublishToTFC(ctx context.Context, tfcreq *TFCUploadReq) error
- func (a *Artifacts) SHA256Sum(path string) (string, error)
- func (a *Artifacts) WriteDetachedSignature(ctx context.Context, source, out, name string) error
- func (a *Artifacts) WriteMetadata() error
- func (a *Artifacts) WriteSHA256SUMS(ctx context.Context, regType RegistryType, gpgIdentityName string, ...) error
- type CopyReq
- type GithubReleaseCreateReq
- type Index
- type IndexValue
- type Local
- func (l *Local) AddGoBinariesFrom(binPath string) error
- func (l *Local) AddReleaseManifest(ctx context.Context, path, version string) error
- func (l *Local) AddReleaseVersionToIndex(ctx context.Context, version string)
- func (l *Local) Close() error
- func (l *Local) CopyReleaseArtifactsBetweenRemoteBucketsForVersion(ctx context.Context, srcBucketName string, destS3Client *s3.Client, ...) error
- func (l *Local) CreateVersionedRegistryManifest(ctx context.Context) error
- func (l *Local) DownloadFromTFC(ctx context.Context, tfcreq *TFCDownloadReq) error
- func (l *Local) ExtractProviderBinaries(ctx context.Context, tfcreq *TFCPromoteReq) error
- func (l *Local) HasVersion(ctx context.Context, version string) (bool, error)
- func (l *Local) Initialize() error
- func (l *Local) LoadRemoteIndex(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
- func (l *Local) PublishToGithubReleases(ctx context.Context, req *GithubReleaseCreateReq) error
- func (l *Local) PublishToRemoteBucket(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
- func (l *Local) PublishToTFC(ctx context.Context, tfcreq *TFCUploadReq) error
- func (l *Local) SetLogLevel(level zapcore.Level) error
- func (l *Local) WriteMetadata() error
- func (l *Local) WriteSHA256Sums(ctx context.Context, regType RegistryType, name string, sign bool) error
- type NewLocalOpt
- type RegistryManifest
- type RegistryType
- type Release
- type TFCClient
- func (c *TFCClient) CreatePrivateProvider(ctx context.Context, namespace string, providerName string) error
- func (c *TFCClient) CreateProviderPlatforms(ctx context.Context, namespace string, providerName string, ...) error
- func (c *TFCClient) CreateProviderVersion(ctx context.Context, namespace string, providerName string, ...) error
- func (c *TFCClient) DoRequest(ctx context.Context, tfcReq *TFCRequest) (*http.Response, error)
- func (c *TFCClient) FindOrCreatePlatform(ctx context.Context, namespace string, providerName string, ...) error
- func (c *TFCClient) FindOrCreateProvider(ctx context.Context, namespace, providerName string) error
- func (c *TFCClient) FindOrCreateVersion(ctx context.Context, namespace string, providerName string, ...) error
- func (c *TFCClient) FindPrivateProvider(ctx context.Context, namespace string, providerName string) (*TFCProvider, error)
- func (c *TFCClient) FindProviderPlatform(ctx context.Context, namespace string, providerName string, ...) ([]*TFCProviderPlatform, error)
- func (c *TFCClient) FindProviderVersion(ctx context.Context, namespace string, providerName string, ...) (*TFCProviderVersion, error)
- type TFCClientOpt
- type TFCDownloadReq
- type TFCPromoteReq
- type TFCProvider
- type TFCProviderPlatform
- type TFCProviderVersion
- type TFCRelease
- type TFCRequest
- type TFCRequestOpt
- type TFCUploadReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Archive ¶
type Archive struct { Hashes []string `json:"hashes"` // the hash of the zip file URL string `json:"url"` // path to the zipfile relative to root SHA256Sum string // The s3 mirror doesn't need this so there's no JSON tag }
Archive is a zip archive of a binary.
type Artifacts ¶
type Artifacts struct {
// contains filtered or unexported fields
}
Artifacts is a collection of all the artifacts in the repository.
func NewArtifacts ¶
NewArtifacts takes the name of the terraform provider and returns a new Artifacts.
func (*Artifacts) AddBinary ¶
AddBinary takes version, platform, arch, and path of a binary and adds it to the mirror. It does this by creating a zip archive of the binary, hashing it and adding it to the artifacts collection.
func (*Artifacts) AddReleaseManifest ¶
Add the base release manifest into the artifacts.
func (*Artifacts) AddReleaseVersionToIndex ¶
AddReleaseVersionToIndex adds the release version to the mirror index.
func (*Artifacts) CopyReleaseArtifactsBetweenRemoteBucketsForVersion ¶
func (a *Artifacts) CopyReleaseArtifactsBetweenRemoteBucketsForVersion(ctx context.Context, srcBucketName string, destS3Client *s3.Client, destBucketName, providerName, providerID, version string) error
CopyReleaseArtifactsBetweenRemoteBucketsForVersion copies artifacts from a remote s3 mirror to another remote mirror.
func (*Artifacts) CreateVersionedRegistryManifest ¶
func (*Artifacts) CreateZipArchive ¶
CreateZipArchive takes a source binary and a destination path and creates a zip archive of the binary.
func (*Artifacts) DownloadFromTFC ¶
func (a *Artifacts) DownloadFromTFC(ctx context.Context, tfcreq *TFCDownloadReq) error
DownloadFromTFC downloads the artifacts for a given version to a directory.
func (*Artifacts) ExtractProviderBinaries ¶
func (a *Artifacts) ExtractProviderBinaries(ctx context.Context, tfcreq *TFCPromoteReq) error
ExtractProviderBinaries extracts the downloaded artifacts to an output directory.
func (*Artifacts) HasVersion ¶
HasVersion checks if the artifact version exists in the loaded index.json of the remote mirror.
func (*Artifacts) HashZipArchive ¶
HashZipArchive returns the h1 style Terraform hash of the zip archive.
func (*Artifacts) Insert ¶
Insert takes a version, platform, arch, and archive and inserts it into the archive collection.
func (*Artifacts) InsertTFCRelease ¶
func (a *Artifacts) InsertTFCRelease(version string, release *TFCRelease)
InsertTFCRelease takes a version, and release and inserts it into the tfcMetadata.
func (*Artifacts) LoadRemoteIndex ¶
func (a *Artifacts) LoadRemoteIndex(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
LoadRemoteIndex fetches the existing index.json from the remote bucket and loads it. This way we can merge new builds with those in existing remote mirror.
func (*Artifacts) LoadRemoteReleaseMetedataForVersion ¶
func (a *Artifacts) LoadRemoteReleaseMetedataForVersion(ctx context.Context, s3Client *s3.Client, bucket, providerID, version string) error
LoadRemoteReleaseMetedataForVersion fetches the version.json for a given release from the remote bucket and loads it. We need this information to known what and where release artifacts for the release are.
func (*Artifacts) PublishToGithubRelease ¶
func (a *Artifacts) PublishToGithubRelease(ctx context.Context, req *GithubReleaseCreateReq) error
PublishToGithubReleases publishes the local mirror artifacts to Github Releases in a manner that is compatible with the public Github registry.
func (*Artifacts) PublishToRemoteBucket ¶
func (a *Artifacts) PublishToRemoteBucket(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
PublishToRemoteBucket publishes the artifacts in the local mirror to the remote S3 Bucket.
func (*Artifacts) PublishToTFC ¶
func (a *Artifacts) PublishToTFC(ctx context.Context, tfcreq *TFCUploadReq) error
PublishToTFC publishes the artifact version to TFC org.
func (*Artifacts) WriteDetachedSignature ¶
WriteDetachedSignature takes a context, source file path, outfile path, and the GPG entity name and writes a signed version of the source file to the outfile.
func (*Artifacts) WriteMetadata ¶
WriteMetadata writes the artifact collection as JSON metadata into the local mirror.
func (*Artifacts) WriteSHA256SUMS ¶
func (a *Artifacts) WriteSHA256SUMS( ctx context.Context, regType RegistryType, gpgIdentityName string, gpgDetachSign bool, ) error
WriteSHA256SUMS writes the release SHA256SUMS file as required by TFC or the public registry.
type CopyReq ¶
type CopyReq struct { Version string SrcBucketName string DestBucketName string SrcProviderName string SrcBinaryName string SrcProviderID string DestProviderName string DestBinaryName string DestProviderID string SrcS3Client *s3.Client DestS3Client *s3.Client // contains filtered or unexported fields }
CopyReq to be copied.
type GithubReleaseCreateReq ¶
type GithubReleaseCreateReq struct { // Local artifacts DistDir string BinaryName string ProviderName string GPGKeyID string GPGIdentityName string Version string ManifestPath string // Github release GithubRelease *github.RepositoryRelease GithubToken string GithubRepoNameOwner string // owner/repo }
func (*GithubReleaseCreateReq) OwnerRepo ¶
func (r *GithubReleaseCreateReq) OwnerRepo() (string, string)
type Index ¶
type Index struct { Versions map[string]*IndexValue `json:"versions"` // contains filtered or unexported fields }
Index is our root index.json which tracks which versions are available in the mirror.
type IndexValue ¶
type IndexValue struct{}
IndexValue is the value of Version in the Index. Currently it is a blank object.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a local provider artifact mirror.
func NewLocal ¶
func NewLocal(name, binname string, opts ...NewLocalOpt) *Local
NewLocal takes a terraform provider name and returns a new local mirror.
func (*Local) AddGoBinariesFrom ¶
AddGoBinariesFrom takes a directory path to the go builds, walks it, finds any providers binaries, creates an archive of them and adds them to the artifacts and index.
func (*Local) AddReleaseManifest ¶
Add public registry manifest path to the local mirror. If present we'll inject in into the provider binary archives.
func (*Local) AddReleaseVersionToIndex ¶
AddReleaseVersionToIndex adds a version to the release index.
func (*Local) CopyReleaseArtifactsBetweenRemoteBucketsForVersion ¶
func (l *Local) CopyReleaseArtifactsBetweenRemoteBucketsForVersion(ctx context.Context, srcBucketName string, destS3Client *s3.Client, destBucketName, binaryName, providerID, version string) error
CopyReleaseArtifactsBetweenRemoteBucketsForVersion copies release artifacts from source bucket to the destination bucket.
func (*Local) CreateVersionedRegistryManifest ¶
Create a versions registry manifest.
func (*Local) DownloadFromTFC ¶
func (l *Local) DownloadFromTFC(ctx context.Context, tfcreq *TFCDownloadReq) error
DownloadFromTFC downloads the artifacts for a given version to a directory.
func (*Local) ExtractProviderBinaries ¶
func (l *Local) ExtractProviderBinaries(ctx context.Context, tfcreq *TFCPromoteReq) error
ExtractProviderBinaries extracts the artifacts to an output directory.
func (*Local) HasVersion ¶
HasVersion checks if t the version exists in the bucket.
func (*Local) LoadRemoteIndex ¶
func (l *Local) LoadRemoteIndex(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
LoadRemoteIndex fetches a remote index and loads it.
func (*Local) PublishToGithubReleases ¶
func (l *Local) PublishToGithubReleases(ctx context.Context, req *GithubReleaseCreateReq) error
PublishToGithubReleases publishes the local mirror artifacts to Github Releases in a manner that is compatible with the public Github registry.
func (*Local) PublishToRemoteBucket ¶
func (l *Local) PublishToRemoteBucket(ctx context.Context, s3Client *s3.Client, bucket, providerID string) error
PublishToRemoteBucket publishes the local mirror artifacts into the remote bucket.
func (*Local) PublishToTFC ¶
func (l *Local) PublishToTFC(ctx context.Context, tfcreq *TFCUploadReq) error
PublishToTFC publishes artifact version to TFC org.
func (*Local) SetLogLevel ¶
SetLogLevel sets the log level.
func (*Local) WriteMetadata ¶
WriteMetadata writes metadata JSON files of the mirror artifacts.
func (*Local) WriteSHA256Sums ¶
func (l *Local) WriteSHA256Sums(ctx context.Context, regType RegistryType, name string, sign bool) error
WriteSHA256Sums writes a detached signature of the source file to the outfile.
type NewLocalOpt ¶
NewLocalOpt accepts optional arguments for Local.
func WithLocalBinaryRename ¶
func WithLocalBinaryRename(name string) NewLocalOpt
WithLocalBinaryRename renames the binary during creation.
type RegistryManifest ¶
type RegistryManifest struct {
// contains filtered or unexported fields
}
RegistryManifest is the public registry manifest.
type RegistryType ¶
type RegistryType string
const ( RegistryTypePrivate RegistryType = "private" RegistryTypePublic RegistryType = "public" )
type Release ¶
type Release struct { Archives map[string]*Archive `json:"archives"` // key is the platform_arch // contains filtered or unexported fields }
Release is a version collection of archives.
func (*Release) AddArchive ¶
AddArchive takes a platform, arch and archive and adds it to the releases archives.
type TFCClient ¶
type TFCClient struct {
// contains filtered or unexported fields
}
TFCClient is a collection of http client request params.
func NewTFCClient ¶
func NewTFCClient(opts ...TFCClientOpt) (*TFCClient, error)
NewTFCClient creates and returns a new instance of TFCClient.
func (*TFCClient) CreatePrivateProvider ¶
func (c *TFCClient) CreatePrivateProvider( ctx context.Context, namespace string, providerName string, ) error
CreatePrivateProvider creates a private provider.
func (*TFCClient) CreateProviderPlatforms ¶
func (c *TFCClient) CreateProviderPlatforms( ctx context.Context, namespace string, providerName string, providerVersion string, releases []*TFCRelease, ) error
CreateProviderPlatforms creates platforms for a provider version.
func (*TFCClient) CreateProviderVersion ¶
func (c *TFCClient) CreateProviderVersion( ctx context.Context, namespace string, providerName string, providerVersion string, gpgKeyID string, sha256sumsPath string, ) error
CreateProviderVersion creates a private provider version.
func (*TFCClient) DoRequest ¶
DoRequest takes a context, http request params with an optional data body and returns an http response.
func (*TFCClient) FindOrCreatePlatform ¶
func (c *TFCClient) FindOrCreatePlatform( ctx context.Context, namespace string, providerName string, providerVersion string, release []*TFCRelease, ) error
FindOrCreatePlatform - FindProviderPlatform - CreateProviderPlatforms.
func (*TFCClient) FindOrCreateProvider ¶
FindOrCreateProvider - FindProvider - CreateProvider.
func (*TFCClient) FindOrCreateVersion ¶
func (c *TFCClient) FindOrCreateVersion( ctx context.Context, namespace string, providerName string, providerVersion string, gpgKeyID string, sha256sumsPath string, ) error
FindOrCreateVersion - FindProviderVersion - CreateProviderVersion.
func (*TFCClient) FindPrivateProvider ¶
func (c *TFCClient) FindPrivateProvider( ctx context.Context, namespace string, providerName string, ) (*TFCProvider, error)
FindPrivateProvider searches for existing private provider.
func (*TFCClient) FindProviderPlatform ¶
func (c *TFCClient) FindProviderPlatform( ctx context.Context, namespace string, providerName string, providerVersion string, ) ([]*TFCProviderPlatform, error)
FindProviderPlatform searches for platforms supported by a private provider version.
type TFCDownloadReq ¶
type TFCDownloadReq struct { DownloadDir string ProviderVersion string BinaryName string ProviderName string TFCOrg string TFCToken string }
TFCDownloadReq is a collection of provider download request.
type TFCPromoteReq ¶
type TFCPromoteReq struct { ProviderVersion string DownloadsDir string PromoteDir string SrcProviderName string DestProviderName string SrcBinaryName string DestBinaryName string GPGKeyID string GPGIdentityName string TFCOrg string TFCToken string }
TFCPromoteReq is a collection of provider promote request.
type TFCProvider ¶
TFCProvider is a collection of TFC provider registry namespace.
type TFCProviderPlatform ¶
type TFCProviderPlatform struct { PlatformID string Version string RegistryType string Org string OS string Arch string Filename string Filepath string SHAsum string PlatformBinaryUploaded bool PlatformBinaryURL string }
TFCProviderPlatform struct is a collection of provider platform data.
type TFCProviderVersion ¶
type TFCProviderVersion struct { Version string RegistryType string KeyID string Org string SHAUploaded bool SHASigUploaded bool SHASumsURL string SHASumsSigURL string }
TFCProviderVersion is a collection of TFC provider's version.
type TFCRelease ¶
TFCRelease is a collection of TFC release zip binary, platform, architecture, and sha256sum.
type TFCRequest ¶
type TFCRequest struct { Scheme string // "https" Host string // "app.terraform.io" ReqPath string HTTPMethod string Body io.Reader }
TFCRequest is a TFC API request.
func NewTFCRequest ¶
func NewTFCRequest(opts ...TFCRequestOpt) (*TFCRequest, error)
NewTFCRequest takes TFCRequestOpt args and returns a new TFC API request.
type TFCRequestOpt ¶
type TFCRequestOpt func(*TFCRequest) (*TFCRequest, error)
TFCRequestOpt are functional options for a new Request.
func WithRequestBody ¶
func WithRequestBody(body io.Reader) TFCRequestOpt
WithRequestBody sets the request body.