gce

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gce implements core.HostProvider on Google Compute Engine by driving the gcloud CLI through setup.Gcloud. One VM per project is named provr-<project>-1, which is also its tailnet hostname and core.Host.ID.

Index

Constants

View Source
const (
	// FirstBootTimeout bounds the wait after creating a host.
	FirstBootTimeout = 5 * time.Minute
	// StartTimeout bounds the wait after starting a stopped host.
	StartTimeout = 2 * time.Minute
)

Ready-wait budgets.

Variables

View Source
var ErrNotReady = errors.New("host not ready")

ErrNotReady is returned when a host does not become ready in time.

Functions

This section is empty.

Types

type Options

type Options struct {
	// GCPProject is the GCP project id that hosts the VMs. Required.
	GCPProject string
	// Project is the provr project name. Required.
	Project string
	// Runner executes gcloud. Required.
	Runner execx.Runner
	// Impersonate is the service account to impersonate; defaults to
	// setup.OperatorEmail(GCPProject) when empty.
	Impersonate string
	// SSHBinary is the ssh executable; defaults to "ssh".
	SSHBinary string
	// Tailnet manages auth keys and devices. Required.
	Tailnet Tailnet
	// Tag is the ACL tag given to joined hosts; defaults to
	// setup.TailscaleTag.
	Tag string
	// TempDir holds the short-lived auth key file; defaults to os.TempDir().
	TempDir string
	// LockDir holds the per-project lock files; defaults to ~/.provr/locks.
	LockDir string
}

Options configures a Provider.

type Provider

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

Provider is a GCE-backed host provider.

func New

func New(opts Options) (*Provider, error)

New validates opts and returns a Provider.

func (*Provider) Delete

func (p *Provider) Delete(ctx context.Context, hostID string) error

Delete removes the host, its boot disk and its tailnet devices. A missing host is not an error.

func (*Provider) Ensure

func (p *Provider) Ensure(ctx context.Context, spec core.HostSpec) (core.Host, error)

Ensure returns the project's running host with room for another preview, starting a stopped host or creating a missing one. It holds the project lock for the whole call so concurrent callers create only one host.

func (*Provider) HostName

func (p *Provider) HostName(project string) string

HostName returns the instance name and tailnet hostname of the project's host: provr-<project>-1.

func (*Provider) List

func (p *Provider) List(ctx context.Context, project string) ([]core.Host, error)

List returns the managed hosts of project across all zones. Running hosts get an accurate PreviewCount over SSH. A running host that does not answer is still returned, with Reachable=false, PreviewCount 0 and ReachError set; callers that need counts must check Reachable.

func (*Provider) Stop

func (p *Provider) Stop(ctx context.Context, hostID string) error

Stop stops the host. An already stopped host is a no-op; a missing one is core.ErrNotFound.

type Tailnet

type Tailnet interface {
	CreateKey(ctx context.Context, spec api.KeySpec) (api.Key, error)
	RevokeKey(ctx context.Context, id string) error
	ListDevices(ctx context.Context) ([]api.Device, error)
	DeleteDevice(ctx context.Context, id string) error
}

Tailnet is the subset of the Tailscale API the join flow uses. It is satisfied by *api.Client.

Jump to

Keyboard shortcuts

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