// NotifyTugboat wraps a Deployer to sent deployment logs and status updates to // a Tugboat instance. func NotifyTugboat(d Deployer, url string) *TugboatDeployer { c := tugboat.NewClient(nil) c.URL = url return &TugboatDeployer{ deployer: d, client: c, } }
func newTugboatDeployer(d deployer, url string) *tugboatDeployer { c := tugboat.NewClient(nil) c.URL = url return &tugboatDeployer{ deployer: d, client: c, } }
// newTestClient will return a new heroku.Client that's configured to interact // with a instance of the empire HTTP server. func newTestClient(t testing.TB) (*tugboat.Client, *tugboat.Tugboat, *httptest.Server) { tug := tugboattest.New(t) s := httptest.NewServer(tugboattest.NewServer(tug)) c := tugboat.NewClient(nil) u, err := url.Parse(s.URL) if err != nil { t.Fatal(err) } u.User = url.User("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJQcm92aWRlciI6Imhlcm9rdSJ9.HVBoIvRnGKR87odScLnkFWHi4pvSI8V7LJpjh00njBY") c.URL = u.String() return c, tug, s }
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 }
func Example() { // First, you'll want to create a tugboat.Client and point it at a // tugboat server. c := tugboat.NewClient(nil) // Options should be parsed from the github webhook. opts := tugboat.DeployOpts{ ID: 1, Sha: "827fecd2d36ebeaa2fd05aa8ef3eed1e56a8cd57", Ref: "master", Environment: "staging", Description: "Deploying to staging", Repo: "remind101/acme-inc", } // Calling Deploy will perform the deployment and record the // logs. if _, err := c.Deploy(context.TODO(), opts, tugboat.ProviderFunc(deploy)); err != nil { log.Fatal(err) } }