diff --git a/cmd/cli/deploy.go b/cmd/cli/deploy.go index 3932193..0d90abb 100644 --- a/cmd/cli/deploy.go +++ b/cmd/cli/deploy.go @@ -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" diff --git a/pkg/deploy/deploy.go b/pkg/deploy/deploy.go index db3ef47..28353c8 100644 --- a/pkg/deploy/deploy.go +++ b/pkg/deploy/deploy.go @@ -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 { @@ -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) +}