Skip to content

chore: clidocgen: generate consistent docs #7047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cli/config/file.go
Original file line number Diff line number Diff line change
@@ -125,5 +125,9 @@ func read(path string) ([]byte, error) {
}

func DefaultDir() string {
return configdir.LocalConfig("coderv2")
configDir := configdir.LocalConfig("coderv2")
if dir := os.Getenv("CLIDOCGEN_CONFIG_DIRECTORY"); dir != "" {
configDir = dir
}
return configDir
}
4 changes: 3 additions & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
@@ -348,7 +348,9 @@ func DefaultCacheDir() string {
// For compatibility with systemd.
defaultCacheDir = dir
}

if dir := os.Getenv("CLIDOCGEN_CACHE_DIRECTORY"); dir != "" {
defaultCacheDir = dir
}
return filepath.Join(defaultCacheDir, "coder")
}

15 changes: 13 additions & 2 deletions scripts/clidocgen/main.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@ type manifest struct {
Routes []route `json:"routes,omitempty"`
}

func unsetCoderEnv() {
func prepareEnv() {
// Unset CODER_ environment variables
for _, env := range os.Environ() {
if strings.HasPrefix(env, "CODER_") {
split := strings.SplitN(env, "=", 2)
@@ -37,6 +38,16 @@ func unsetCoderEnv() {
}
}
}

// Override default OS values to ensure the same generated results.
err := os.Setenv("CLIDOCGEN_CACHE_DIRECTORY", "~/.cache")
if err != nil {
panic(err)
}
err = os.Setenv("CLIDOCGEN_CONFIG_DIRECTORY", "~/.config/coderv2")
if err != nil {
panic(err)
}
}

func deleteEmptyDirs(dir string) error {
@@ -63,7 +74,7 @@ func deleteEmptyDirs(dir string) error {
}

func main() {
unsetCoderEnv()
prepareEnv()

workdir, err := os.Getwd()
if err != nil {