feat(vendordep): add vendordep management

- Add vendordep add
- Add vendordep remove
- Add vendordep list
- Refactor downloading
This commit is contained in:
2025-10-17 14:15:37 -04:00
parent e073c0d391
commit 2a22f41fac
18 changed files with 1099 additions and 184 deletions

41
utils/utils.go Normal file
View File

@@ -0,0 +1,41 @@
package utils
import (
"fmt"
"log/slog"
"os"
"path/filepath"
"strings"
)
func FindEntryDirInParents(startPath string, lookingFor string) (string, error) {
absPath, err := filepath.Abs(startPath)
if err != nil {
slog.Error("Unable to get the absolute path", "path", startPath, "error", err)
return "", err
}
// Find our depth so we don't have to do more checking than necessary
components := strings.Split(filepath.Clean(absPath), string(os.PathSeparator))
// Start searching from the current directory upwards
currentPath := absPath
for i := len(components); i > 0; i-- {
lookingForPath := filepath.Join(currentPath, lookingFor)
_, err := os.Stat(lookingForPath)
if err == nil {
realLookingForPath, err := filepath.Abs(currentPath)
if err != nil {
slog.Error("Unable to get the absolute path", "path", lookingForPath, "error", err)
return "", err
}
return realLookingForPath, nil
}
// Go up one directory level
currentPath = filepath.Dir(currentPath)
}
return "", fmt.Errorf(lookingFor + " not found")
}