mode

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadFile

type DownloadFile struct {
	Mode        Mode            `hcl:"mode"`
	DownloadURL string          `hcl:"downloadURL"`
	Paths       []*DownloadPath `hcl:"download,block"`
}

DownloadFile represents a custom HCL format of how to handle module@version requests that are not found in storage.

func NewFile

func NewFile(m Mode, downloadURL string) (*DownloadFile, error)

NewFile takes a mode and returns a DownloadFile. Mode can be one of the constants declared above or a custom HCL file. To pass a custom HCL file, you can either point to a file path by passing file:/path/to/file OR custom:<base64-encoded-hcl> directly.

func (*DownloadFile) Match

func (d *DownloadFile) Match(mod string) Mode

Match returns the Mode that matches the given module. A pattern is prioritized by order in which it appears in the HCL file, while the default Mode will be returned if no patterns exist or match.

func (*DownloadFile) URL

func (d *DownloadFile) URL(mod string) string

URL returns the redirect URL that applies to the given module. If no pattern matches, the top level downloadURL is returned.

type DownloadPath

type DownloadPath struct {
	Pattern     string `hcl:"pattern,label"`
	Mode        Mode   `hcl:"mode"`
	DownloadURL string `hcl:"downloadURL,optional"`
}

DownloadPath represents a custom Mode for a matching path.

type Mode

type Mode string

Mode specifies the behavior of what to do when a module is not found in storage.

const (
	Sync          Mode = "sync"
	Async         Mode = "async"
	Redirect      Mode = "redirect"
	AsyncRedirect Mode = "async_redirect"
	None          Mode = "none"
)

DownloadMode constants. For more information see config.dev.toml.

Jump to

Keyboard shortcuts

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