Skip to content

Commit

Permalink
✨ Finish pulse run cmd
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Gleich <git@mattglei.ch>
  • Loading branch information
gleich committed Feb 20, 2021
1 parent cb2c41b commit 0d31193
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion pkg/commands/pulse_run.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package commands

import (
"fmt"

"github.com/rootly-io/cli/pkg/api"
"github.com/rootly-io/cli/pkg/commands/pulserun"
"github.com/rootly-io/cli/pkg/inputs"
"github.com/rootly-io/cli/pkg/log"
"github.com/spf13/cobra"
)

var pulseRunCmd = &cobra.Command{
Use: "pulse-run",
Short: "Run a command and send a pulse with the exit code",
Short: "Run a terminal command and send a pulse with the exit code",
Example: "rootly pulse-run --api-key\"ABC123\" --summary\"Deploy Website\" --label=\"Stage|#|Prod\" sh deploy.sh",
Run: func(cmd *cobra.Command, args []string) {
log.Info("Getting inputs")
Expand Down Expand Up @@ -38,6 +42,33 @@ var pulseRunCmd = &cobra.Command{

log.Success("Got inputs")

client, err := api.GenClient()
if err.Error != nil {
log.Fatal(err)
}

secProvider, err := api.GenSecurityProvider(apiKey)
if err.Error != nil {
log.Fatal(err)
}

exitCode, err := pulserun.RunProgram(prog, progArgs)
if err.Error != nil {
log.Fatal(err)
}
labels = append(
labels,
map[string]string{"key": "Exit Status", "value": fmt.Sprint(exitCode)},
)

err = api.CreatePulse(
api.Pulse{Summary: summary, Labels: labels},
client,
secProvider,
)
if err.Error != nil {
log.Fatal(err)
}
},
}

Expand Down

0 comments on commit 0d31193

Please sign in to comment.