From 0843e956d7f6306747ec979890c6bd3229b20a7b Mon Sep 17 00:00:00 2001 From: Sotnikov Maksym Date: Wed, 10 Apr 2019 11:08:58 +0300 Subject: [PATCH] Check if S3 bucket exist --- function/function.go | 12 ++++++++++++ project/project.go | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/function/function.go b/function/function.go index 98e296b7..163ece4c 100644 --- a/function/function.go +++ b/function/function.go @@ -389,6 +389,12 @@ func (f *Function) Update(zip []byte, session *session.Session) error { //Upload to s3, and set update configuration var s3bucket string var s3key string + + if len(f.S3Bucket) < 1 { + f.Log.Errorf("Please provide S3Bucket name in function config file") + os.Exit(1) + } + if strings.Contains(f.S3Bucket, "/") { tmp := strings.Split(f.S3Bucket, "/") s3bucket = tmp[0] @@ -463,6 +469,12 @@ func (f *Function) Create(zip []byte, session *session.Session) error { //Safe zip to file, Upload to s3, and set update configuration var s3bucket string var s3key string + + if len(f.S3Bucket) < 1 { + f.Log.Errorf("Please provide S3Bucket name in function config file") + os.Exit(1) + } + if strings.Contains(f.S3Bucket, "/") { tmp := strings.Split(f.S3Bucket, "/") s3bucket = tmp[0] diff --git a/project/project.go b/project/project.go index 56ec85e7..62ef0dfb 100644 --- a/project/project.go +++ b/project/project.go @@ -14,7 +14,6 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/pkg/errors" "github.com/tj/go-sync/semaphore" - "gopkg.in/validator.v2" "apex/function" "apex/hooks"