config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeDirName       = "vibepit"
	CacheDirName         = "vibepit"
	ConfigDirName        = "vibepit"
	ProjectConfigDirName = ".vibepit"
)
View Source
const (
	MemorySourceCLI     = "--memory flag"
	MemorySourceProject = "project config"
	MemorySourceGlobal  = "global config"
)

Sources of the memory limit, as reported by MemoryLimit.

Variables

View Source
var CommitID = "HEAD"
View Source
var Version = "0.0.0"

Functions

func AppendAllowDNS

func AppendAllowDNS(projectConfigPath string, entries []string) error

AppendAllowDNS adds entries to the allow-dns list of an existing project config. It loads the current config, deduplicates, and writes back.

func AppendAllowHTTP

func AppendAllowHTTP(projectConfigPath string, entries []string) error

AppendAllowHTTP adds entries to the allow-http list of an existing project config. It loads the current config, deduplicates, and writes back.

func DefaultGlobalPath

func DefaultGlobalPath() string

func DefaultProjectPath

func DefaultProjectPath(projectRoot string) string

func DetectPresets

func DetectPresets(projectDir string) []string

DetectPresets scans the project root for marker files and returns the names of presets that match. Only presets with Matchers are considered.

func FindProjectRoot

func FindProjectRoot(path string) (string, error)

FindProjectRoot returns the Git repository root for the given path, or the path itself if it is not inside a Git repository.

func MavenSettings

func MavenSettings(host string, port int) []byte

func ParseMemoryLimit added in v0.5.0

func ParseMemoryLimit(memory string) (int64, error)

ParseMemoryLimit parses a docker-style memory size (e.g. "512m", "8g") into bytes. Empty and a zero size ("0", "0g", ...) both mean no limit and return 0.

func RandomProxyPort

func RandomProxyPort(excluded []int) (int, error)

RandomProxyPort returns a random port in the ephemeral range (49152-65535) that is not in the excluded set.

func RunFirstTimeSetup

func RunFirstTimeSetup(projectDir, projectConfigPath string) ([]string, error)

RunFirstTimeSetup shows an interactive preset selector and writes the project config file. Returns the selected preset names.

func RunReconfigure

func RunReconfigure(projectConfigPath, projectDir string) ([]string, error)

RunReconfigure re-runs the interactive preset selector and rewrites only the presets section of the project config. Every other key (allow-http, allow-dns, allow-host-ports, memory, ...) and all comments are left as they are, so settings the template writer doesn't know about survive.

Types

type Config

type Config struct {
	Global  GlobalConfig
	Project ProjectConfig
}

func Load

func Load(globalPath, projectPath string) (*Config, error)

func (*Config) MemoryLimit added in v0.5.0

func (c *Config) MemoryLimit(cliMemory string) (int64, string, error)

MemoryLimit returns the sandbox memory limit in bytes, or 0 for no limit, along with the source the value came from ("" when unset). The CLI value takes precedence over project config, which takes precedence over global config. An explicit "0" at any level disables a limit set at a lower-precedence level.

func (*Config) Merge

func (c *Config) Merge(cliAllow []string, cliPresets []string) (MergedConfig, error)

Merge combines global config, project config, CLI flags, and expanded presets into a single flat config. Duplicates are removed while preserving order.

type GlobalConfig

type GlobalConfig struct {
	AllowHTTP   []string `koanf:"allow-http"`
	AllowDNS    []string `koanf:"allow-dns"`
	BlockCIDR   []string `koanf:"block-cidr"`
	AllowCIDR   []string `koanf:"allow-cidr"`
	ExtraHosts  []string `koanf:"extra-hosts"`
	UpstreamDNS string   `koanf:"upstream-dns"`
	Memory      string   `koanf:"memory"`
}

type MergedConfig

type MergedConfig struct {
	AllowHTTP      []string `json:"allow-http"`
	AllowDNS       []string `json:"allow-dns"`
	BlockCIDR      []string `json:"block-cidr"`
	AllowCIDR      []string `json:"allow-cidr"`
	ExtraHosts     []string `json:"extra-hosts,omitempty"`
	UpstreamDNS    string   `json:"upstream-dns,omitempty"`
	AllowHostPorts []int    `json:"allow-host-ports"`
	ProxyIP        string   `json:"proxy-ip,omitempty"`
	HostGateway    string   `json:"host-gateway,omitempty"`
	ProxyPort      int      `json:"proxy-port,omitempty"`
	ControlAPIPort int      `json:"control-api-port,omitempty"`
	SSHForwardAddr string   `json:"ssh-forward-addr,omitempty"`
}

type ProjectConfig

type ProjectConfig struct {
	Presets        []string `koanf:"presets"`
	AllowHTTP      []string `koanf:"allow-http"`
	AllowDNS       []string `koanf:"allow-dns"`
	AllowHostPorts []int    `koanf:"allow-host-ports"`
	Memory         string   `koanf:"memory"`
}

Jump to

Keyboard shortcuts

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