gravitational / force

A new programming language for cloud native workflows
https://force.gravitational.co
Apache License 2.0
31 stars 7 forks source link

aws.RecursiveCopy doesn't work if you use a path that is not the current working directory #67

Closed webvictim closed 5 years ago

webvictim commented 5 years ago

What happened: RecursiveCopy fails when providing a path that isn't the current working directory.

s3-upload.force:

func(){
     aws.RecursiveCopy(
          aws.Local{Path: "./build"},
          aws.S3{Bucket: "gusteleport.gravitational.io", Key: "4.1.0/"},
     ),
}
$ ls -l *.force
-rw-rw-r--. 1 gus gus 146 Oct  9 14:22 s3-upload.force
-rw-rw-r--. 1 gus gus  88 Oct  9 14:17 setup.force

$ ls -ld build
drwxrwxr-x. 2 gus gus 4096 Oct  9 15:03 build

$ ls -l build
total 105668
-rw-rw-r--. 1 gus gus 108196857 Oct  9 15:03 teleport-v4.2.0-alpha.1-linux-amd64-bin.tar.gz

$ force s3-upload.force
INFO             Process antaeus-1 triggered by Oneshot(time=2019-10-09 18:03:14.600735141 +0000 UTC) runner/run.go:245
Dest bucket: gusteleport.gravitational.io, key: 4.1.0/teleport-v4.2.0-alpha.1-linux-amd64-bin.tar.gzERRO [ANTAEUS-1] Process antaeus-1 failed after running for 94.309µs. error:[
ERROR REPORT:
Original Error: *trace.NotFoundError open teleport-v4.2.0-alpha.1-linux-amd64-bin.tar.gz: no such file or directory
Stack Trace:
    /home/gus/go/src/github.com/gravitational/force/pkg/aws/copy.go:279 github.com/gravitational/force/pkg/aws.uploadFile
    /home/gus/go/src/github.com/gravitational/force/pkg/aws/copy.go:269 github.com/gravitational/force/pkg/aws.uploadDir
    /home/gus/go/src/github.com/gravitational/force/pkg/aws/copy.go:167 github.com/gravitational/force/pkg/aws.(*CopyAction).Run
    /home/gus/go/src/github.com/gravitational/force/shell.go:341 github.com/gravitational/force.(*SequenceAction).RunWithScope
    /home/gus/go/src/github.com/gravitational/force/lambda.go:92 github.com/gravitational/force.(*LambdaFunctionCall).RunWithScope
    /home/gus/go/src/github.com/gravitational/force/lambda.go:42 github.com/gravitational/force.(*LambdaFunction).RunWithScope
    /home/gus/go/src/github.com/gravitational/force/lambda.go:71 github.com/gravitational/force.(*LambdaFunction).Run
    /home/gus/go/src/github.com/gravitational/force/shell.go:341 github.com/gravitational/force.(*SequenceAction).RunWithScope
    /home/gus/go/src/github.com/gravitational/force/shell.go:361 github.com/gravitational/force.(*SequenceAction).Run
    /home/gus/go/src/github.com/gravitational/force/pkg/runner/local.go:125 github.com/gravitational/force/pkg/runner.(*LocalProcess).triggerActions.func1
    /usr/local/go/src/runtime/asm_amd64.s:1357 runtime.goexit
User Message: open teleport-v4.2.0-alpha.1-linux-amd64-bin.tar.gz: no such file or directory
] id:bb62109c proc:antaeus-1 runner/local.go:127

What you expected to happen: RecursiveCopy should add the source path onto the filename as part of the copy.

webvictim commented 5 years ago

I should add that I can probably work around this by setting the source path to . as per the example and running a chdir first, but the reason I want to use the functionality like this is so I don't upload the .force files which are present in the same directory.

klizhentas commented 5 years ago

fixed in master