Skip to content

Commit

Permalink
Nicer key names
Browse files Browse the repository at this point in the history
  • Loading branch information
aidansteele committed Aug 15, 2019
1 parent ae42a8e commit f0dfc6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestPackageAndExecuteE2E(t *testing.T) {
})
_ = RootCmd.Execute()

assert.Regexp(t, regexp.MustCompile(`Uploaded ./func to s3://stackit-ap-southeast-2-607481581596/test-stack-packaged/[a-f0-9]{32}.zip \(v = [^)]+\)
assert.Regexp(t, regexp.MustCompile(`Uploaded ./func to s3://stackit-ap-southeast-2-607481581596/test-stack-packaged/func.zip/[a-f0-9]{32} \(v = [^)]+\)
\[\d\d:\d\d:\d\d] test-stack-packaged - CREATE_IN_PROGRESS - User Initiated
\[\d\d:\d\d:\d\d] FunctionRole - CREATE_IN_PROGRESS
\[\d\d:\d\d:\d\d] FunctionRole - CREATE_IN_PROGRESS - Resource creation Initiated
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestPackageAndExecuteE2E(t *testing.T) {
})
_ = RootCmd.Execute()

assert.Regexp(t, regexp.MustCompile(`./func already exists at s3://stackit-ap-southeast-2-607481581596/test-stack-packaged/[a-f0-9]{32}.zip \(v = [^)]+\)`), buf.String())
assert.Regexp(t, regexp.MustCompile(`./func already exists at s3://stackit-ap-southeast-2-607481581596/test-stack-packaged/func.zip/[a-f0-9]{32} \(v = [^)]+\)`), buf.String())
})

buf.Reset()
Expand Down
5 changes: 3 additions & 2 deletions pkg/stackit/packager/packager.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ func (p *Packager) Package(ctx context.Context, prefix string, templateReader Te
errch := make(chan error)
for artifactPath, zipPath := range artifacts {
go func(artifactPath, zipPath string) {
basename, _ := md5path(zipPath)
key := strings.TrimPrefix(fmt.Sprintf("%s/%s.zip", prefix, basename), "/")
hash, _ := md5path(zipPath)
basename := strings.TrimSuffix(filepath.Base(artifactPath), ".zip")
key := strings.TrimPrefix(fmt.Sprintf("%s/%s.zip/%s", prefix, basename, hash), "/")
up, err := p.Upload(ctx, key, zipPath)
uploads[artifactPath] = up
errch <- errors.Wrap(err, "uploading zip to s3")
Expand Down

0 comments on commit f0dfc6c

Please sign in to comment.