( deps commandDeps, rawPath string, operation SupportBundleOperationRecord, )
| 233 | } |
| 234 | |
| 235 | func resolveSupportBundleOutputPath( |
| 236 | deps commandDeps, |
| 237 | rawPath string, |
| 238 | operation SupportBundleOperationRecord, |
| 239 | ) (string, error) { |
| 240 | homePaths, err := deps.resolveHome() |
| 241 | if err != nil { |
| 242 | return "", err |
| 243 | } |
| 244 | fileName := strings.TrimSpace(operation.FileName) |
| 245 | if fileName == "" { |
| 246 | fileName = fmt.Sprintf("agh-support-bundle-%s.tar.gz", time.Now().UTC().Format("20060102T150405Z")) |
| 247 | } |
| 248 | |
| 249 | trimmed := strings.TrimSpace(rawPath) |
| 250 | if trimmed == "" { |
| 251 | return filepath.Join(homePaths.HomeDir, supportBundlesDirName, fileName), nil |
| 252 | } |
| 253 | resolved, err := filepath.Abs(trimmed) |
| 254 | if err != nil { |
| 255 | return "", fmt.Errorf("cli: resolve support bundle output path: %w", err) |
| 256 | } |
| 257 | info, err := os.Stat(resolved) |
| 258 | if err == nil && info.IsDir() { |
| 259 | return filepath.Join(resolved, fileName), nil |
| 260 | } |
| 261 | if err != nil && !errors.Is(err, os.ErrNotExist) { |
| 262 | return "", fmt.Errorf("cli: inspect support bundle output path: %w", err) |
| 263 | } |
| 264 | return resolved, nil |
| 265 | } |
| 266 | |
| 267 | func downloadSupportBundle( |
| 268 | ctx context.Context, |
no test coverage detected