plan

package
v0.46.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadURLWithChecksum

func DownloadURLWithChecksum(url string) (string, error)

DownloadURLWithChecksum gets the contents of the given url, ensuring the checksum is correct. The provided url must contain a checksum parameter that matches the file being downloaded. If there isn't an error, the content returned by the url will be returned as a string. Returns an error if:

  • The url is not a URL or does not contain a checksum parameter.
  • Downloading the URL fails.
  • The checksum does not match what is returned by the URL.
  • The URL does not return a regular file.
  • The downloaded file is empty or only whitespace.

func DownloadUpgrade

func DownloadUpgrade(dstRoot, url, daemonName string) error

DownloadUpgrade downloads the given url into the provided directory and ensures it's valid. The provided url must contain a checksum parameter that matches the file being downloaded. If this returns nil, the download was successful, and {dstRoot}/bin/{daemonName} is a regular executable file. This is an opinionated directory structure that corresponds with Cosmovisor requirements. If the url is not an archive, it is downloaded and saved to {dstRoot}/bin/{daemonName}. If the url is an archive, it is downloaded and unpacked to {dstRoot}.

If the archive does not contain a /bin/{daemonName} file, then this will attempt to move /{daemonName} to /bin/{daemonName}.
If the archive does not contain either /bin/{daemonName} or /{daemonName}, an error is returned.

Note: Because a checksum is required, this function cannot be used to download non-archive directories. If dstRoot already exists, some or all of its contents might be updated.

func EnsureBinary

func EnsureBinary(path string) error

EnsureBinary checks that the given file exists as a regular file and is executable. An error is returned if:

  • The file does not exist.
  • The path exists, but is one of: Dir, Symlink, NamedPipe, Socket, Device, CharDevice, or Irregular.
  • The file exists, is not executable by all three of User, Group, and Other, and cannot be made executable.

func ValidateIsURLWithChecksum

func ValidateIsURLWithChecksum(urlStr string) error

ValidateIsURLWithChecksum checks that the given string is a url and contains a checksum query parameter.

Types

type BinaryDownloadURLMap

type BinaryDownloadURLMap map[string]string

BinaryDownloadURLMap is a map of os/architecture stings to a URL where the binary can be downloaded.

func (BinaryDownloadURLMap) CheckURLs

func (m BinaryDownloadURLMap) CheckURLs(daemonName string) error

CheckURLs checks that all entries have valid URLs that return expected data. The provided daemonName is the name of the executable file expected in all downloaded directories. Warning: This is an expensive process. It will make an HTTP GET request to each URL and download the response.

func (BinaryDownloadURLMap) ValidateBasic

func (m BinaryDownloadURLMap) ValidateBasic() error

ValidateBasic does stateless validation of this BinaryDownloadURLMap. It validates that:

  • This has at least one entry.
  • All entry keys have the format "os/arch" or are "any".
  • All entry values are valid URLs.
  • All URLs contain a checksum query parameter.

type Info

type Info struct {
	Binaries BinaryDownloadURLMap `json:"binaries"`
}

Info is the special structure that the Plan.Info string can be (as json).

func ParseInfo

func ParseInfo(infoStr string) (*Info, error)

ParseInfo parses an info string into a map of os/arch strings to URL string. If the infoStr is a url, an GET request will be made to it, and its response will be parsed instead.

func (Info) ValidateFull

func (m Info) ValidateFull(daemonName string) error

ValidateFull does all possible validation of this Info. The provided daemonName is the name of the executable file expected in all downloaded directories. It checks that:

  • Binaries.ValidateBasic() doesn't return an error
  • Binaries.CheckURLs(daemonName) doesn't return an error.

Warning: This is an expensive process. See BinaryDownloadURLMap.CheckURLs for more info.

Jump to

Keyboard shortcuts

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