(ctx context.Context, endpoint string, files []string)
| 393 | } |
| 394 | |
| 395 | func (runCtx *runContext) uploadFiles(ctx context.Context, endpoint string, files []string) error { |
| 396 | for _, file := range files { |
| 397 | stat, err := os.Stat(file) |
| 398 | if err != nil { |
| 399 | return errors.Wrapf(ctx, err, "stat file %s", file) |
| 400 | } |
| 401 | relPath := file |
| 402 | file, err = filepath.Abs(relPath) |
| 403 | if err != nil { |
| 404 | return errors.Wrapf(ctx, err, "get absolute path of %s", relPath) |
| 405 | } |
| 406 | if stat.IsDir() { |
| 407 | dir := file |
| 408 | file, err = runCtx.compressDir(ctx, dir) |
| 409 | if err != nil { |
| 410 | return errors.Wrapf(ctx, err, "compress directory %s", dir) |
| 411 | } |
| 412 | } |
| 413 | err = runCtx.uploadFile(ctx, endpoint, file) |
| 414 | if err != nil { |
| 415 | return errors.Wrapf(ctx, err, "upload file %s", file) |
| 416 | } |
| 417 | } |
| 418 | return nil |
| 419 | } |
| 420 | |
| 421 | func (runCtx *runContext) compressDir(ctx context.Context, dir string) (string, error) { |
| 422 | tmpDir, err := os.MkdirTemp(os.TempDir(), "job-file") |
no test coverage detected