MCPcopy Index your code
hub / github.com/docker/docker-agent / ResolveDatabasePath

Function ResolveDatabasePath

pkg/rag/strategy/helpers.go:45–75  ·  view source on GitHub ↗

ResolveDatabasePath resolves database configuration to a path

(dbCfg latest.RAGDatabaseConfig, parentDir, defaultName string)

Source from the content-addressed store, hash-verified

43
44// ResolveDatabasePath resolves database configuration to a path
45func ResolveDatabasePath(dbCfg latest.RAGDatabaseConfig, parentDir, defaultName string) (string, error) {
46 if dbCfg.IsEmpty() {
47 // Use default path in data directory
48 return filepath.Join(paths.GetDataDir(), defaultName), nil
49 }
50
51 dbStr, err := dbCfg.AsString()
52 if err != nil {
53 return "", err
54 }
55
56 // If it's a connection string (has ://), return as-is
57 if strings.Contains(dbStr, "://") {
58 return dbStr, nil
59 }
60
61 // If it's a relative file path, make it absolute
62 if !filepath.IsAbs(dbStr) {
63 if parentDir == "" {
64 slog.Debug("Resolving relative database path with empty parentDir, using working directory", "path", dbStr)
65 abs, err := filepath.Abs(dbStr)
66 if err != nil {
67 return "", fmt.Errorf("failed to resolve absolute path for %q: %w", dbStr, err)
68 }
69 return abs, nil
70 }
71 return filepath.Join(parentDir, dbStr), nil
72 }
73
74 return dbStr, nil
75}
76
77// GetParam gets a parameter from the config Params map.
78// It includes numeric coercion so YAML numbers (which may be decoded as int, int64,

Calls 4

GetDataDirFunction · 0.92
DebugMethod · 0.80
IsEmptyMethod · 0.45
AsStringMethod · 0.45