remote

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package remote is the daemons the CLI knows, kept with the current one in ~/.config/dicer/remotes.yaml, and how each is reached.

Index

Constants

View Source
const (
	// ConfigDirEnv is the environment variable that overrides the
	// configuration directory.
	ConfigDirEnv = "DICER_CONFIG_DIR"
)
View Source
const (
	// Local names the built-in remote: the daemon on this machine, on its
	// default socket. It is always there and cannot be deleted.
	Local = "local"
)

Variables

This section is empty.

Functions

func ConfigDir added in v0.4.0

func ConfigDir() (string, error)

ConfigDir returns the configuration directory: $DICER_CONFIG_DIR, or dicer under the user's configuration directory.

func IsAddress

func IsAddress(s string) bool

IsAddress reports whether s is an address rather than a remote's name, which holds neither ':' nor '/'.

Types

type Config

type Config struct {
	// Current is the remote commands go to unless told otherwise. Empty
	// means the local one.
	Current string `yaml:"current,omitempty"`

	// Remotes are the configured remotes by name, the built-in one aside.
	Remotes map[string]Remote `yaml:"remotes,omitempty"`
}

Config is the set of remotes, as kept in remotes.yaml.

func Load

func Load(dir string) (*Config, error)

Load reads the remotes kept in dir. No file means none but the local one.

func (*Config) Create

func (c *Config) Create(name string, r Remote) error

Create adds a remote.

func (*Config) CurrentName

func (c *Config) CurrentName() string

CurrentName returns the name of the current remote.

func (*Config) Delete

func (c *Config) Delete(name string) error

Delete removes a remote. Deleting the current one makes the local one current.

func (*Config) Names

func (c *Config) Names() []string

Names returns every remote's name, the built-in one included, sorted.

func (*Config) Remote added in v0.4.0

func (c *Config) Remote(name string) (Remote, error)

Remote returns a remote by name, the built-in one included. A name not configured is an errdefs.ErrNotFound.

func (*Config) Save

func (c *Config) Save(dir string) error

Save writes the remotes into dir.

func (*Config) Use

func (c *Config) Use(name string) error

Use makes a remote the current one.

type Remote

type Remote struct {
	// Address is a gRPC target: unix:///path/to/socket, or HOST:PORT for a
	// daemon's TCP listener.
	Address string `yaml:"address"`

	// Token is what every call to a TCP address is made with, which also
	// says how the daemon is checked. A socket takes none.
	Token string `yaml:"token,omitempty"`
}

Remote is a daemon the CLI talks to: on its socket, or on its TCP listener with a token.

func Parse

func Parse(address string) (Remote, error)

Parse returns the remote an address names, with no token.

func (Remote) ClientOptions

func (r Remote) ClientOptions() []dicer.Option

ClientOptions returns what dicer.NewClient needs to reach the remote.

func (Remote) IsSocket added in v0.4.0

func (r Remote) IsSocket() bool

IsSocket reports whether the remote is a daemon's socket.

func (Remote) Validate

func (r Remote) Validate() error

Validate returns an error if the remote cannot be connected to. A TCP address without a token is valid: the token can come from elsewhere.

Jump to

Keyboard shortcuts

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