-
Notifications
You must be signed in to change notification settings - Fork 332
/
cat_hook_output.go
35 lines (30 loc) · 992 Bytes
/
cat_hook_output.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package cmd
import (
"fmt"
"net/http"
"github.com/spf13/cobra"
)
const catHookOutputRequiredArgs = 3
var catHookOutputCmd = &cobra.Command{
Use: "cat-hook-output <repository URI> <run_id> <hook_id>",
Short: "Cat actions hook output",
Hidden: true,
Example: "lakectl cat-hook-output " + myRepoExample + " " + myRunIDExample + " my_hook_name",
Args: cobra.ExactArgs(catHookOutputRequiredArgs),
ValidArgsFunction: ValidArgsRepository,
Run: func(cmd *cobra.Command, args []string) {
u := MustParseRepoURI("repository URI", args[0])
fmt.Println("Repository:", u)
runID := args[1]
hookRunID := args[2]
client := getClient()
ctx := cmd.Context()
resp, err := client.GetRunHookOutputWithResponse(ctx, u.Repository, runID, hookRunID)
DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK)
fmt.Println(string(resp.Body))
},
}
//nolint:gochecknoinits
func init() {
rootCmd.AddCommand(catHookOutputCmd)
}