sdk

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoolYes        = "true"
	BoolNo         = "false"
	UnLinkAttrFlag = "unlink"
)

Variables

View Source
var ErrRuntimeNotFound = errors.New("runtime not found")

Functions

func IsUseUnLink(attr pathmeta.Attr) bool

Types

type AvailableRuntime added in v1.0.0

type AvailableRuntime struct {
	Version Version
	Name    string
	Note    string
}

type AvailableRuntimePackage added in v1.0.0

type AvailableRuntimePackage struct {
	*AvailableRuntime
	Additions []*AvailableRuntime
}

type Metadata added in v1.0.0

type Metadata struct {
	Name                string
	PluginMetadata      *plugin.Metadata
	SdkInstalledPath    string
	PluginInstalledPath string
}

Metadata contains the metadata of the SDK and plugin installed paths

type Runtime added in v1.0.0

type Runtime struct {
	Name    string  `json:"name"`
	Version Version `json:"version"`
	Path    string  `json:"path"`
}

Runtime represents a runtime environment with its version and installation path.

type RuntimePackage added in v1.0.0

type RuntimePackage struct {
	*Runtime
	PackagePath string
	Additions   []*Runtime `json:"additions"`
}

RuntimePackage represents a package of runtimes, including a main runtime and additional runtimes.

func (*RuntimePackage) ReplacePath added in v1.0.0

func (r *RuntimePackage) ReplacePath(parentPath string) *RuntimePackage

ReplacePath returns a new RuntimePackage with all runtimes' paths replaced by joining the parentPath and their names.

type Sdk

type Sdk interface {
	Install(version Version) error                                        // Install a specific runtime of the SDK
	Uninstall(version Version) error                                      // Uninstall a specific runtime of the SDK
	Available(args []string) ([]*AvailableRuntimePackage, error)          // List available runtime of the SDK
	EnvKeys(runtimePackage *RuntimePackage) (*env.Envs, error)            // Get environment variables for a specific runtime of the SDK
	Use(version Version, scope env.UseScope) error                        // Use a specific runtime in a given scope
	UseWithConfig(version Version, scope env.UseScope, unlink bool) error // Use with link configuration
	Unuse(scopes ...env.UseScope) error                                   // Unuse the current runtime in a given scope
	GetRuntimePackage(version Version) (*RuntimePackage, error)           // Get the runtime package for a specific version
	CheckRuntimeExist(version Version) bool                               // Check if a specific runtime version is installed
	InstalledList() []Version
	ParseLegacyFile(path string) (Version, error) // Parse legacy version file to get the runtime version
	Current() Version
	Metadata() *Metadata // Get the metadata of the SDK

	// CreateSymlinksForScope creates symlinks for a specific version in the given scope
	CreateSymlinksForScope(version Version, scope env.UseScope) error
	// EnvKeysForScope returns environment variables for a version in the given scope
	// It creates symlinks if needed and returns env vars with paths pointing to symlinks
	EnvKeysForScope(version Version, scope env.UseScope) (*env.Envs, error)

	Close()
}

Sdk interface defines the methods for managing software development kits (SDKs).

func NewSdk

func NewSdk(runtimeEnvContext *env.RuntimeEnvContext, pluginPath string) (Sdk, error)

NewSdk creates a new SDK instance based on the provided plugin path and runtime environment context.

type SdkEnv added in v1.0.0

type SdkEnv struct {
	Sdk *impl
	Env *env.Envs
}

type SdkEnvs added in v1.0.0

type SdkEnvs []*SdkEnv

func (*SdkEnvs) ToEnvs added in v1.0.0

func (d *SdkEnvs) ToEnvs() *env.Envs

func (*SdkEnvs) ToExportEnvs added in v1.0.0

func (d *SdkEnvs) ToExportEnvs() env.Vars

func (*SdkEnvs) ToVars added in v1.0.0

func (d *SdkEnvs) ToVars() env.Vars

ToVars export the env vars of SDK to shell

type Version

type Version string

Version represents the version string of SDK runtime.

type VersionNotExistsError added in v1.0.0

type VersionNotExistsError struct {
	Label string
}

func (*VersionNotExistsError) Error added in v1.0.0

func (e *VersionNotExistsError) Error() string

Jump to

Keyboard shortcuts

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