downloader

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyURLType      = fmt.Errorf("empty remote url and type")
	ErrEmptyURLDest      = fmt.Errorf("remote url or destination dir path cannot be empty")
	ErrEmptyURLTypeDest  = fmt.Errorf("empty remote url or type or destination dir path")
	ErrInvalidRemoteType = fmt.Errorf("supplied remote type is not supported")
)

list of errors

Functions

func GetSourceAddrAndVersion

func GetSourceAddrAndVersion(sourceURL string) (string, string)

GetSourceAddrAndVersion extracts source address and version from supplied source url

func IsLocalSourceAddr

func IsLocalSourceAddr(addr string) bool

IsLocalSourceAddr validates if a source address is a local address or not

func IsRegistrySourceAddr

func IsRegistrySourceAddr(addr string) bool

IsRegistrySourceAddr will validate if the source address is a valid registry module or not. a valid source address is of the form <HOSTNAME>/NAMESPACE>/<NAME>/<PROVIDER> regsrc.ParseModuleSource func returns a terraform registry module source.

func IsRemoteTypeTerraformRegistry

func IsRemoteTypeTerraformRegistry(remoteType string) bool

IsRemoteTypeTerraformRegistry checks if supplied remote type is terraform-registry

func IsValidRemoteType

func IsValidRemoteType(remoteType string) bool

IsValidRemoteType validates the remote type supplied as scan option

func NewAuthenticatedRegistryClient

func NewAuthenticatedRegistryClient(rcFile string) terraformRegistryClient

NewAuthenticatedRegistryClient parses the contents of a terraformrc file and builds an authenticated registry client using the credentials found in the rcfile

func SplitAddrSubdir

func SplitAddrSubdir(addr string) (repoURL, subDir string)

SplitAddrSubdir splits the given address into a package portion and a sub-directory portion.

The package portion defines the URL what should be downloaded and then the sub-directory portion, if present, specifies a sub-directory within the downloaded object .

The subDir portion will be returned as empty if no subdir separator ("//") is present in the address.

Types

type Downloader

type Downloader interface {
	Download(url, destDir string) (finalDir string, err error)
	DownloadWithType(remoteType, url, dest string) (finalDir string, err error)
	GetURLSubDir(url, dest string) (urlWithType string, subDir string, err error)
	SubDirGlob(string, string) (string, error)
}

Downloader helps in downloading different kinds of modules from different types of sources

func NewDownloader

func NewDownloader() Downloader

NewDownloader returns a new downloader

type ModuleDownloader

type ModuleDownloader interface {
	DownloadModule(addr, destPath string) (string, error)
	DownloadRemoteModule(requiredVersion hclConfigs.VersionConstraint, destPath string, module *regsrc.Module) (string, error)
	CleanUp()
	GetDownloaderCache() map[string]string
}

ModuleDownloader helps in downloading the remote modules

func NewRemoteDownloader

func NewRemoteDownloader() ModuleDownloader

NewRemoteDownloader returns a new ModuleDownloader

Jump to

Keyboard shortcuts

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