From 4767d14b7f20d472247dd53c1092be3d4c0e8f5e Mon Sep 17 00:00:00 2001 From: razzkumar Date: Wed, 30 Oct 2019 11:28:39 +0545 Subject: [PATCH 1/3] Remove null value key from shift.json --- core/structs/structs.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/structs/structs.go b/core/structs/structs.go index 553f19b..8adcd08 100644 --- a/core/structs/structs.go +++ b/core/structs/structs.go @@ -2,23 +2,23 @@ package structs // Env defines the structure for a single environment type Env struct { - Bucket string `json:"bucket"` - Cluster string `json:"cluster"` - BuildCommand string `json:"buildCommand"` + Bucket string `json:"bucket,omitempty"` + Cluster string `json:"cluster,omitempty"` + BuildCommand string `json:"buildCommand,omitempty"` } // Project defines the overall structure for a project deployment. type Project struct { - Name string `json:"name"` - Platform string `json:"platform"` - Profile string `json:"profile"` - Region string `json:"region"` - Type string `json:"type"` - DistDir string `json:"distDir"` - SlackURL string `json:"slackURL"` - Port string `json:"port"` - DockerFilePath string `json:"dockerFilePath"` - HealthCheckPath string `json:"healthCheckPath"` + Name string `json:"name,omitempty"` + Platform string `json:"platform,omitempty"` + Profile string `json:"profile,omitempty"` + Region string `json:"region,omitempty"` + Type string `json:"type,omitempty"` + DistDir string `json:"distDir,omitempty"` + SlackURL string `json:"slackURL,omitempty"` + Port string `json:"port,omitempty"` + DockerFilePath string `json:"dockerFilePath,omitempty"` + HealthCheckPath string `json:"healthCheckPath,omitempty"` Env map[string]Env `json:"env"` } From c6206f19f040df698e6e11cff0301cdfce6fa2f1 Mon Sep 17 00:00:00 2001 From: razzkumar Date: Wed, 30 Oct 2019 17:46:40 +0545 Subject: [PATCH 2/3] Add Progress bar while deploying to s3 --- deployment/services/platforms/aws/s3/s3.go | 28 +++++++++++++--------- go.mod | 1 + go.sum | 8 +++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/deployment/services/platforms/aws/s3/s3.go b/deployment/services/platforms/aws/s3/s3.go index 1f5db5f..2a5100c 100644 --- a/deployment/services/platforms/aws/s3/s3.go +++ b/deployment/services/platforms/aws/s3/s3.go @@ -1,16 +1,18 @@ package s3 import ( + "fmt" "os" "path/filepath" + "strconv" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3/s3manager" awsService "github.com/leapfrogtechnology/shift/core/services/platforms/aws" fileUtil "github.com/leapfrogtechnology/shift/core/utils/file" - "github.com/leapfrogtechnology/shift/core/utils/logger" - "github.com/leapfrogtechnology/shift/core/utils/spinner" + + "github.com/schollz/progressbar/v2" ) // Data contains the data needed to deploy to S3 bucket @@ -43,17 +45,23 @@ func Deploy(data Data) error { return nil }) - spinner.Start("Uploading") + bar := progressbar.NewOptions(len(fileList), + progressbar.OptionEnableColorCodes(true), + progressbar.OptionSetWidth(30), + progressbar.OptionShowIts(), + progressbar.OptionSetTheme(progressbar.Theme{ + Saucer: "[green]▌▌[reset]", + SaucerPadding: "[green]░[reset]", + BarStart: "╢", + BarEnd: "╟", + })) for _, file := range fileList { f, _ := os.Open(file) - logger.Log("Uploading: " + file) - key := strings.TrimPrefix(file, data.DistDir) contentType := fileUtil.GetFileContentType(file) - // Upload the file to S3. _, err := uploader.Upload(&s3manager.UploadInput{ Bucket: aws.String(data.Bucket), Key: aws.String(key), @@ -64,13 +72,11 @@ func Deploy(data Data) error { if err != nil { return err } - - logger.Success("Success") + bar.Describe("Uploading... " + file) + bar.Add(1) } - logger.Info("🎉 🎉 🎉 Files Uploaded Successfully. 🎉 🎉 🎉") - - spinner.Stop() + fmt.Println("\n\n" + strconv.Itoa(len(fileList)) + " Files Uploaded Successfully. 🎉 🎉 🎉") return nil } diff --git a/go.mod b/go.mod index 59294bd..198aaec 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 github.com/go-resty/resty/v2 v2.0.0 github.com/logrusorgru/aurora v0.0.0-20190803045625-94edacc10f9b + github.com/schollz/progressbar/v2 v2.14.0 github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 github.com/urfave/cli v1.22.1 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect diff --git a/go.sum b/go.sum index e5bd64d..ebf6dd4 100644 --- a/go.sum +++ b/go.sum @@ -9,6 +9,7 @@ github.com/briandowns/spinner v1.6.1 h1:LBxHu5WLyVuVEtTD72xegiC7QJGx598LBpo3ywKT github.com/briandowns/spinner v1.6.1/go.mod h1://Zf9tMcxfRUA36V23M6YGEAv+kECGfvpnLTnb8n4XQ= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= @@ -48,15 +49,22 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/schollz/progressbar v1.0.0 h1:gbyFReLHDkZo8mxy/dLWMr+Mpb1MokGJ1FqCiqacjZM= +github.com/schollz/progressbar/v2 v2.14.0 h1:vo7bdkI9E4/CIk9DnL5uVIaybLQiVtiCC2vO+u9j5IM= +github.com/schollz/progressbar/v2 v2.14.0/go.mod h1:6YZjqdthH6SCZKv2rqGryrxPtfmRB/DWZxSMfCXPyD8= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= From 855edda4735080b97d2781b11f7272c8116c2746 Mon Sep 17 00:00:00 2001 From: razzkumar Date: Thu, 31 Oct 2019 11:33:38 +0545 Subject: [PATCH 3/3] Fixes s3-bucket-name invalid error --- infrastructure/internals/terraform/terraform.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/internals/terraform/terraform.go b/infrastructure/internals/terraform/terraform.go index 5b5a01a..72d0015 100644 --- a/infrastructure/internals/terraform/terraform.go +++ b/infrastructure/internals/terraform/terraform.go @@ -65,8 +65,8 @@ func getTerraformOutput(workspaceDir string) (string, error) { cmd.Dir = workspaceDir var stdout bytes.Buffer var stderr bytes.Buffer - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr + cmd.Stdout = &stdout + cmd.Stderr = &stderr err := cmd.Run() if err != nil {