config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(cfg *Config) error

func WriteBase added in v0.1.4

func WriteBase(path string, homeDir string) error

WriteBase writes a default base config file to path.

func WriteDefaultForEnv

func WriteDefaultForEnv(path string, mounts []DefaultMount, homeDir string) error

WriteDefaultForEnv writes a default config file for a new drop environment to path.

Types

type Config

type Config struct {
	Extends      string   `toml:"extends"`
	Mounts       []Mount  `toml:"mounts"`
	BlockedPaths []string `toml:"blocked_paths"`
	Environ      Environ  `toml:"environ"`
	Net          Net      `toml:"net"`
}

func Read

func Read(path string, homeDir string) (*Config, error)

type DefaultMount added in v0.1.3

type DefaultMount struct {
	Entry   string
	Comment string
}

type EnvVar

type EnvVar struct {
	Name  string
	Value string
}

func (*EnvVar) Expand

func (e *EnvVar) Expand(mapping func(string) string) string

func (*EnvVar) UnmarshalTOML

func (e *EnvVar) UnmarshalTOML(data any) error

type Environ

type Environ struct {
	ExposedVars []string `toml:"exposed_vars"`
	SetVars     []EnvVar `toml:"set_vars"`
}

type HostPort

type HostPort struct {
	Auto      bool
	HostPort  int
	GuestPort int
}

Different from PublishedPort because Pasta, contrary to its man page, doesn't seem to support HostIP for ports forwarded from host to the namespace.

func ParseHostPort

func ParseHostPort(spec string) (*HostPort, error)

ParseHostPort parses host port string. Like ParsePublishedPort, but does not allow to specify hostIP/, only HOST_PORT[:DROP_PORT] or "auto".

func (*HostPort) UnmarshalTOML

func (p *HostPort) UnmarshalTOML(data any) error

Custom toml.Unmarshaler for HostPort field. Input is a string in the format hostPort[:guestPort] or "auto" for automatic port forwarding of all ports.

type Mount

type Mount struct {
	Source  string
	Target  string
	RW      bool
	Overlay bool
}

func ParseMountCompact

func ParseMountCompact(str string) (*Mount, error)

ParseMountCompact parses mount configuration from a string of a form source:target:options, where target and options are optional. If target is not given or empty, it equals source. Options are comma separated and can be "rw" and "overlay". Valid strings: "~/go", "~/go:~/host-go" "~/go:~/host-go:ro", "~/go::ro,overlay

func (*Mount) UnmarshalTOML

func (m *Mount) UnmarshalTOML(data any) error

Custom toml.Unmarshaler for mount field which is of mixed type (TOML 1.0 feature). In TOML mount entry can be either a single Docker-style mount string source:target:option (like "~/go:~/host-go:ro"), or a more verbose TOML table {source = "~/go", target = "~/host-go", rw = true, overlay = false}, where target is optional and defaults to source if not specified.

type Net

type Net struct {
	Mode              string          `toml:"mode"`
	TCPPublishedPorts []PublishedPort `toml:"tcp_published_ports"`
	TCPHostPorts      []HostPort      `toml:"tcp_host_ports"`
	UDPPublishedPorts []PublishedPort `toml:"udp_published_ports"`
	UDPHostPorts      []HostPort      `toml:"udp_host_ports"`
}

type PublishedPort

type PublishedPort struct {
	Auto      bool
	HostIP    string
	HostPort  int
	GuestPort int
}

func ParsePublishedPort

func ParsePublishedPort(spec string) (*PublishedPort, error)

ParsePublishedPort parses and validates a published port string.

To keep things simple and keep an option of using a different connectivity tool, only the simplest Pasta mapping expressions are allowed.

Supported format of forwardSpecs items:

  • port (e.g., "8080") -> publishes Drop port 8080 as host port 8080 bound to 127.0.0.1 only
  • hostPort:guestPort (e.g., "8080:80") -> publishes Drop port 80 as host port 8080 bound to 127.0.0.1 only
  • hostIP/hostPort:guestPort (e.g., "192.168.0.3/8080:80") -> published Drop port 80 as host port 8080 bound to IP address 192.168.0.3
  • "auto" -> automatically publishes all open ports and binds them to ALL available IP addresses

func (*PublishedPort) UnmarshalTOML

func (p *PublishedPort) UnmarshalTOML(data any) error

Custom toml.Unmarshaler for PublishedPort field. Input entry is a string in the format [hostIP/][hostPort:]guestPort or "auto" for automatic port forwarding of all ports.

Jump to

Keyboard shortcuts

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