api

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package api contains everything related to the toolctl API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLatestVersion

func GetLatestVersion(toolctlAPI ToolctlAPI, tool Tool) (version *semver.Version, err error)

GetLatestVersion returns the latest version for the given tool, OS and arch

func SaveMeta added in v0.2.2

func SaveMeta(toolctlAPI ToolctlAPI, meta Meta) (err error)

SaveMeta saves the metadata for the toolctl API.

func SaveToolPlatformMeta

func SaveToolPlatformMeta(toolctlAPI ToolctlAPI, tool Tool, meta ToolPlatformMeta) (err error)

SaveToolPlatformMeta saves the metadata for the given tool and platform.

func SaveToolPlatformVersionMeta added in v0.2.2

func SaveToolPlatformVersionMeta(toolctlAPI ToolctlAPI, tool Tool, meta ToolPlatformVersionMeta) (err error)

SaveToolPlatformVersionMeta saves version metadata for a tool to the API.

Types

type Location

type Location uint32

Location represents the location of the API, currently remote or local.

const (
	// Local represents the local API location.
	Local Location = iota
	// Remote represents the remote API location.
	Remote
)

type Meta

type Meta struct {
	Tools []string
}

Meta contains metadata for the toolctl API.

func GetMeta

func GetMeta(toolctlAPI ToolctlAPI) (meta Meta, err error)

GetMeta returns the metadata for the toolctl API.

type NotFoundError

type NotFoundError struct {
}

NotFoundError is returned when an API resource could not be found.

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Tool

type Tool struct {
	Name    string
	Version string
	OS      string
	Arch    string
}

Tool describes a tool. It contains its name and version as well as the OS and architecture for which it was compiled.

type ToolMeta

type ToolMeta struct {
	Description         string
	DownloadURLTemplate string `yaml:"downloadURLTemplate"`
	Homepage            string
	IgnoredVersions     []string `yaml:"ignoredVersions"`
	VersionArgs         []string `yaml:"versionArgs"`
}

ToolMeta contains metadata for a tool.

func GetToolMeta

func GetToolMeta(toolctlAPI ToolctlAPI, tool Tool) (meta ToolMeta, err error)

GetToolMeta returns the metadata for the given tool.

type ToolPlatformMeta

type ToolPlatformMeta struct {
	Version ToolPlatformMetaVersion
}

ToolPlatformMeta contains metadata for a given tool and platform.

func GetToolPlatformMeta

func GetToolPlatformMeta(toolctlAPI ToolctlAPI, tool Tool) (meta ToolPlatformMeta, err error)

GetToolPlatformMeta returns the metadata for the given tool and platform.

type ToolPlatformMetaVersion

type ToolPlatformMetaVersion struct {
	Earliest string
	Latest   string
}

ToolPlatformMetaVersion contains version metadata for a given tool and platform.

type ToolPlatformVersionMeta

type ToolPlatformVersionMeta struct {
	URL    string
	SHA256 string
}

ToolPlatformVersionMeta contains metadata for a given tool version and platform.

func GetToolPlatformVersionMeta

func GetToolPlatformVersionMeta(toolctlAPI ToolctlAPI, tool Tool) (meta ToolPlatformVersionMeta, err error)

GetToolPlatformVersionMeta returns the metadata for the given tool version and platform.

type ToolctlAPI

type ToolctlAPI interface {
	LocalAPIBasePath() string
	LocalAPIFS() afero.Fs
	Location() Location

	GetContents(path string) (found bool, contents []byte, err error)
	SaveContents(path string, data []byte) error
}

ToolctlAPI defines the interface that all toolctl APIs need to implement.

func New

func New(
	localAPIFS afero.Fs, cmd *cobra.Command, defaultLocation Location,
) (toolctlAPI ToolctlAPI, err error)

New returns a new API instance, based on the specified command line flags and the default location.

func NewLocalAPI

func NewLocalAPI(localAPIFS afero.Fs, basePath string) (ToolctlAPI, error)

NewLocalAPI returns a new local API instance.

func NewRemoteAPI

func NewRemoteAPI(localFS afero.Fs, remoteAPIBaseURL string) (ToolctlAPI, error)

NewRemoteAPI returns a new remote API instance.

Jump to

Keyboard shortcuts

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