sandbox

package
v0.0.0-...-06ec9a8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOptions       = errors.New("sandbox: invalid options")
	ErrWorkflowDispatch     = errors.New("sandbox: workflow dispatch failed")
	ErrWorkflowStartTimeout = errors.New("sandbox: workflow start timeout")
	ErrMetadataTimeout      = errors.New("sandbox: metadata not published")
	ErrSandboxFailed        = errors.New("sandbox: workflow failed before sandbox was ready")
	ErrSSHExecution         = errors.New("sandbox: ssh execution failed")
)

Functions

This section is empty.

Types

type CreateSandboxOptions

type CreateSandboxOptions struct {
	Name string

	GitHubRepository string
	GitHubWorkflow   string
	GitHubRef        string
	GitHubToken      string

	PinggyToken string

	// Deprecated: UptermServer is ignored. Use PinggyToken.
	UptermServer string

	StartupTimeout time.Duration
}

CreateSandboxOptions 定义创建 sandbox 所需的输入参数。

func DefaultCreateSandboxOptions

func DefaultCreateSandboxOptions() CreateSandboxOptions

DefaultCreateSandboxOptions 返回创建 sandbox 的默认参数。

Example
package main

import (
	"fmt"

	"github.com/117503445/github-action-sandbox/sdk/sandbox"
)

func main() {
	opts := sandbox.DefaultCreateSandboxOptions()

	fmt.Println(opts.GitHubWorkflow)
	fmt.Println(opts.GitHubRef)
	fmt.Printf("%q\n", opts.PinggyToken)

}
Output:
sandbox.yml
main
""

type DiskCleanupStep

type DiskCleanupStep struct {
	Name string

	StartedAt   time.Time
	CompletedAt time.Time
	Duration    time.Duration

	AvailableBytesBefore int64
	AvailableBytesAfter  int64
	FreedBytes           int64

	Command string
}

DiskCleanupStep 表示一次清理步骤的执行结果。

type FreeDiskSpaceOptions

type FreeDiskSpaceOptions struct {
	Android       bool
	Dotnet        bool
	Haskell       bool
	LargePackages bool
	DockerImages  bool
	ToolCache     bool
	SwapStorage   bool
}

FreeDiskSpaceOptions 定义基于 SSH 在 sandbox 内执行磁盘清理时的选项。

func DefaultFreeDiskSpaceOptions

func DefaultFreeDiskSpaceOptions() FreeDiskSpaceOptions

DefaultFreeDiskSpaceOptions 返回基于 SSH 清理磁盘的默认参数。

Example
package main

import (
	"fmt"

	"github.com/117503445/github-action-sandbox/sdk/sandbox"
)

func main() {
	opts := sandbox.DefaultFreeDiskSpaceOptions()

	fmt.Println(opts.Android)
	fmt.Println(opts.ToolCache)

}
Output:
true
false

type FreeDiskSpaceResult

type FreeDiskSpaceResult struct {
	StartedAt   time.Time
	CompletedAt time.Time
	Duration    time.Duration

	AvailableBytesBefore int64
	AvailableBytesAfter  int64
	FreedBytes           int64

	Steps []DiskCleanupStep
}

FreeDiskSpaceResult 汇总一次磁盘清理的结果。

type ListSandboxesOptions

type ListSandboxesOptions struct {
	GitHubRepository string
	GitHubWorkflow   string
	GitHubToken      string

	Limit int
}

ListSandboxesOptions 定义列出 sandbox 所需的输入参数。

func DefaultListSandboxesOptions

func DefaultListSandboxesOptions() ListSandboxesOptions

DefaultListSandboxesOptions 返回列出 sandbox 的默认参数。

Example
package main

import (
	"fmt"

	"github.com/117503445/github-action-sandbox/sdk/sandbox"
)

func main() {
	opts := sandbox.DefaultListSandboxesOptions()

	fmt.Println(opts.GitHubWorkflow)
	fmt.Println(opts.Limit)

}
Output:
sandbox.yml
20

type Sandbox

type Sandbox struct {
	ID     string
	Status string

	Repository string
	Workflow   string
	Ref        string
	RunID      int64
	RunURL     string

	SSHHost    string
	SSHPort    int
	SSHUser    string
	SSHCommand string

	CreatedAt time.Time
	// contains filtered or unexported fields
}

Sandbox 表示一个已创建的 GitHub Actions sandbox。

func CreateSandbox

func CreateSandbox(ctx context.Context, opts CreateSandboxOptions) (*Sandbox, error)

CreateSandbox 创建一个新的 GitHub Actions sandbox。

func ListSandboxes

func ListSandboxes(ctx context.Context, opts ListSandboxesOptions) ([]*Sandbox, error)

ListSandboxes 列出一个 workflow 下最近的 sandbox runs。

func (*Sandbox) Close

func (s *Sandbox) Close(ctx context.Context) error

Close 取消对应的 workflow run,并等待 run 结束。

func (*Sandbox) FreeDiskSpace

func (s *Sandbox) FreeDiskSpace(ctx context.Context, opts FreeDiskSpaceOptions) (*FreeDiskSpaceResult, error)

FreeDiskSpace 基于 SSH 在 sandbox 内执行磁盘清理,并返回每个步骤的耗时和释放空间。

Jump to

Keyboard shortcuts

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