From 03a026184235132e7a661d21660314ee7fe74f8a Mon Sep 17 00:00:00 2001
From: Jan Hajek <hajek.mail@gmail.com>
Date: Fri, 5 Jun 2020 16:26:10 +0200
Subject: [PATCH] #xxxxx

---
 cmd/deploy.go                     |  9 ++++-----
 src/command/deploy/handler.go     |  6 +++---
 src/command/deploy/handler_run.go | 11 +++++++++--
 src/command/login/handler.go      |  4 ++--
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/cmd/deploy.go b/cmd/deploy.go
index 313c66ce..95d2f519 100644
--- a/cmd/deploy.go
+++ b/cmd/deploy.go
@@ -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],
 			})
 		},
 	}
diff --git a/src/command/deploy/handler.go b/src/command/deploy/handler.go
index 5d6bef08..08b56907 100644
--- a/src/command/deploy/handler.go
+++ b/src/command/deploy/handler.go
@@ -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 {
diff --git a/src/command/deploy/handler_run.go b/src/command/deploy/handler_run.go
index 50612a2e..2225c4c7 100644
--- a/src/command/deploy/handler_run.go
+++ b/src/command/deploy/handler_run.go
@@ -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"
@@ -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
 	}
diff --git a/src/command/login/handler.go b/src/command/login/handler.go
index b1dcf611..0bb3a4cd 100644
--- a/src/command/login/handler.go
+++ b/src/command/login/handler.go
@@ -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
@@ -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)
 	}