Documentation ¶
Overview ¶
Package handlers provides the interfaces and common implementations for handling provider requests.
Index ¶
- Constants
- Variables
- type CommonProviderHandler
- type NotFoundWellKnownURL
- type ProviderDirectHandler
- func (handler *ProviderDirectHandler) Download(ctx echo.Context, provider *models.Provider) error
- func (handler *ProviderDirectHandler) GetPlatform(ctx echo.Context, provider *models.Provider, ...) error
- func (handler *ProviderDirectHandler) GetVersions(ctx echo.Context, provider *models.Provider) error
- func (handler *ProviderDirectHandler) String() string
- type ProviderFilesystemMirrorHandler
- func (handler *ProviderFilesystemMirrorHandler) Download(ctx echo.Context, provider *models.Provider) error
- func (handler *ProviderFilesystemMirrorHandler) GetPlatform(ctx echo.Context, provider *models.Provider, ...) error
- func (handler *ProviderFilesystemMirrorHandler) GetVersions(ctx echo.Context, provider *models.Provider) error
- func (handler *ProviderFilesystemMirrorHandler) String() string
- type ProviderHandler
- type ProviderHandlers
- type ProviderNetworkMirrorHandler
- func (handler *ProviderNetworkMirrorHandler) Download(ctx echo.Context, provider *models.Provider) error
- func (handler *ProviderNetworkMirrorHandler) GetPlatform(ctx echo.Context, provider *models.Provider, ...) error
- func (handler *ProviderNetworkMirrorHandler) GetVersions(ctx echo.Context, provider *models.Provider) error
- func (handler *ProviderNetworkMirrorHandler) String() string
- type RegistryURLs
- type ReverseProxy
Constants ¶
const ( // Provider's assets consist of three files/URLs: zipped binary, hashes and signature ProviderDownloadURLName providerURLName = "download_url" ProviderSHASumsURLName providerURLName = "shasums_url" ProviderSHASumsSignatureURLName providerURLName = "shasums_signature_url" )
Variables ¶
var (
DefaultRegistryURLs = &RegistryURLs{
ModulesV1: "/v1/modules",
ProvidersV1: "/v1/providers",
}
)
Functions ¶
This section is empty.
Types ¶
type CommonProviderHandler ¶ added in v0.58.7
type CommonProviderHandler struct {
// contains filtered or unexported fields
}
func NewCommonProviderHandler ¶ added in v0.58.7
func NewCommonProviderHandler(providerService *services.ProviderService, includes, excludes *[]string) *CommonProviderHandler
NewCommonProviderHandler returns a new `CommonProviderHandler` instance with the defined values.
func (*CommonProviderHandler) CanHandleProvider ¶ added in v0.58.7
func (handler *CommonProviderHandler) CanHandleProvider(provider *models.Provider) bool
CanHandleProvider implements ProviderHandler.CanHandleProvider
func (*CommonProviderHandler) DiscoveryURL ¶ added in v0.67.12
func (handler *CommonProviderHandler) DiscoveryURL(ctx context.Context, registryName string) (*RegistryURLs, error)
DiscoveryURL implements ProviderHandler.DiscoveryURL.
type NotFoundWellKnownURL ¶ added in v0.67.12
type NotFoundWellKnownURL struct {
// contains filtered or unexported fields
}
func (NotFoundWellKnownURL) Error ¶ added in v0.67.12
func (err NotFoundWellKnownURL) Error() string
type ProviderDirectHandler ¶ added in v0.58.7
type ProviderDirectHandler struct { *CommonProviderHandler *ReverseProxy // contains filtered or unexported fields }
func NewProviderDirectHandler ¶ added in v0.58.7
func NewProviderDirectHandler(providerService *services.ProviderService, cacheProviderHTTPStatusCode int, method *cliconfig.ProviderInstallationDirect, credsSource *cliconfig.CredentialsSource) *ProviderDirectHandler
func (*ProviderDirectHandler) Download ¶ added in v0.58.7
func (handler *ProviderDirectHandler) Download(ctx echo.Context, provider *models.Provider) error
Download implements ProviderHandler.Download
func (*ProviderDirectHandler) GetPlatform ¶ added in v0.58.7
func (handler *ProviderDirectHandler) GetPlatform(ctx echo.Context, provider *models.Provider, downloaderController router.Controller, cacheRequestID string) error
GetPlatform implements ProviderHandler.GetPlatform
func (*ProviderDirectHandler) GetVersions ¶ added in v0.58.7
func (handler *ProviderDirectHandler) GetVersions(ctx echo.Context, provider *models.Provider) error
GetVersions implements ProviderHandler.GetVersions https://developer.hashicorp.com/terraform/cloud-docs/api-docs/private-registry/provider-versions-platforms#get-all-versions-for-a-single-provider
func (*ProviderDirectHandler) String ¶ added in v0.58.7
func (handler *ProviderDirectHandler) String() string
type ProviderFilesystemMirrorHandler ¶ added in v0.58.7
type ProviderFilesystemMirrorHandler struct { *CommonProviderHandler // contains filtered or unexported fields }
func (*ProviderFilesystemMirrorHandler) Download ¶ added in v0.58.7
func (handler *ProviderFilesystemMirrorHandler) Download(ctx echo.Context, provider *models.Provider) error
Download implements ProviderHandler.Download
func (*ProviderFilesystemMirrorHandler) GetPlatform ¶ added in v0.58.7
func (handler *ProviderFilesystemMirrorHandler) GetPlatform(ctx echo.Context, provider *models.Provider, downloaderController router.Controller, cacheRequestID string) error
GetPlatform implements ProviderHandler.GetPlatform
func (*ProviderFilesystemMirrorHandler) GetVersions ¶ added in v0.58.7
func (handler *ProviderFilesystemMirrorHandler) GetVersions(ctx echo.Context, provider *models.Provider) error
GetVersions implements ProviderHandler.GetVersions
func (*ProviderFilesystemMirrorHandler) String ¶ added in v0.58.7
func (handler *ProviderFilesystemMirrorHandler) String() string
type ProviderHandler ¶ added in v0.58.7
type ProviderHandler interface { // CanHandleProvider returns true if the given provider can be handled by this handler. CanHandleProvider(provider *models.Provider) bool // GetVersions serves a request that returns all versions for a single provider. GetVersions(ctx echo.Context, provider *models.Provider) error // GetPlatform serves a request that returns a provider for a specific platform. GetPlatform(ctx echo.Context, provider *models.Provider, downloaderController router.Controller, cacheRequestID string) error // Download serves a request to download the target file. Download(ctx echo.Context, provider *models.Provider) error // DiscoveryURL discovers modules and providers API endpoints for the specified `registryName`. // https://developer.hashicorp.com/terraform/internals/remote-service-discovery#discovery-process DiscoveryURL(ctx context.Context, registryName string) (*RegistryURLs, error) }
func NewProviderFilesystemMirrorHandler ¶ added in v0.58.7
func NewProviderFilesystemMirrorHandler(providerService *services.ProviderService, cacheProviderHTTPStatusCode int, method *cliconfig.ProviderInstallationFilesystemMirror) ProviderHandler
func NewProviderNetworkMirrorHandler ¶ added in v0.58.7
func NewProviderNetworkMirrorHandler(providerService *services.ProviderService, cacheProviderHTTPStatusCode int, networkMirror *cliconfig.ProviderInstallationNetworkMirror, credsSource *cliconfig.CredentialsSource) (ProviderHandler, error)
type ProviderHandlers ¶ added in v0.67.12
type ProviderHandlers []ProviderHandler
ProviderHandlers is a slice of ProviderHandler.
func (ProviderHandlers) DiscoveryURL ¶ added in v0.67.12
func (handlers ProviderHandlers) DiscoveryURL(ctx context.Context, registryName string) (*RegistryURLs, error)
DiscoveryURL looks for the first handler that can handle the given `registryName`, which is determined by the include and exclude settings in the `.terraformrc` CLI config file. If the handler is found, tries to discover its API endpoints otherwise return the default registry URLs.
type ProviderNetworkMirrorHandler ¶ added in v0.58.7
type ProviderNetworkMirrorHandler struct { *CommonProviderHandler *http.Client // contains filtered or unexported fields }
func (*ProviderNetworkMirrorHandler) Download ¶ added in v0.58.7
func (handler *ProviderNetworkMirrorHandler) Download(ctx echo.Context, provider *models.Provider) error
Download implements ProviderHandler.Download
func (*ProviderNetworkMirrorHandler) GetPlatform ¶ added in v0.58.7
func (handler *ProviderNetworkMirrorHandler) GetPlatform(ctx echo.Context, provider *models.Provider, downloaderController router.Controller, cacheRequestID string) error
GetPlatform implements ProviderHandler.GetPlatform
func (*ProviderNetworkMirrorHandler) GetVersions ¶ added in v0.58.7
func (handler *ProviderNetworkMirrorHandler) GetVersions(ctx echo.Context, provider *models.Provider) error
GetVersions implements ProviderHandler.GetVersions
func (*ProviderNetworkMirrorHandler) String ¶ added in v0.58.7
func (handler *ProviderNetworkMirrorHandler) String() string
type RegistryURLs ¶ added in v0.67.12
type RegistryURLs struct { ModulesV1 string `json:"modules.v1"` ProvidersV1 string `json:"providers.v1"` }
func DiscoveryURL ¶ added in v0.67.12
func DiscoveryURL(ctx context.Context, registryName string) (*RegistryURLs, error)
func (*RegistryURLs) String ¶ added in v0.67.12
func (urls *RegistryURLs) String() string
type ReverseProxy ¶
type ReverseProxy struct { ServerURL *url.URL CredsSource *cliconfig.CredentialsSource Rewrite func(*httputil.ProxyRequest) ModifyResponse func(resp *http.Response) error ErrorHandler func(http.ResponseWriter, *http.Request, error) // contains filtered or unexported fields }
func (*ReverseProxy) NewRequest ¶
func (reverseProxy *ReverseProxy) NewRequest(ctx echo.Context, targetURL *url.URL) (er error)
func (ReverseProxy) WithModifyResponse ¶
func (reverseProxy ReverseProxy) WithModifyResponse(fn func(resp *http.Response) error) *ReverseProxy
func (ReverseProxy) WithRewrite ¶
func (reverseProxy ReverseProxy) WithRewrite(fn func(req *httputil.ProxyRequest)) *ReverseProxy