GetDataDir returns the user's data directory for docker agent (caches, content, logs). If an override has been set via [SetDataDir] it is returned instead. If the home directory cannot be determined, it falls back to a directory under the system temporary directory.
()
| 110 | // If the home directory cannot be determined, it falls back to a directory |
| 111 | // under the system temporary directory. |
| 112 | func GetDataDir() string { |
| 113 | return dataDirOverride.get(func() string { |
| 114 | homeDir, err := os.UserHomeDir() |
| 115 | if err != nil { |
| 116 | return filepath.Clean(filepath.Join(os.TempDir(), ".cagent")) |
| 117 | } |
| 118 | return filepath.Clean(filepath.Join(homeDir, ".cagent")) |
| 119 | }) |
| 120 | } |
| 121 | |
| 122 | // GetHomeDir returns the user's home directory. |
| 123 | // |