Documentation
¶
Overview ¶
Package extension manages third-party commands installed from GitHub releases (like `gh extension`).
Unlike cargo/git, binaries named reearth-* on PATH are never executed implicitly. Only extensions installed through this manager run, and their SHA-256 is pinned in a lock file and re-verified before every run.
Extensions are not sandboxed. They run with the user's own access, like any process the user starts, and inherit environment variables, including REEARTH_TOKEN. The CLI does not hand them the credentials it stores (keyring or file); an extension that needs the API calls `$REEARTH_BIN api ...`. REEARTH_EXTENSION=1 is how the CLI recognises a call from an extension. None of this stops a malicious extension, which could read the keyring itself: users are protected by installing only extensions they trust.
Index ¶
- Constants
- Variables
- func AssetName(name, goos, goarch string) string
- func Dispatch(m *Manager) func(f *core.Factory, root *cobra.Command, args []string) (bool, int)
- func NewCmd(f *core.Factory, m *Manager) *cobra.Command
- func ParseRepo(s string) (owner, repo, name string, err error)
- func Run(f *core.Factory, m *Manager, e *Entry, args []string) (int, error)
- type Entry
- type Manager
- func (m *Manager) Command(e *Entry, args []string, reearthBin string) (*exec.Cmd, error)
- func (m *Manager) Get(name string) (*Entry, bool)
- func (m *Manager) Install(ctx context.Context, p *Plan) (*Entry, error)
- func (m *Manager) List() ([]*Entry, error)
- func (m *Manager) PlanInstall(ctx context.Context, repoArg, tag string) (*Plan, error)
- func (m *Manager) Remove(name string) error
- type Plan
Constants ¶
const OfficialOwner = "reearth"
OfficialOwner is the GitHub owner whose extensions are marked official.
Variables ¶
var ErrTampered = errors.New("extension binary does not match its recorded checksum")
ErrTampered means the binary on disk no longer matches the lock file.
Functions ¶
func Dispatch ¶
Dispatch runs `reearth <name> ...` for an installed extension when <name> is not a built-in command. Agents must use `ext exec` explicitly.
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"name"`
Repo string `json:"repo"`
Version string `json:"version"`
Path string `json:"path"`
SHA256 string `json:"sha256"`
Official bool `json:"official"`
// ChecksumsVerified means the release published a checksums file that matched.
ChecksumsVerified bool `json:"checksums_verified"`
InstalledAt time.Time `json:"installed_at"`
}
type Manager ¶
type Manager struct {
Dir string
GH *ghrelease.Client
// Reserved reports names that extensions may not take (built-in commands).
Reserved func(name string) bool
}
func (*Manager) Command ¶
Command returns an exec.Cmd for the extension after verifying its checksum.
func (*Manager) Install ¶
Install downloads the planned binary, verifies it and records it in the lock file.
func (*Manager) PlanInstall ¶
PlanInstall resolves the release and asset for repoArg at tag (latest if empty).
type Plan ¶
type Plan struct {
Name string
Repo string
Tag string
Official bool
Asset *ghrelease.Asset
// Checksum is the expected SHA-256 from the release's checksums files;
// empty only when the release publishes none.
Checksum string
URL string
}
Plan describes what an install would do, for confirmation.