Skip to content

Commit

Permalink
Merge branch 'dev' into feat/delete_bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelbm committed May 16, 2024
2 parents 1dd6a99 + b32c85c commit c5556ed
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @aziontech/integrations
* @aziontech/dev-tools-integrations
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ require (
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.21.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
14 changes: 9 additions & 5 deletions pkg/cmd/deploy/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import (
"go.uber.org/zap"
)

var PathStatic = ".edge/storage"
var (
PathStatic = ".edge/storage"
Jobs chan contracts.FileOps
Retries int64
)

func (cmd *DeployCmd) uploadFiles(f *cmdutil.Factory, conf *contracts.AzionApplicationOptions) error {
// Get total amount of files to display progress
Expand All @@ -40,12 +44,12 @@ func (cmd *DeployCmd) uploadFiles(f *cmdutil.Factory, conf *contracts.AzionAppli

noOfWorkers := 5
var currentFile int64
jobs := make(chan contracts.FileOps, totalFiles)
Jobs := make(chan contracts.FileOps, totalFiles)
results := make(chan error, noOfWorkers)

// Create worker goroutines
for i := 1; i <= noOfWorkers; i++ {
go worker(jobs, results, &currentFile, clientUpload, conf)
go worker(Jobs, results, &currentFile, clientUpload, conf)
}

bar := progressbar.NewOptions(
Expand Down Expand Up @@ -84,14 +88,14 @@ func (cmd *DeployCmd) uploadFiles(f *cmdutil.Factory, conf *contracts.AzionAppli
FileContent: fileContent,
}

jobs <- fileOptions
Jobs <- fileOptions
}
return nil
}); err != nil {
logger.Debug("Error while reading files to be uploaded", zap.Error(err))
return err
}
close(jobs)
close(Jobs)

// Check for errors from workers
for a := 1; a <= totalFiles; a++ {
Expand Down
10 changes: 9 additions & 1 deletion pkg/cmd/deploy/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

// worker reads the range of jobs and uploads the file, if there is an error during upload, we returning it through the results channel
func worker(jobs <-chan contracts.FileOps, results chan<- error, currentFile *int64, clientUpload *storage.Client, conf *contracts.AzionApplicationOptions) {

for job := range jobs {
// Once ENG-27343 is completed, we might be able to remove this piece of code
fileInfo, err := job.FileContent.Stat()
Expand All @@ -32,9 +31,18 @@ func worker(jobs <-chan contracts.FileOps, results chan<- error, currentFile *in

if err := clientUpload.Upload(context.Background(), &job, conf); err != nil {
logger.Debug("Error while worker tried to upload file: <"+job.Path+"> to storage api", zap.Error(err))
if Retries < 5 {
logger.Debug("Retrying to upload the following file: <"+job.Path+"> to storage api", zap.Error(err))
atomic.AddInt64(&Retries, 1)
Jobs <- job
results <- nil
return
}
logger.Debug("There have been 5 retries already, quitting upload")
results <- err
return
}

atomic.AddInt64(currentFile, 1)
results <- nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/output/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"reflect"

"github.com/aziontech/azion-cli/pkg/logger"
"github.com/fatih/color"
"github.com/aziontech/tablecli"
"github.com/fatih/color"
)

type DescribeOutput struct {
Expand Down Expand Up @@ -69,13 +69,13 @@ func (c *DescribeOutput) Output() {

func checkPrimitiveType(value any) any {
valueType := reflect.TypeOf(value)
if valueType.Kind() == reflect.Int || valueType.Kind() == reflect.String ||
if valueType != nil && (valueType.Kind() == reflect.Int || valueType.Kind() == reflect.String ||
valueType.Kind() == reflect.Bool || valueType.Kind() == reflect.Float32 ||
valueType.Kind() == reflect.Float64 || valueType.Kind() == reflect.Uint ||
valueType.Kind() == reflect.Uint8 || valueType.Kind() == reflect.Uint16 ||
valueType.Kind() == reflect.Uint32 || valueType.Kind() == reflect.Uint64 ||
valueType.Kind() == reflect.Int8 || valueType.Kind() == reflect.Int16 ||
valueType.Kind() == reflect.Int32 || valueType.Kind() == reflect.Int64 {
valueType.Kind() == reflect.Int32 || valueType.Kind() == reflect.Int64) {
return value
}
jsonValue, _ := json.Marshal(value)
Expand Down

0 comments on commit c5556ed

Please sign in to comment.