tooth

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAvailableVersions

func GetAvailableVersions(ctx *context.Context, toothRepoPath string) (semver.Versions,
	error)

GetAvailableVersions fetches the version list of a tooth repository.

func GetLatestVersion

func GetLatestVersion(ctx *context.Context,
	toothRepoPath string) (semver.Version, error)

GetLatestVersion returns the latest =version of a tooth repository.

func GetLatestVersionInVersionRange

func GetLatestVersionInVersionRange(ctx *context.Context,
	toothRepoPath string, versionRange semver.Range) (semver.Version, error)

GetLatestVersionInVersionRange returns the latest version in a version range.

func IsInstalled

func IsInstalled(ctx *context.Context, toothRepoPath string) (bool, error)

IsInstalled checks if a tooth is installed.

func IsValidToothRepoPath

func IsValidToothRepoPath(toothRepoPath string) bool

IsValidToothRepoPath checks if the tooth repository path is valid.

Types

type Archive

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

Archive is an archive containing a tooth.

func MakeArchive

func MakeArchive(archiveFilePath path.Path) (Archive, error)

MakeArchive creates a new archive. It will automatically convert metadata to platform-specific.

func (Archive) ContentFilePathRoot

func (ar Archive) ContentFilePathRoot() path.Path

ContentFilePathRoot returns the directory of tooth.json in the archive.

func (Archive) FilePath

func (ar Archive) FilePath() path.Path

FilePath returns the path of the asset archive.

func (Archive) Metadata

func (ar Archive) Metadata() Metadata

Metadata returns the metadata of the archive.

type Metadata

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

func GetAllMetadata

func GetAllMetadata(ctx *context.Context) ([]Metadata, error)

GetAllMetadata lists all installed tooth metadata.

func GetMetadata

func GetMetadata(ctx *context.Context, toothRepoPath string) (Metadata,
	error)

GetMetadata finds the installed tooth metadata.

func MakeMetadata

func MakeMetadata(jsonBytes []byte) (Metadata, error)

MakeMetadata parses the given jsonBytes and returns a Metadata.

func MakeMetadataFromRaw

func MakeMetadataFromRaw(rawMetadata RawMetadata) (Metadata, error)

MakeMetadataFromRaw returns a Metadata from the given RawMetadata.

func (Metadata) AssetURL

func (m Metadata) AssetURL() (*url.URL, error)

func (Metadata) Commands

func (m Metadata) Commands() RawMetadataCommands

func (Metadata) Dependencies

func (m Metadata) Dependencies() map[string]semver.Range

func (Metadata) DependenciesAsStrings

func (m Metadata) DependenciesAsStrings() map[string]string

func (Metadata) Files

func (m Metadata) Files() RawMetadataFiles

func (Metadata) Info

func (m Metadata) Info() RawMetadataInfo

func (Metadata) MarshalJSON

func (m Metadata) MarshalJSON() ([]byte, error)

func (Metadata) Prerequisites

func (m Metadata) Prerequisites() map[string]semver.Range

func (Metadata) PrerequisitesAsStrings

func (m Metadata) PrerequisitesAsStrings() map[string]string

func (Metadata) Raw

func (m Metadata) Raw() RawMetadata

func (Metadata) ToPlatformSpecific added in v0.18.1

func (m Metadata) ToPlatformSpecific(goos string, goarch string) (Metadata, error)

func (Metadata) ToothRepoPath

func (m Metadata) ToothRepoPath() string

func (Metadata) Version

func (m Metadata) Version() semver.Version

type RawMetadata

type RawMetadata struct {
	FormatVersion int             `json:"format_version"`
	Tooth         string          `json:"tooth"`
	Version       string          `json:"version"`
	Info          RawMetadataInfo `json:"info"`

	AssetURL      string              `json:"asset_url,omitempty"`
	Commands      RawMetadataCommands `json:"commands,omitempty"`
	Dependencies  map[string]string   `json:"dependencies,omitempty"`
	Prerequisites map[string]string   `json:"prerequisites,omitempty"`
	Files         RawMetadataFiles    `json:"files,omitempty"`

	Platforms []RawMetadataPlatformsItem `json:"platforms,omitempty"`
}

Why to split Metadata and RawMetadata? Because we encounter a problem when we want to add a getter with the same name as a field.

type RawMetadataCommands

type RawMetadataCommands struct {
	PreInstall    []string `json:"pre_install,omitempty"`
	PostInstall   []string `json:"post_install,omitempty"`
	PreUninstall  []string `json:"pre_uninstall,omitempty"`
	PostUninstall []string `json:"post_uninstall,omitempty"`
}

type RawMetadataFiles

type RawMetadataFiles struct {
	Place    []RawMetadataFilesPlaceItem `json:"place,omitempty"`
	Preserve []string                    `json:"preserve,omitempty"`
	Remove   []string                    `json:"remove,omitempty"`
}

type RawMetadataFilesPlaceItem

type RawMetadataFilesPlaceItem struct {
	Src  string `json:"src"`
	Dest string `json:"dest"`
}

type RawMetadataInfo

type RawMetadataInfo struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Author      string   `json:"author"`
	Tags        []string `json:"tags"`
	Source      string   `json:"source,omitempty"`
}

type RawMetadataPlatformsItem

type RawMetadataPlatformsItem struct {
	GOARCH string `json:"goarch,omitempty"`
	GOOS   string `json:"goos"`

	AssetURL      string              `json:"asset_url,omitempty"`
	Commands      RawMetadataCommands `json:"commands,omitempty"`
	Dependencies  map[string]string   `json:"dependencies,omitempty"`
	Prerequisites map[string]string   `json:"prerequisites,omitempty"`
	Files         RawMetadataFiles    `json:"files,omitempty"`
}

Directories

Path Synopsis
migration

Jump to

Keyboard shortcuts

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