tooth

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-3.0 Imports: 21 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) AssetFilePath added in v0.19.0

func (ar Archive) AssetFilePath() (path.Path, error)

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.

func (Archive) ToAssetArchiveAttached added in v0.19.0

func (ar Archive) ToAssetArchiveAttached(assetArchiveFilePath path.Path) (Archive, error)

ToAssetArchiveAttached converts the archive to an archive with asset archive attached. If assetArchivePath is empty, the tooth archive will be used as the asset archive.

type Commands added in v0.19.0

type Commands struct {
	PreInstall    []string
	PostInstall   []string
	PreUninstall  []string
	PostUninstall []string
}

type Files added in v0.19.0

type Files struct {
	Place    []FilesPlaceItem
	Preserve []path.Path
	Remove   []path.Path
}

type FilesPlaceItem added in v0.19.0

type FilesPlaceItem struct {
	Src  path.Path
	Dest path.Path
}

type Info added in v0.19.0

type Info struct {
	Name        string
	Description string
	Author      string
	Tags        []string
}

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() Commands

func (Metadata) Dependencies

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

func (Metadata) DependenciesAsStrings

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

func (Metadata) Files

func (m Metadata) Files() (Files, error)

func (Metadata) Info

func (m Metadata) Info() Info

func (Metadata) IsWildcardPopulated added in v0.19.0

func (m Metadata) IsWildcardPopulated() bool

func (Metadata) MarshalJSON

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

func (Metadata) Prerequisites

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

func (Metadata) PrerequisitesAsStrings

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

func (Metadata) ToFilePathPrefixPrepended added in v0.19.0

func (m Metadata) ToFilePathPrefixPrepended(prefix path.Path) Metadata

ToFilePathPrefixPrepended prepends the given prefix to files.place field of metadata.

func (Metadata) ToPlatformSpecific added in v0.18.1

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

func (Metadata) ToWildcardPopulated added in v0.19.0

func (m Metadata) ToWildcardPopulated(filePaths []path.Path) (Metadata, error)

ToWildcardPopulated populates wildcards in files.place field of metadata.

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"`
}

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