workdir

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatsVer1 = "v1"
)

Variables

View Source
var ErrToolNotFoundInSpec = errors.New("tool not found in spec")
View Source
var ErrToolNotInstalled = errors.New("tool not installed")

Functions

func Init added in v0.14.1

func Init(dir string) (string, error)

Init will initialize context in specified directory.

Types

type IRuntime added in v0.14.1

type IRuntime interface {
	// Parse will parse string with module name. It is used only on `toolset add` step.
	// Parse should:
	//	1) ensure that this program is valid, exists, and can be installed.
	//	2) normalize program name and return a canonical name.
	Parse(ctx context.Context, str string) (string, error)
	// GetModule returns an information about module (parsed module).
	GetModule(ctx context.Context, program string) (*structs.ModuleInfo, error)
	// Install will install the program.
	Install(ctx context.Context, program string) error
	Run(ctx context.Context, program string, args ...string) error
	GetLatest(ctx context.Context, module string) (string, bool, error)
	Remove(ctx context.Context, tool structs.Tool) error
}

type Include added in v0.12.0

type Include struct {
	Src  string   `json:"src"`
	Tags []string `json:"tags"`
}

func (Include) IsSame added in v0.12.0

func (i Include) IsSame(include Include) bool

func (*Include) UnmarshalJSON added in v0.14.0

func (i *Include) UnmarshalJSON(bb []byte) error

type Lock added in v0.12.0

type Lock struct {
	Tools   structs.Tools `json:"tools"`
	Remotes []RemoteSpec  `json:"remotes"`
}

func (*Lock) FromSpec added in v0.15.0

func (l *Lock) FromSpec(spec *Spec)

type RemoteSpec added in v0.12.0

type RemoteSpec struct {
	Source string   `json:"source"`
	Spec   Spec     `json:"spec"`
	Tags   []string `json:"tags"`
}

func (*RemoteSpec) UnmarshalJSON added in v0.14.1

func (r *RemoteSpec) UnmarshalJSON(bb []byte) error

type Runtimes added in v0.24.0

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

func NewRuntimes added in v0.24.0

func NewRuntimes(ctx context.Context, baseDir, specDir string) (*Runtimes, error)

func (*Runtimes) Get added in v0.24.0

func (r *Runtimes) Get(runtime string) (IRuntime, error)

func (*Runtimes) GetInstall added in v0.24.0

func (r *Runtimes) GetInstall(ctx context.Context, runtime string) (IRuntime, error)

GetInstall will get installed runtime or try to install it in other case.

func (*Runtimes) Install added in v0.24.0

func (r *Runtimes) Install(ctx context.Context, runtime string) error

type SourceUri added in v0.13.0

type SourceUri interface {
	// contains filtered or unexported methods
}

type SourceUriFile added in v0.13.0

type SourceUriFile struct {
	Path string
}

type SourceUriGit added in v0.13.0

type SourceUriGit struct {
	Addr string
	Path string
}

type SourceUriUrl added in v0.13.0

type SourceUriUrl struct {
	URL string
}

type Spec

type Spec struct {
	// This dir is store all toolset-related files.
	// This directory should be managed by toolset only.
	Dir      string        `json:"dir"`
	Tools    structs.Tools `json:"tools"`
	Includes []Include     `json:"includes"`
}

func (*Spec) AddInclude added in v0.12.0

func (s *Spec) AddInclude(include Include) bool

type Stats added in v0.19.0

type Stats struct {
	Version string               `json:"version"`
	Tools   map[string]time.Time `json:"tools"`
}

type ToolState added in v0.15.0

type ToolState struct {
	Module  structs.ModuleInfo
	Tool    structs.Tool
	LastUse optional.Val[time.Time]
}

ToolState describe a state of this tool.

type Workdir added in v0.14.1

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

func New added in v0.14.1

func New(ctx context.Context, dir string) (*Workdir, error)

func (*Workdir) Add added in v0.14.1

func (c *Workdir) Add(ctx context.Context, runtime, program string, alias optional.Val[string], tags []string) (bool, string, error)

func (*Workdir) AddInclude added in v0.14.1

func (c *Workdir) AddInclude(ctx context.Context, source string, tags []string) (int, error)

func (*Workdir) CopySource added in v0.14.1

func (c *Workdir) CopySource(ctx context.Context, source string, tags []string) (int, error)

CopySource will add all tools from source. Source can be a path to file or a http url or git repo.

func (*Workdir) FindTool added in v0.14.1

func (c *Workdir) FindTool(name string) (*ToolState, error)

func (*Workdir) GetTools added in v0.15.0

func (c *Workdir) GetTools(ctx context.Context) ([]ToolState, error)

func (*Workdir) RemoveTool added in v0.22.0

func (c *Workdir) RemoveTool(ctx context.Context, target string) error

func (*Workdir) RunTool added in v0.14.1

func (c *Workdir) RunTool(ctx context.Context, str string, args ...string) error

RunTool will run a tool by its name and args.

func (*Workdir) RuntimeAdd added in v0.24.0

func (c *Workdir) RuntimeAdd(ctx context.Context, runtime string) error

func (*Workdir) RuntimeList added in v0.24.0

func (c *Workdir) RuntimeList() []string

func (*Workdir) Save added in v0.14.1

func (c *Workdir) Save() error

func (*Workdir) Sync added in v0.14.1

func (c *Workdir) Sync(ctx context.Context, maxWorkers int, tags []string) error

Sync will read the locked tools and try to install the desired version. It will skip the installation in case when we have a desired version.

func (*Workdir) Upgrade added in v0.14.1

func (c *Workdir) Upgrade(ctx context.Context, tags []string) error

Upgrade will upgrade only spec tools. and re-fetch latest versions of includes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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