Skip to content

Commit

Permalink
replace from_published by from
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrildiagne committed Jan 14, 2020
1 parent a6f3575 commit 6449f78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/cli/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func deployFromPublished(published string) error {
fmt.Println("Deploying from published API image", published)

params := url.Values{}
params.Set("from_published", published)
params.Set("from", published)
body := strings.NewReader(params.Encode())

url := cfg.Provider.ApiURL + "/deploy"
Expand Down
27 changes: 16 additions & 11 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,13 @@ func deployFromPublished(fromPublished string, env *api.Env, w http.ResponseWrit
return nil
}

// HandleDeploy handles deployments from tar archived in body & published images.
func HandleDeploy(env *api.Env, w http.ResponseWriter, r *http.Request) error {
// Set maximum upload size to 2GB.
r.ParseMultipartForm((2 * 1000) << 20)

func deployFromFiles(env *api.Env, w http.ResponseWriter, r *http.Request) error {
// Retrieve namespace.
namespace, err := api.GetAuthorizedNamespace(env, r)
if err != nil {
return err
}

// Check if deploying from published
fromPublished := r.FormValue("from_published")
if fromPublished != "" {
return deployFromPublished(fromPublished, env, w, r)
}

// Extract archive to temp folder.
contextDir, err := extractContext(namespace, r)
if err != nil {
Expand Down Expand Up @@ -131,3 +121,18 @@ func HandleDeploy(env *api.Env, w http.ResponseWriter, r *http.Request) error {
fmt.Fprintf(w, "Deployment successful!\n")
return nil
}

// HandleDeploy handles deployments from tar archived in body & published images.
func HandleDeploy(env *api.Env, w http.ResponseWriter, r *http.Request) error {
// Set maximum upload size to 2GB.
r.ParseMultipartForm((2 * 1000) << 20)

fmt.Println("handle deploy")

// Check if deploying from published
from := r.FormValue("from")
if from != "" {
return deployFromPublished(from, env, w, r)
}
return deployFromFiles(env, w, r)
}

0 comments on commit 6449f78

Please sign in to comment.