catalog

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEndpoint = "tcp:443"
	ServeVersion    = "0.0.1"
)
View Source
const DefaultFilename = "catalog.yaml"

Variables

This section is empty.

Functions

func CanonicalName

func CanonicalName(name string) string

CanonicalName strips a leading "svc:" so CLI args and API names match.

func ConfigDir

func ConfigDir() (string, error)

ConfigDir is $XDG_CONFIG_HOME/tscatalog or ~/.config/tscatalog.

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath is the XDG catalog file path (may not exist yet).

func HasAll

func HasAll(have, want []string) bool

HasAll reports whether have contains every string in want.

func JoinURL

func JoinURL(base, path string) string

func NormalizePort

func NormalizePort(p string) string

NormalizePort accepts "443" or "tcp:443" and returns "tcp:443".

func PortsEqual

func PortsEqual(a, b []string) bool

func ResolvePath

func ResolvePath(explicit string) (string, error)

ResolvePath picks the catalog file. explicit is the -f flag; empty means auto-discover. Order: -f → TSCATALOG_CATALOG → $XDG_CONFIG_HOME/tscatalog/catalog.yaml (if present) → ./catalog.yaml (if present).

Types

type Access

type Access struct {
	Src             []string `yaml:"src"`
	AutoApproveHost string   `yaml:"autoApproveHost"`
	// TagOwners are allowed to apply AutoApproveHost. Empty means autogroup:admin
	// when the policy merger fills an empty or missing tagOwners entry.
	TagOwners []string `yaml:"tagOwners"`
}

type Check

type Check struct {
	Path   string `yaml:"path"`
	Expect []int  `yaml:"expect"`
	Public []int  `yaml:"public"`
}

Check is optional HTTP probing on top of a TCP bind check.

func (Check) LocalExpect

func (c Check) LocalExpect() []int

func (Check) LocalPath

func (c Check) LocalPath() string

func (Check) PublicExpect

func (c Check) PublicExpect() []int

type File

type File struct {
	Endpoint string    `yaml:"endpoint"`
	Access   Access    `yaml:"access"`
	Services []Service `yaml:"services"`
}

File is the on-disk catalog.

func Load

func Load(path string) (*File, error)

func (*File) AutostartNames

func (f *File) AutostartNames() []string

AutostartNames is the catalog names with autostart: true, in file order.

func (*File) ExpandForRuntime

func (f *File) ExpandForRuntime(names []string) ([]Service, error)

ExpandForRuntime returns services to start or probe, with each requires chain before its dependent. When names is empty, every catalog row is included in dependency order. Stop does not use this — only explicitly named services stop.

func (*File) HostTags

func (f *File) HostTags() []string

HostTags is the identity stamped on VIP Services so tagged hosts can auto-approve via autoApprovers.services["tag:…"] (svc:* is not a valid key).

func (*File) Lookup

func (f *File) Lookup(name string) (Service, bool)

Lookup resolves a catalog name, a vip label, or svc: plus either label.

func (*File) Names

func (f *File) Names() []string

func (*File) ServeConfig

func (f *File) ServeConfig() *ServeFile

func (*File) VIPServices

func (f *File) VIPServices() []tailscale.Service

func (*File) Validate

func (f *File) Validate() error

type Kind

type Kind string

Kind is the catalog discriminator for one start slot.

const (
	KindProcess  Kind = "process"
	KindCompose  Kind = "compose"
	KindExternal Kind = "external"
)

type Launch

type Launch []LaunchSpec

Launch is one process spec or several (UI + API).

func (Launch) Defined

func (l Launch) Defined() bool

func (Launch) Find

func (l Launch) Find(id string) (int, LaunchSpec, error)

Find matches a slot by ID or by a decimal index. An empty id is the caller's error; Find still reports it as unknown.

func (*Launch) UnmarshalYAML

func (l *Launch) UnmarshalYAML(value *yaml.Node) error

func (Launch) Validate

func (l Launch) Validate() error

type LaunchSpec

type LaunchSpec struct {
	Kind     string   `yaml:"kind,omitempty"`
	Name     string   `yaml:"name,omitempty"`
	Cwd      string   `yaml:"cwd"`
	Start    []string `yaml:"start"`
	Stop     []string `yaml:"stop"`
	Detach   bool     `yaml:"detach"`
	Services []string `yaml:"services,omitempty"`
	Files    []string `yaml:"files,omitempty"`
	Status   []string `yaml:"status,omitempty"`
	Logs     []string `yaml:"logs,omitempty"`
}

LaunchSpec is how this host starts one slot. start/stop/status/logs are argv (not a shell). Kind may be omitted: a strict `docker compose up` argv is compose, Detach selects a watched process, and anything else is an external helper.

func (LaunchSpec) ComposeSource

func (s LaunchSpec) ComposeSource() (services, files []string, project string, err error)

ComposeSource is the compose working set for this spec. An explicit kind uses Files and Services and an empty project name. An inferred argv supplies files, services, and the project name.

func (LaunchSpec) ID

func (s LaunchSpec) ID(index int) string

ID is the slot name, or the decimal index when Name is empty.

func (LaunchSpec) ResolveKind

func (s LaunchSpec) ResolveKind() (Kind, error)

ResolveKind returns the explicit kind, or infers one when Kind is empty. Compose is tested before detach, so a compose argv with detach is compose and then rejected by Validate.

func (LaunchSpec) Warnings

func (s LaunchSpec) Warnings() []string

Warnings is set only for an external helper missing status or logs. Validate does not call Warnings. Load still succeeds when those argv are omitted.

type ServeFile

type ServeFile struct {
	Version  string                  `json:"version"`
	Services map[string]ServeService `json:"services"`
}

ServeFile is the JSON document for `tailscale serve set-config`.

type ServeService

type ServeService struct {
	Endpoints map[string]string `json:"endpoints"`
}

type Service

type Service struct {
	Name        string   `yaml:"name"`
	VIP         string   `yaml:"vip,omitempty"`
	DisplayName string   `yaml:"displayName"`
	Local       string   `yaml:"local"`
	Comment     string   `yaml:"comment"`
	Requires    []string `yaml:"requires,omitempty"`
	Unpublished bool     `yaml:"unpublished,omitempty"`
	Autostart   bool     `yaml:"autostart,omitempty"`
	Launch      Launch   `yaml:"launch"`
	Check       Check    `yaml:"check"`
}

func (Service) Published

func (s Service) Published() bool

Published reports whether this row gets VIP, Serve, advertise, and ACL grants.

func (Service) SVCName

func (s Service) SVCName() string

func (Service) TailscaleLabel

func (s Service) TailscaleLabel() string

TailscaleLabel is the single DNS label used for svc:* and https://<label>.<tailnet>.ts.net. When name contains dots, set vip explicitly or it defaults to dots replaced by hyphens.

func (Service) VIPService

func (s Service) VIPService(endpoint string, tags []string) tailscale.Service

Jump to

Keyboard shortcuts

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