download

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(url string) (response *http.Response, err error)

DownloadFile downloads a file from a `url`. Response body needs to be closed by caller.

func Extract

func Extract(file string, extension string, dir string) (err error)

Extract extracts a file int dir. The extension guides the type of extraction.

func GetDeploySettingsFile

func GetDeploySettingsFile(installDir string) string

GetDeploySettingsFile gets the deploy settings file inside the install directory.

func StoreDeploySettings

func StoreDeploySettings(file string, settings IDeploySettings) error

StoreDeploySettings stores the deploy `settings` to `file`.

Types

type Asset

type Asset struct {
	FileName string // The file name of the asset.
	URL      string // The download URL of the asset.

	Extension string // Extension of the assert (can be empty).
}

Asset holds data for Git web services such as Github or Gitea.

func (*Asset) IsValid

func (a *Asset) IsValid() bool

IsValid checks if the asset is valid.

type Checksums

type Checksums struct {
	File          Asset
	FileSignature Asset
}

Checksums holds the checksum and its signature file.

func (*Checksums) IsValid

func (c *Checksums) IsValid() bool

IsValid checks if the checksums data is valid.

type GiteaDeploySettings

type GiteaDeploySettings struct {
	RepoSettings
	APIUrl string // API url of the Gitea service.

	// If empty, the internal Githooks binary
	// embedded PGP is taken from `.deploy.pgp`.
	PublicPGP string
}

GiteaDeploySettings are deploy settings for Gitea.

func (*GiteaDeploySettings) Download

func (s *GiteaDeploySettings) Download(versionTag string, dir string) error

Download downloads the version with `versionTag` into `dir` from a Gitea instance.

type GithubDeploySettings

type GithubDeploySettings struct {
	RepoSettings

	// If empty, the internal Githooks binary
	// embedded PGP is taken from `.deploy.pgp`.
	PublicPGP string
}

GithubDeploySettings are deploy settings for Github.

func (*GithubDeploySettings) Download

func (s *GithubDeploySettings) Download(versionTag string, dir string) error

Download downloads the version with `versionTag` to `dir` from a Github instance.

type HTTPDeploySettings

type HTTPDeploySettings struct {
	// Path template string which can contain
	// - `{{VersionTag}}` : The version tag to download.
	// - `{{Version}}` : The version to download (removed prefix 'v' of `VersionTag`).
	// - `{{Os}}` : The `runtime.GOOS` variable with the operating system.
	// - `{{Arch}}` : The `runtime.GOARCH` for type architecture.
	// pointing to the compressed archive of the Githooks binaries.
	// In the same url directory need to be a checksum file
	// `githooks.checksums`
	// and a checksum signature file.
	// `githooks.checksums.sig` which is validated using
	// the `PublicPGP`.
	URLTemplate string

	// If empty, the internal Githooks binary
	// embedded PGP is taken from `.deploy.pgp`.
	PublicPGP string
}

HTTPDeploySettings are deploy settings for HTTP downloading.

func (*HTTPDeploySettings) Download

func (s *HTTPDeploySettings) Download(versionTag string, dir string) error

Download downloads the Githooks from a template URL and extracts it into `dir`.

type IDeploySettings

type IDeploySettings interface {
	Download(versionTag string, dir string) error
}

IDeploySettings is the common interface for all deploy settings.

func LoadDeploySettings

func LoadDeploySettings(file string) (IDeploySettings, error)

LoadDeploySettings load the deploy settings from `file`.

type LocalDeploySettings

type LocalDeploySettings struct {
	// Path template string which can contain
	// - `{{VersionTag}}` : The version tag to download.
	// - `{{Version}}` : The version to download (removed prefix 'v' of `VersionTag`).
	// - `{{Os}}` : The `runtime.GOOS` variable with the operating system.
	// - `{{Arch}}` : The `runtime.GOARCH` for type architecture.
	// pointing to the compressed archive of the Githooks binaries.
	// In the same directory need to be a checksum file
	// `githooks.checksums`
	// and a checksum signature file.
	// `githooks.checksums.sig` which is validated using
	// the `PublicPGP`.
	PathTemplate string

	// If empty, the internal Githooks binary
	// embedded PGP is taken from `.deploy.pgp`.
	PublicPGP string
}

LocalDeploySettings are deploy settings for accessing the deploy locally.

func (*LocalDeploySettings) Download

func (s *LocalDeploySettings) Download(versionTag string, dir string) error

Download downloads the Githooks from a template URL and extracts it into `dir`.

type RepoSettings

type RepoSettings struct {
	Owner      string // The owner of the repository.
	Repository string // The repository name.
}

RepoSettings holds repo data for web based Git services such as Github or Gitea.

Jump to

Keyboard shortcuts

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