diff --git a/cft/pkg/pkg_test.go b/cft/pkg/pkg_test.go index 97ea6736..e1dcf28b 100644 --- a/cft/pkg/pkg_test.go +++ b/cft/pkg/pkg_test.go @@ -1,4 +1,4 @@ -//+build func_test +//go:build func_test package pkg_test @@ -211,8 +211,8 @@ func TestWrappedTypes(t *testing.T) { propName string expected interface{} }{ - {"AWS::Serverless::Function", "CodeURI", s3ZipURI}, - {"AWS::Serverless::Api", "DefinitionURI", s3URI}, + {"AWS::Serverless::Function", "CodeUri", s3ZipURI}, + {"AWS::Serverless::Api", "DefinitionUri", s3URI}, {"AWS::AppSync::GraphQLSchema", "DefinitionS3Location", s3URI}, {"AWS::AppSync::Resolver", "RequestMappingTemplateS3Location", s3URI}, {"AWS::AppSync::Resolver", "ResponseMappingTemplateS3Location", s3URI}, @@ -221,7 +221,7 @@ func TestWrappedTypes(t *testing.T) { {"AWS::ServerlessRepo::Application", "ReadmeUrl", s3URI}, {"AWS::ServerlessRepo::Application", "LicenseUrl", s3URI}, {"AWS::Glue::Job", "Command/ScriptLocation", s3URI}, - {"AWS::Serverless::LayerVersion", "ContentURI", s3ZipURI}, + {"AWS::Serverless::LayerVersion", "ContentUri", s3ZipURI}, {"AWS::Serverless::Application", "Location", httpURI}, {"AWS::Lambda::Function", "Code", map[string]interface{}{"S3Bucket": bucket, "S3Key": zipHash}}, {"AWS::ElasticBeanstalk::ApplicationVersion", "SourceBundle", map[string]interface{}{"S3Bucket": bucket, "S3Key": hash}}, diff --git a/cft/pkg/util.go b/cft/pkg/util.go index b9a5bff2..f36ef8bc 100644 --- a/cft/pkg/util.go +++ b/cft/pkg/util.go @@ -117,27 +117,33 @@ func upload(root, path string, force bool) (*s3Path, error) { } } - if result, ok := uploads[path]; ok { + artifactName := path + if force { + artifactName = "zip:" + artifactName + } + + if result, ok := uploads[artifactName]; ok { config.Debugf("Using existing upload for: %s\n", path) return result, nil } - config.Debugf("Uploading: %s\n", path) - info, err := os.Stat(path) if err != nil { return nil, err } - origPath := path if info.IsDir() || force { // Zip it! - path, err = zipPath(path) + zipped, err := zipPath(path) if err != nil { return nil, err } + config.Debugf("Zipped %s as %s\n", path, zipped) + path = zipped } + config.Debugf("Uploading: %s\n", path) + content, err := ioutil.ReadFile(path) if err != nil { return nil, err @@ -146,13 +152,13 @@ func upload(root, path string, force bool) (*s3Path, error) { bucket := s3.RainBucket(false) key, err := s3.Upload(bucket, content) - uploads[origPath] = &s3Path{ + uploads[artifactName] = &s3Path{ bucket: bucket, key: key, region: aws.Config().Region, } - return uploads[origPath], err + return uploads[artifactName], err } func expectString(n *yaml.Node) (string, error) { diff --git a/cft/spec/internal/main.go b/cft/spec/internal/main.go index d301fa55..61132661 100644 --- a/cft/spec/internal/main.go +++ b/cft/spec/internal/main.go @@ -1,4 +1,4 @@ -// +build ignore +//go:build ignore package main diff --git a/internal/aws/aws.go b/internal/aws/aws.go index 2d41947f..d28f85f3 100644 --- a/internal/aws/aws.go +++ b/internal/aws/aws.go @@ -1,4 +1,4 @@ -//+build !func_test +//go:build !func_test // Package aws contains functionality that wraps the AWS SDK package aws diff --git a/internal/aws/cfn/cfn.go b/internal/aws/cfn/cfn.go index ba648b7c..d6f77a4f 100644 --- a/internal/aws/cfn/cfn.go +++ b/internal/aws/cfn/cfn.go @@ -1,4 +1,4 @@ -//+build !func_test +//go:build !func_test package cfn diff --git a/internal/aws/cfn/mock.go b/internal/aws/cfn/mock.go index 557b1040..e475350d 100644 --- a/internal/aws/cfn/mock.go +++ b/internal/aws/cfn/mock.go @@ -1,4 +1,4 @@ -//+build func_test +//go:build func_test package cfn diff --git a/internal/aws/ec2/ec2.go b/internal/aws/ec2/ec2.go index efc0ea4a..042db717 100644 --- a/internal/aws/ec2/ec2.go +++ b/internal/aws/ec2/ec2.go @@ -1,4 +1,4 @@ -//+build !func_test +//go:build !func_test package ec2 diff --git a/internal/aws/ec2/mock.go b/internal/aws/ec2/mock.go index bbc26dfe..1815d946 100644 --- a/internal/aws/ec2/mock.go +++ b/internal/aws/ec2/mock.go @@ -1,4 +1,4 @@ -//+build func_test +//go:build func_test package ec2 diff --git a/internal/aws/mock.go b/internal/aws/mock.go index e8077e52..c5b11186 100644 --- a/internal/aws/mock.go +++ b/internal/aws/mock.go @@ -1,4 +1,4 @@ -//+build func_test +//go:build func_test // Package aws contains functionality that wraps the AWS SDK package aws diff --git a/internal/aws/s3/mock.go b/internal/aws/s3/mock.go index 1a9109ad..8e8f0128 100644 --- a/internal/aws/s3/mock.go +++ b/internal/aws/s3/mock.go @@ -1,4 +1,4 @@ -//+build func_test +//go:build func_test package s3 diff --git a/internal/aws/s3/s3.go b/internal/aws/s3/s3.go index aafccd94..5521d5af 100644 --- a/internal/aws/s3/s3.go +++ b/internal/aws/s3/s3.go @@ -1,4 +1,4 @@ -//+build !func_test +//go:build !func_test package s3 diff --git a/internal/console/console_windows.go b/internal/console/console_windows.go index 26e5a691..a41e9633 100644 --- a/internal/console/console_windows.go +++ b/internal/console/console_windows.go @@ -1,4 +1,4 @@ -// +build windows +//go:build windows // Package console contains utility functions for working with text consoles package console diff --git a/test/func_test.go b/test/func_test.go index 3b374b8f..0109702b 100644 --- a/test/func_test.go +++ b/test/func_test.go @@ -1,4 +1,4 @@ -//+build func_test +//go:build func_test package test