File tree 3 files changed +21
-4
lines changed
3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -125,5 +125,9 @@ func read(path string) ([]byte, error) {
125
125
}
126
126
127
127
func DefaultDir () string {
128
- return configdir .LocalConfig ("coderv2" )
128
+ configDir := configdir .LocalConfig ("coderv2" )
129
+ if dir := os .Getenv ("CLIDOCGEN_CONFIG_DIRECTORY" ); dir != "" {
130
+ configDir = dir
131
+ }
132
+ return configDir
129
133
}
Original file line number Diff line number Diff line change @@ -348,7 +348,9 @@ func DefaultCacheDir() string {
348
348
// For compatibility with systemd.
349
349
defaultCacheDir = dir
350
350
}
351
-
351
+ if dir := os .Getenv ("CLIDOCGEN_CACHE_DIRECTORY" ); dir != "" {
352
+ defaultCacheDir = dir
353
+ }
352
354
return filepath .Join (defaultCacheDir , "coder" )
353
355
}
354
356
Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ type manifest struct {
28
28
Routes []route `json:"routes,omitempty"`
29
29
}
30
30
31
- func unsetCoderEnv () {
31
+ func prepareEnv () {
32
+ // Unset CODER_ environment variables
32
33
for _ , env := range os .Environ () {
33
34
if strings .HasPrefix (env , "CODER_" ) {
34
35
split := strings .SplitN (env , "=" , 2 )
@@ -37,6 +38,16 @@ func unsetCoderEnv() {
37
38
}
38
39
}
39
40
}
41
+
42
+ // Override default OS values to ensure the same generated results.
43
+ err := os .Setenv ("CLIDOCGEN_CACHE_DIRECTORY" , "~/.cache" )
44
+ if err != nil {
45
+ panic (err )
46
+ }
47
+ err = os .Setenv ("CLIDOCGEN_CONFIG_DIRECTORY" , "~/.config/coderv2" )
48
+ if err != nil {
49
+ panic (err )
50
+ }
40
51
}
41
52
42
53
func deleteEmptyDirs (dir string ) error {
@@ -63,7 +74,7 @@ func deleteEmptyDirs(dir string) error {
63
74
}
64
75
65
76
func main () {
66
- unsetCoderEnv ()
77
+ prepareEnv ()
67
78
68
79
workdir , err := os .Getwd ()
69
80
if err != nil {
You can’t perform that action at this time.
0 commit comments