Skip to content

Commit

Permalink
#xxxxx
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-hajek committed Jun 5, 2020
1 parent 5221149 commit 03a0261
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
9 changes: 4 additions & 5 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ func deployCmd() *cobra.Command {
zipClient := zipClient.New(zipClient.Config{})

return deploy.New(
deploy.Config{
SourceDirectoryPath: params.GetString("sourceDirectory"),
},
deploy.Config{},
httpClient,
zipClient,
logger,
apiGrpcClient,
).Run(ctx, deploy.RunConfig{
ProjectName: args[0],
ServiceStackName: args[1],
SourceDirectoryPath: params.GetString("sourceDirectory"),
ProjectName: args[0],
ServiceStackName: args[1],
})
},
}
Expand Down
6 changes: 3 additions & 3 deletions src/command/deploy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
)

type Config struct {
SourceDirectoryPath string
}

type RunConfig struct {
ProjectName string
ServiceStackName string
ProjectName string
ServiceStackName string
SourceDirectoryPath string
}

type Handler struct {
Expand Down
11 changes: 9 additions & 2 deletions src/command/deploy/handler_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"net/http"
"path/filepath"

"github.com/zerops-io/zcli/src/helpers"
"github.com/zerops-io/zcli/src/service/httpClient"
Expand Down Expand Up @@ -66,9 +67,15 @@ func (h *Handler) Run(ctx context.Context, config RunConfig) error {
}
appVersion := appVersionResponse.GetOutput()

data := &bytes.Buffer{}
sourceDirectoryPath, err := filepath.Abs(config.SourceDirectoryPath)
if err != nil {
return err
}

h.logger.Info("packing directory: ", sourceDirectoryPath)

err = h.zipClient.Zip(h.config.SourceDirectoryPath, data)
data := &bytes.Buffer{}
err = h.zipClient.Zip(sourceDirectoryPath, data)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions src/command/login/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (h *Handler) Run(_ context.Context, runConfig RunConfig) error {
}
}

if loginResponse.StatusCode < http.StatusMultipleChoices {
if loginResponse.StatusCode < http.StatusBadRequest {
err := json.Unmarshal(loginResponse.Body, &loginResponseObject)
if err != nil {
return err
Expand Down Expand Up @@ -110,7 +110,7 @@ func (h *Handler) Run(_ context.Context, runConfig RunConfig) error {
return err
}

if cliResponse.StatusCode >= http.StatusMultipleChoices {
if cliResponse.StatusCode >= http.StatusBadRequest {
return parseRestApiError(cliResponse.Body)
}

Expand Down

0 comments on commit 03a0261

Please sign in to comment.