MCPcopy Create free account
hub / github.com/Scalingo/cli / uploadFiles

Method uploadFiles

apps/run.go:395–419  ·  view source on GitHub ↗
(ctx context.Context, endpoint string, files []string)

Source from the content-addressed store, hash-verified

393}
394
395func (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
421func (runCtx *runContext) compressDir(ctx context.Context, dir string) (string, error) {
422 tmpDir, err := os.MkdirTemp(os.TempDir(), "job-file")

Callers 1

RunFunction · 0.95

Calls 2

compressDirMethod · 0.95
uploadFileMethod · 0.95

Tested by

no test coverage detected