@@ -12,11 +12,75 @@ import (
1212 "github.com/tetratelabs/func-e/internal/api"
1313)
1414
15- // HomeDir is an absolute path which most importantly contains "versions"
16- // installed from EnvoyVersionsURL. Defaults to "${HOME}/.func-e"
15+ // Deprecated: Use ConfigHome, DataHome, StateHome or RuntimeDir instead.
16+ // This function will be removed in a future version.
1717func HomeDir (homeDir string ) RunOption {
1818 return func (o * api.RunOpts ) {
19- o .HomeDir = homeDir
19+ o .ConfigHome = homeDir
20+ o .DataHome = homeDir
21+ o .StateHome = homeDir
22+ o .RuntimeDir = homeDir
23+ }
24+ }
25+
26+ // ConfigHome is the directory containing configuration files.
27+ // Defaults to "~/.config/func-e"
28+ //
29+ // Files stored here:
30+ // - envoy-version (selected version preference)
31+ func ConfigHome (configHome string ) RunOption {
32+ return func (o * api.RunOpts ) {
33+ o .ConfigHome = configHome
34+ }
35+ }
36+
37+ // DataHome is the directory containing downloaded Envoy binaries.
38+ // Defaults to "~/.local/share/func-e"
39+ //
40+ // Files stored here:
41+ // - envoy-versions/{version}/bin/envoy (downloaded Envoy binaries)
42+ func DataHome (dataHome string ) RunOption {
43+ return func (o * api.RunOpts ) {
44+ o .DataHome = dataHome
45+ }
46+ }
47+
48+ // StateHome is the directory containing persistent state like run logs.
49+ // Defaults to "~/.local/state/func-e"
50+ //
51+ // Files stored here:
52+ // - envoy-runs/{runID}/stdout.log,stderr.log (per-run logs)
53+ // - envoy-runs/{runID}/config_dump.json (Envoy configuration snapshot)
54+ func StateHome (stateHome string ) RunOption {
55+ return func (o * api.RunOpts ) {
56+ o .StateHome = stateHome
57+ }
58+ }
59+
60+ // RuntimeDir is the directory containing ephemeral runtime files.
61+ // Defaults to "/tmp/func-e-${UID}"
62+ //
63+ // Files stored here:
64+ // - {runID}/admin-address.txt (Envoy admin API endpoint)
65+ //
66+ // Note: Runtime files are ephemeral and may be cleaned up on system restart.
67+ func RuntimeDir (runtimeDir string ) RunOption {
68+ return func (o * api.RunOpts ) {
69+ o .RuntimeDir = runtimeDir
70+ }
71+ }
72+
73+ // RunID sets a custom run identifier used in StateDir and RuntimeDir paths.
74+ // By default, a timestamp-based runID is auto-generated (e.g., "20250115_123456_789").
75+ //
76+ // Use this to:
77+ // - Create predictable directories for Docker/K8s (e.g., RunID("0"))
78+ // - Implement custom naming schemes
79+ //
80+ // Validation: runID cannot contain path separators (/ or \)
81+ func RunID (runID string ) RunOption {
82+ return func (o * api.RunOpts ) {
83+ o .RunID = runID
2084 }
2185}
2286
@@ -29,7 +93,7 @@ func EnvoyVersionsURL(envoyVersionsURL string) RunOption {
2993}
3094
3195// EnvoyVersion overrides the version of Envoy to run. Defaults to the
32- // contents of "$HomeDir/versions/ version".
96+ // contents of "$ConfigHome/envoy- version".
3397//
3498// When that file is missing, it is generated from ".latestVersion" from the
3599// EnvoyVersionsURL. Its value can be in full version major.minor.patch format,
0 commit comments