Documentation
¶
Overview ¶
Package cli implements the headmesh command-line tool.
Index ¶
- Variables
- func NewRoot(version string, deps Deps) *cobra.Command
- type APIError
- type Client
- func (c *Client) CompleteEnrollment(ctx context.Context, enrollmentID, secret string, nodeID uint64) (*Device, error)
- func (c *Client) CreateGrant(ctx context.Context, req map[string]any) (*Grant, error)
- func (c *Client) CreateInvite(ctx context.Context, roles []string, kind string, uses int, ttl time.Duration, ...) (*InviteResponse, error)
- func (c *Client) Devices(ctx context.Context) ([]Device, error)
- func (c *Client) Enroll(ctx context.Context, token, hostname, goos, arch string) (*EnrollResponse, error)
- func (c *Client) Grants(ctx context.Context) ([]Grant, error)
- func (c *Client) RevokeGrant(ctx context.Context, id string) (*Grant, error)
- type Deps
- type Device
- type EnrollResponse
- type ExecTailscale
- type Grant
- type Instance
- type InviteResponse
- type Tailscale
Constants ¶
This section is empty.
Variables ¶
var ErrNoAPIKey = errors.New("this command needs an API key: set HEADMESH_API_KEY")
ErrNoAPIKey is returned for commands that need HEADMESH_API_KEY when it is unset.
var ErrOtherTailnet = errors.New("this tailscaled is already connected to another tailnet")
ErrOtherTailnet means the target tailscaled is already on a different tailnet.
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
Status int `json:"status"`
Title string `json:"title"`
Detail string `json:"detail"`
}
APIError is an RFC 9457 problem returned by the server.
type Client ¶
Client is a small typed client for the Headmesh REST API.
func (*Client) CompleteEnrollment ¶
func (c *Client) CompleteEnrollment(ctx context.Context, enrollmentID, secret string, nodeID uint64) (*Device, error)
CompleteEnrollment binds the registered node to the device.
func (*Client) CreateGrant ¶
CreateGrant gives another org time-limited access to one device.
func (*Client) CreateInvite ¶
func (c *Client) CreateInvite(ctx context.Context, roles []string, kind string, uses int, ttl time.Duration, ephemeral bool) (*InviteResponse, error)
CreateInvite creates an enrollment token.
func (*Client) Enroll ¶
func (c *Client) Enroll(ctx context.Context, token, hostname, goos, arch string) (*EnrollResponse, error)
Enroll exchanges an enrollment token for a pre-auth key.
type Deps ¶
type Deps struct {
Tailscale Tailscale
EnsureInstance func(ctx context.Context, inst Instance) error
Hostname func() (string, error)
Getenv func(string) string
}
Deps are the CLI's side effects, replaceable in tests.
type Device ¶
type Device struct {
ID string `json:"id"`
ShortID string `json:"short_id"`
Name string `json:"name"`
GivenName string `json:"given_name"`
Kind string `json:"kind"`
Roles []string `json:"roles"`
IPv4 string `json:"ipv4,omitempty"`
IPv6 string `json:"ipv6,omitempty"`
Online bool `json:"online"`
State string `json:"state"`
}
Device mirrors the API's device.
type EnrollResponse ¶
type EnrollResponse struct {
EnrollmentID string `json:"enrollment_id"`
DeviceID string `json:"device_id"`
LoginServer string `json:"login_server"`
AuthKey string `json:"auth_key"`
Hostname string `json:"hostname"`
Tags []string `json:"tags"`
ExpiresAt time.Time `json:"expires_at"`
CompletionSecret string `json:"completion_secret"`
}
EnrollResponse mirrors the API's enroll response.
type ExecTailscale ¶
type ExecTailscale struct{ Binary string }
ExecTailscale shells out to the tailscale binary.
type Grant ¶
type Grant struct {
ID string `json:"id"`
GranteeOrg string `json:"grantee_org,omitempty"`
DstDeviceID string `json:"dst_device_id"`
Ports []string `json:"ports"`
StartsAt time.Time `json:"starts_at"`
ExpiresAt time.Time `json:"expires_at"`
Revoked bool `json:"revoked"`
ExternalRef string `json:"external_ref,omitempty"`
Enforced bool `json:"enforced"`
}
Grant mirrors the API's grant.
type Instance ¶
Instance identifies which tailscaled to drive. The zero value is the system's default daemon; a named instance is a separate tailscaled (own state, socket, UDP port and TUN device) so a machine can join a Headmesh network while staying on another tailnet — the pattern Xcelsior's GPU hosts already use.
func NamedInstance ¶
NamedInstance returns the paths Headmesh uses for an isolated tailscaled.