Skip to content

Commit

Permalink
add initial s3_uri support
Browse files Browse the repository at this point in the history
Signed-off-by: cscanlin <[email protected]>
  • Loading branch information
cscanlin-kwh committed Apr 26, 2023
1 parent 319e934 commit ca696a9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion in/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"
"strconv"

"github.com/concourse/s3-resource"
s3resource "github.com/concourse/s3-resource"
"github.com/concourse/s3-resource/versions"
)

Expand All @@ -28,6 +28,10 @@ func (up *RequestURLProvider) s3URL(request Request, remotePath string) string {
return up.s3Client.URL(request.Source.Bucket, remotePath, request.Source.Private, request.Version.VersionID)
}

func GetS3URI(request Request, remotePath string) string {
return "s3://" + request.Source.Bucket + remotePath
}

type Command struct {
s3client s3resource.S3Client
urlProvider RequestURLProvider
Expand Down Expand Up @@ -56,6 +60,7 @@ func (command *Command) Run(destinationDir string, request Request) (Response, e
var versionNumber string
var versionID string
var url string
var s3_uri string
var isInitialVersion bool
var skipDownload bool

Expand Down Expand Up @@ -152,6 +157,10 @@ func (command *Command) Run(destinationDir string, request Request) (Response, e
if err = command.writeURLFile(destinationDir, url); err != nil {
return Response{}, err
}
s3_uri = GetS3URI(request, remotePath)
if err = command.writeS3URIFile(destinationDir, s3_uri); err != nil {
return Response{}, err
}
}

err = command.writeVersionFile(versionNumber, destinationDir)
Expand Down Expand Up @@ -182,6 +191,10 @@ func (command *Command) writeURLFile(destDir string, url string) error {
return ioutil.WriteFile(filepath.Join(destDir, "url"), []byte(url), 0644)
}

func (command *Command) writeS3URIFile(destDir string, s3_uri string) error {
return ioutil.WriteFile(filepath.Join(destDir, "s3_uri"), []byte(s3_uri), 0644)
}

func (command *Command) writeVersionFile(versionNumber string, destDir string) error {
return ioutil.WriteFile(filepath.Join(destDir, "version"), []byte(versionNumber), 0644)
}
Expand Down

0 comments on commit ca696a9

Please sign in to comment.