feat: add API v2 support by adding APGroup and DNSRecord resource handling with generated code (#23)

* feat: add API v2 support by adding APGroup and DNSRecord resource handling with generated code

* fix tests
This commit is contained in:
Mateusz Filipowicz
2025-02-17 15:39:54 +01:00
committed by GitHub
parent dca894e8e7
commit aa188a6faa
14 changed files with 482 additions and 175 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
)
// ensurePath checks if a path exists and is a directory, if not it creates the directory. Returns true if the directories were created.
@@ -24,3 +25,29 @@ func ensurePath(path string) (bool, error) {
}
return false, nil
}
func findProjectRoot() (string, error) {
wd, err := os.Getwd()
if err != nil {
return "", err
}
// Walk up the directory tree until we find a go.mod file
for {
if _, err := os.Stat(filepath.Join(wd, "go.mod")); err == nil {
return wd, nil
}
if wd == "/" {
break
}
wd = filepath.Dir(wd)
}
return "", errors.New("unable to find project root")
}
func findCodegenDir() (string, error) {
root, err := findProjectRoot()
if err != nil {
return "", err
}
return filepath.Join(root, "codegen"), nil
}