getter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package getter is used to download or copy source files from remote / local location. It is a wrapper around go-getter and supports all the same features. It also implements a special detector for terraform registry support. This allows it to use the official terraform registry to download modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client used to download or copy source files with. Support all features that go-getter supports, local files, http, git etc.

func New

func New(options *Options) *Client

New creates a new getter client. It configures all the detectors and getters itself to make sure they are configured correctly.

func (*Client) Clone

func (c *Client) Clone(workingDir string) *Client

Clone creates a clone of the client with an alternative new working directory. If workingDir is set to "" it will just reuse same directory in client

func (*Client) Detect

func (c *Client) Detect(src string) (string, error)

Detect is a wrapper on go-getter detect and will return a new source string that is the parsed url using correct getter

func (*Client) Get

func (c *Client) Get(src, dst string) error

Get retrieves sources from src and load them into dst folder. If version is set it will try to download from terraform registry. Set to nil to disable this feature.

func (*Client) GetFile

func (c *Client) GetFile(src, dst string) error

GetFile retrieves a single file from src destination. It implements almost same functionallity that Get function, but does only allow a single file to be downloaded. Since terraform registry does not supply single files it cannot download any single files from terraform registry.

type LocalGetter

type LocalGetter struct {
	getter.FileGetter
}

LocalGetter is a wrapper around the go-getter implementation of FileGetter This is due to the go-getter implementation does not support copying a local directory, it will only create a symlink. That causes some problems for modules that should be copied into temp folder

func (*LocalGetter) Get

func (g *LocalGetter) Get(dst string, u *url.URL) error

Get overwrites FileGetter.Get if Copy is set to true. Otherwise it will just call the FileGetter.Get function and use standard functionality

func (*LocalGetter) GetFile

func (g *LocalGetter) GetFile(dst string, u *url.URL) error

GetFile just wraps the FileGetter function

type Options

type Options struct {
	Timeout          time.Duration
	WorkingDirectory string
}

Options for initialization a new getter client

type RegistryDetector

type RegistryDetector struct {
	// contains filtered or unexported fields
}

RegistryDetector implements detector to detect terraform registry. Src have to be formatted with query parameter ?registryVersion= avinor/storage-account/azurerm?registryVersion=1.0

func (*RegistryDetector) Detect

func (d *RegistryDetector) Detect(src, _ string) (string, bool, error)

Detect implements the Detector interface and will check if this source is a terraform registry source. If src contains ?registryVersion parameter it will assume it is a registry source.

func (*RegistryDetector) DetectRegistry

func (d *RegistryDetector) DetectRegistry(src string) (string, bool, error)

DetectRegistry tries to locate the download location for terraform registry source

Jump to

Keyboard shortcuts

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