Documentation
¶
Index ¶
- func Latest(ctx context.Context, r Release) (string, error)
- func List(ctx context.Context, r Release, maxLength int, preRelease bool) ([]string, error)
- type GitHubAPI
- type GitHubClient
- type GitHubConfig
- type GitHubRelease
- type GitLabAPI
- type GitLabClient
- type GitLabConfig
- type GitLabRelease
- type Release
- type TFRegistryAPI
- type TFRegistryClient
- func (c *TFRegistryClient) ModuleLatestForProvider(ctx context.Context, req *tfregistry.ModuleLatestForProviderRequest) (*tfregistry.ModuleLatestForProviderResponse, error)
- func (c *TFRegistryClient) ProviderLatest(ctx context.Context, req *tfregistry.ProviderLatestRequest) (*tfregistry.ProviderLatestResponse, error)
- type TFRegistryConfig
- type TFRegistryModuleRelease
- type TFRegistryProviderRelease
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Latest ¶
Latest returns the latest release. Note that GetLatestRelease API in GitHub and GitLab returns the most recent release, which doesn't means the latest stable release. I'm not sure it also affects Terraform Registry but I think we should use the same strategy for consistency. So we sort versions in semver order and find the latest non pre-release.
Types ¶
type GitHubAPI ¶
type GitHubAPI interface {
// RepositoriesListReleases lists the releases for a repository.
// GitHub API docs: https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
RepositoriesListReleases(ctx context.Context, owner, repo string, opt *github.ListOptions) ([]*github.RepositoryRelease, *github.Response, error)
}
GitHubAPI is an interface which calls GitHub API. This abstraction layer is needed for testing with mock.
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient is a real GitHubAPI implementation.
func NewGitHubClient ¶
func NewGitHubClient(config GitHubConfig) (*GitHubClient, error)
NewGitHubClient returns a real GitHubClient instance.
func (*GitHubClient) RepositoriesListReleases ¶
func (c *GitHubClient) RepositoriesListReleases(ctx context.Context, owner, repo string, opt *github.ListOptions) ([]*github.RepositoryRelease, *github.Response, error)
RepositoriesListReleases lists the releases for a repository.
type GitHubConfig ¶
type GitHubConfig struct {
// BaseURL is a URL for GitHub API requests.
// Defaults to the public GitHub API.
// This looks like the GitHub Enterprise support, but currently for testing purposes only.
// The GitHub Enterprise is not supported yet.
// BaseURL should always be specified with a trailing slash.
BaseURL string
// Token is a personal access token for GitHub.
// This allows access to a private repository.
Token string
// contains filtered or unexported fields
}
GitHubConfig is a set of configurations for GitHubRelease.
type GitHubRelease ¶
type GitHubRelease struct {
// contains filtered or unexported fields
}
GitHubRelease is a release implementation which provides version information with GitHub Release.
func (*GitHubRelease) ListReleases ¶
func (r *GitHubRelease) ListReleases(ctx context.Context) ([]string, error)
ListReleases returns a list of unsorted all releases including pre-release.
type GitLabAPI ¶
type GitLabAPI interface {
// ProjectListReleases gets a pagenated of releases accessible by the authenticated user.
ProjectListReleases(ctx context.Context, owner, project string, opt *gitlab.ListReleasesOptions) ([]*gitlab.Release, *gitlab.Response, error)
}
GitLabAPI is an interface which calls GitLab API. This abstraction layer is needed for testing with mock.
type GitLabClient ¶
type GitLabClient struct {
// contains filtered or unexported fields
}
GitLabClient is a real GitLabAPI implementation.
func NewGitLabClient ¶
func NewGitLabClient(config GitLabConfig) (*GitLabClient, error)
NewGitLabClient returns a real GitLab instance.
func (*GitLabClient) ProjectListReleases ¶
func (c *GitLabClient) ProjectListReleases(ctx context.Context, owner, project string, opt *gitlab.ListReleasesOptions) ([]*gitlab.Release, *gitlab.Response, error)
ProjectListReleases gets a pagenated of releases accessible by the authenticated user.
type GitLabConfig ¶
type GitLabConfig struct {
// BaseURL is a URL for GitLab API requests.
// Defaults to the public GitLab API.
// BaseURL should always be specified with a trailing slash.
BaseURL string
// Token is a personal access token for GitLab, needed to use the api.
Token string
// contains filtered or unexported fields
}
GitLabConfig is a set of configurations for GitLabRelease..
type GitLabRelease ¶
type GitLabRelease struct {
// contains filtered or unexported fields
}
GitLabRelease is a release implementation which provides version information with GitLab Release.
func NewGitLabRelease ¶
func NewGitLabRelease(source string, config GitLabConfig) (*GitLabRelease, error)
NewGitLabRelease is a factory method which returns an GitLabRelease instance.
func (*GitLabRelease) ListReleases ¶
func (r *GitLabRelease) ListReleases(ctx context.Context) ([]string, error)
ListReleases returns a list of unsorted all releases including pre-release.
type Release ¶
type Release interface {
// ListReleases returns a list of unsorted all releases including pre-release.
ListReleases(ctx context.Context) ([]string, error)
}
Release is an interface which provides version information of a module or provider.
func NewGitHubRelease ¶
func NewGitHubRelease(source string, config GitHubConfig) (Release, error)
NewGitHubRelease is a factory method which returns an GitHubRelease instance.
func NewTFRegistryModuleRelease ¶
func NewTFRegistryModuleRelease(source string, config TFRegistryConfig) (Release, error)
NewTFRegistryModuleRelease is a factory method which returns an TFRegistryModuleRelease instance.
func NewTFRegistryProviderRelease ¶
func NewTFRegistryProviderRelease(source string, config TFRegistryConfig) (Release, error)
NewTFRegistryProviderRelease is a factory method which returns an TFRegistryProviderRelease instance.
type TFRegistryAPI ¶
type TFRegistryAPI interface {
// ModuleLatestForProvider returns the latest version of a module for a single provider.
// https://www.terraform.io/docs/registry/api.html#latest-version-for-a-specific-module-provider
ModuleLatestForProvider(ctx context.Context, req *tfregistry.ModuleLatestForProviderRequest) (*tfregistry.ModuleLatestForProviderResponse, error)
// ProviderLatest returns the latest version of a provider.
// This relies on a currently undocumented providers API endpoint which behaves exactly like the equivalent documented modules API endpoint.
// https://www.terraform.io/docs/registry/api.html#latest-version-for-a-specific-module-provider
ProviderLatest(ctx context.Context, req *tfregistry.ProviderLatestRequest) (*tfregistry.ProviderLatestResponse, error)
}
TFRegistryAPI is an interface which calls Terraform Registry API. This abstraction layer is needed for testing with mock.
type TFRegistryClient ¶
type TFRegistryClient struct {
// contains filtered or unexported fields
}
TFRegistryClient is a real TFRegistryAPI implementation.
func NewTFRegistryClient ¶
func NewTFRegistryClient(config TFRegistryConfig) (*TFRegistryClient, error)
NewTFRegistryClient returns a real TFRegistryClient instance.
func (*TFRegistryClient) ModuleLatestForProvider ¶
func (c *TFRegistryClient) ModuleLatestForProvider(ctx context.Context, req *tfregistry.ModuleLatestForProviderRequest) (*tfregistry.ModuleLatestForProviderResponse, error)
ModuleLatestForProvider returns the latest version of a module for a single provider. https://www.terraform.io/docs/registry/api.html#latest-version-for-a-specific-module-provider
func (*TFRegistryClient) ProviderLatest ¶
func (c *TFRegistryClient) ProviderLatest(ctx context.Context, req *tfregistry.ProviderLatestRequest) (*tfregistry.ProviderLatestResponse, error)
ProviderLatest returns the latest version of a provider. This relies on a currently undocumented providers API endpoint which behaves exactly like the equivalent documented modules API endpoint. https://www.terraform.io/docs/registry/api.html#latest-version-for-a-specific-module-provider
type TFRegistryConfig ¶
type TFRegistryConfig struct {
// BaseURL is a URL for Terraform Registry API requests.
// Defaults to the public Terraform Registry API.
// This looks like the Terraform Cloud support, but currently for testing purposes only.
// The Terraform Cloud is not supported yet.
// BaseURL should always be specified with a trailing slash.
BaseURL string
// contains filtered or unexported fields
}
TFRegistryConfig is a set of configurations for TFRegistryModuleRelease and TFRegistryProviderRelease.
type TFRegistryModuleRelease ¶
type TFRegistryModuleRelease struct {
// contains filtered or unexported fields
}
TFRegistryModuleRelease is a release implementation which provides version information with TFRegistryModule Release.
func (*TFRegistryModuleRelease) ListReleases ¶
func (r *TFRegistryModuleRelease) ListReleases(ctx context.Context) ([]string, error)
ListReleases returns a list of unsorted all releases including pre-release.
type TFRegistryProviderRelease ¶
type TFRegistryProviderRelease struct {
// contains filtered or unexported fields
}
TFRegistryProviderRelease is a release implementation which provides version information with TFRegistryProvider Release.
func (*TFRegistryProviderRelease) ListReleases ¶
func (r *TFRegistryProviderRelease) ListReleases(ctx context.Context) ([]string, error)
ListReleases returns a list of unsorted all releases including pre-release.