Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/gpctl/cmd/imagebuilds-list.go
2498 views
1
// Copyright (c) 2020 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"context"
9
"io"
10
11
"github.com/spf13/cobra"
12
13
"github.com/gitpod-io/gitpod/common-go/log"
14
builder "github.com/gitpod-io/gitpod/image-builder/api"
15
)
16
17
// clientLogsCmd represents the clientLogs command
18
var imagebuildsListCmd = &cobra.Command{
19
Use: "list",
20
Short: "Lists all ongoing builds",
21
Run: func(cmd *cobra.Command, args []string) {
22
ctx, cancel := context.WithCancel(context.Background())
23
defer cancel()
24
25
conn, client, err := getImagebuildsClient(ctx)
26
if err != nil {
27
log.WithError(err).Fatal("cannot connect")
28
}
29
defer conn.Close()
30
log.Info("connected")
31
32
// build did start, print log until done
33
resp, err := client.ListBuilds(ctx, &builder.ListBuildsRequest{})
34
if err != nil && err != io.EOF {
35
log.Fatal(err)
36
}
37
38
tpl := `REF STATUS STARTED AT
39
{{- range .Builds }}
40
{{ .Ref }} {{ .Status }} {{ .StartedAt }}
41
{{ end }}
42
`
43
getOutputFormat(tpl, "{..ref}").Print(resp)
44
},
45
}
46
47
func init() {
48
imagebuildsCmd.AddCommand(imagebuildsListCmd)
49
}
50
51