func CloneRepositoryHandler(w http.ResponseWriter, r *http.Request) error { w.Header().Set("Content-Type", "text") instance := app.App{Name: r.URL.Query().Get(":name")} err := instance.Get() logWriter := LogWriter{&instance, w} if err != nil { return &errors.Http{Code: http.StatusNotFound, Message: fmt.Sprintf("App %s not found.", instance.Name)} } err = write(&logWriter, []byte("\n ---> Tsuru receiving push\n")) if err != nil { return err } err = write(&logWriter, []byte("\n ---> Replicating the application repository across units\n")) if err != nil { return err } out, err := repository.CloneOrPull(&instance) // should iterate over the machines if err != nil { return &errors.Http{Code: http.StatusInternalServerError, Message: string(out)} } err = write(&logWriter, out) if err != nil { return err } err = write(&logWriter, []byte("\n ---> Installing dependencies\n")) if err != nil { return err } err = instance.InstallDeps(&logWriter) if err != nil { return err } err = instance.Restart(&logWriter) if err != nil { return err } return write(&logWriter, []byte("\n ---> Deploy done!\n\n")) }