func (h *DeploymentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { opts, err := tugboat.NewDeployOptsFromReader(r.Body) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } ds, err := h.tugboat.Deploy(context.TODO(), opts) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } for _, d := range ds { fmt.Fprintf(w, "Deployment: %s\n", d.ID) } }
func deploy() error { raw, err := ioutil.ReadFile(*payload) if err != nil { return err } c := tugboat.NewClient(nil) c.URL = *url opts, err := tugboat.NewDeployOptsFromReader(bytes.NewReader(raw)) if err != nil { return err } c.Deploy(context.Background(), opts, tugboat.ProviderFunc(perform)) return nil }