Added static DNS record

This commit is contained in:
appkins
2024-07-13 04:52:27 -05:00
parent 85af09f5e0
commit e99c608dec
62 changed files with 1406 additions and 11 deletions

View File

@@ -159,6 +159,63 @@ func extractJSON(jarFile, fieldsDir string) error {
}
}
wd, err := os.Getwd()
if err != nil {
panic(err)
}
rootDir := findModuleRoot(wd)
srcDir := path.Join(rootDir, "fields")
files, err := os.ReadDir(path.Join(srcDir, "custom"))
if err != nil {
return fmt.Errorf("unable to read custom directory: %w", err)
}
for _, file := range files {
if !file.IsDir() {
fs, err := os.Open(path.Join(srcDir, "custom", file.Name()))
if err != nil {
return fmt.Errorf("unable to open file: %w", err)
}
defer fs.Close()
rf, err := os.Create(filepath.Join(fieldsDir, file.Name()))
if err != nil {
return fmt.Errorf("unable to create file: %w", err)
}
defer rf.Close()
_, err = io.Copy(rf, fs)
if err != nil {
return fmt.Errorf("unable to copy file: %w", err)
}
_, err = io.ReadAll(fs)
if err != nil {
return fmt.Errorf("unable to read file: %w", err)
}
}
fmt.Println(file.Name(), file.IsDir())
}
// TODO: cleanup JSON
return nil
}
func findModuleRoot(dir string) (roots string) {
if dir == "" {
panic("dir not set")
}
dir = filepath.Clean(dir)
// Look for enclosing go.mod.
for {
if fi, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil && !fi.IsDir() {
return dir
}
d := filepath.Dir(dir)
if d == dir {
break
}
dir = d
}
return ""
}