cliconfig

package
v6.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRemotes = map[string]Remote{
	"images": ImagesRemote,
	"local":  LocalRemote,
}

DefaultRemotes is the list of default remotes.

View Source
var ErrNotLinux = fmt.Errorf("Can't connect to a local server on a non-Linux system")

ErrNotLinux is returned when attemping to access the "local" remote on non-Linux systems.

View Source
var ImagesRemote = Remote{
	Addr:     "https://images.linuxcontainers.org",
	Public:   true,
	Protocol: "simplestreams",
}

ImagesRemote is the community image server (over simplestreams).

View Source
var LocalRemote = Remote{
	Addr:     "unix://",
	Static:   true,
	Public:   false,
	Protocol: "incus",
}

LocalRemote is the default local remote (over the unix socket).

View Source
var StaticRemotes = map[string]Remote{
	"local": LocalRemote,
}

StaticRemotes is the list of remotes which can't be removed.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DefaultRemote holds the remote daemon name from the Remotes map
	// that the client should communicate with by default
	DefaultRemote string `yaml:"default-remote"`

	// Remotes defines a map of remote daemon names to the details for
	// communication with the named daemon
	Remotes map[string]Remote `yaml:"remotes"`

	// Command line aliases for `incus`
	Aliases map[string]string `yaml:"aliases"`

	// Configuration directory
	ConfigDir string `yaml:"-"`

	// Cache directory
	CacheDir string `yaml:"-"`

	// The UserAgent to pass for all queries
	UserAgent string `yaml:"-"`

	// PromptPassword is a helper function used when encountering an encrypted key
	PromptPassword func(filename string) (string, error) `yaml:"-"`

	// ProjectOverride allows overriding the default project
	ProjectOverride string `yaml:"-"`
	// contains filtered or unexported fields
}

Config holds settings to be used by a client or daemon.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads the configuration from the config path; if the path does not exist, it returns a default configuration; if the given path is empty it tries to determine automatically the configuration file to load.

func NewConfig

func NewConfig(configDir string, defaults bool) *Config

NewConfig returns a Config, optionally using default remotes.

func (*Config) ConfigPath

func (c *Config) ConfigPath(paths ...string) string

ConfigPath returns a joined path of the configuration directory and passed arguments.

func (*Config) CookiesPath

func (c *Config) CookiesPath(remote string) string

CookiesPath returns the path for the remote's cookie jar.

func (*Config) CopyGlobalCert

func (c *Config) CopyGlobalCert(src string, dst string) error

CopyGlobalCert will copy global (system-wide) certificates to the user config path.

func (*Config) GenerateClientCertificate

func (c *Config) GenerateClientCertificate() error

GenerateClientCertificate will generate the needed client.crt and client.key if needed.

func (*Config) GetImageServer

func (c *Config) GetImageServer(name string) (incus.ImageServer, error)

GetImageServer returns a ImageServer struct for the remote.

func (*Config) GetInstanceServer

func (c *Config) GetInstanceServer(name string) (incus.InstanceServer, error)

GetInstanceServer returns a InstanceServer struct for the remote.

func (*Config) GlobalConfigPath

func (c *Config) GlobalConfigPath(paths ...string) string

GlobalConfigPath returns a joined path of the global configuration directory and passed arguments.

func (*Config) HasClientCertificate

func (c *Config) HasClientCertificate() bool

HasClientCertificate will return true if a client certificate has already been generated.

func (*Config) HasRemoteClientCertificate

func (c *Config) HasRemoteClientCertificate(name string) bool

HasRemoteClientCertificate will return true if a remote-specific client certificate is present.

func (*Config) OIDCTokenPath

func (c *Config) OIDCTokenPath(remote string) string

OIDCTokenPath returns the path for the remote's OIDC tokens.

func (*Config) ParseRemote

func (c *Config) ParseRemote(raw string) (string, string, error)

ParseRemote splits remote and object.

func (*Config) SaveConfig

func (c *Config) SaveConfig(path string) error

SaveConfig writes the provided configuration to the config file.

func (*Config) SaveOIDCTokens

func (c *Config) SaveOIDCTokens()

SaveOIDCTokens saves OIDC tokens to disk.

func (*Config) ServerCertPath

func (c *Config) ServerCertPath(remote string) string

ServerCertPath returns the path for the remote's server certificate.

type Remote

type Remote struct {
	Addr      string `yaml:"addr"`
	AuthType  string `yaml:"auth_type,omitempty"`
	KeepAlive int    `yaml:"keepalive,omitempty"`
	Project   string `yaml:"project,omitempty"`
	Protocol  string `yaml:"protocol,omitempty"`
	Public    bool   `yaml:"public"`
	Global    bool   `yaml:"-"`
	Static    bool   `yaml:"-"`
}

Remote holds details for communication with a remote daemon.

Jump to

Keyboard shortcuts

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