Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcbmgr: add list build jobs #1194

Merged
merged 1 commit into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions cmd/krel/cmd/gcbmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type gcbmgrOptions struct {
releaseType string
buildVersion string
gcpUser string
lastJobs int64
}

var (
Expand Down Expand Up @@ -140,6 +141,13 @@ func init() {
"If provided, this will be used as the GCP_USER_TAG.",
)

gcbmgrCmd.PersistentFlags().Int64Var(
&gcbmgrOpts.lastJobs,
"list-jobs",
5,
"List the last x build jobs in the project. Default to 5.",
)

rootCmd.AddCommand(gcbmgrCmd)
}

Expand Down Expand Up @@ -241,7 +249,7 @@ func runGcbmgr() error {
jobType = "release"
buildOpts.DiskSize = "100"
default:
return listJobs()
return listJobs(buildOpts.Project, gcbmgrOpts.lastJobs)
}

buildOpts.ConfigDir = filepath.Join(toolRoot, "gcb", jobType)
Expand Down Expand Up @@ -362,11 +370,11 @@ func setGCBSubstitutions(o *gcbmgrOptions) (map[string]string, error) {
return gcbSubs, nil
}

var buildListJobs = build.ListJobs

// listJobs lists recent GCB jobs run in the specified project
func listJobs() error {
logrus.Info("Listing GCB jobs is not currently supported.")
func listJobs(project string, lastJobs int64) error {
logrus.Infof("Listing last %d GCB jobs:", lastJobs)

// TODO: Add job listing logic
// logrus.Info("Listing recent GCB jobs...")
return nil
return buildListJobs(project, lastJobs)
}
60 changes: 48 additions & 12 deletions cmd/krel/cmd/gcbmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cmd

import (
"errors"
"fmt"
"os"
"testing"
Expand All @@ -26,27 +27,54 @@ import (
"k8s.io/release/pkg/gcp/build"
)

func TestRunGcbmgrSuccess(t *testing.T) {
type fakeListJobs struct {
expectedProject string
expectedLastJobs int64
t *testing.T
err error
}

func (f *fakeListJobs) ListJobs(project string, lastJobs int64) error {
require.Equal(f.t, project, f.expectedProject)
require.Equal(f.t, lastJobs, f.expectedLastJobs)
return f.err
}

func TestRunGcbmgrList(t *testing.T) {
testcases := []struct {
name string
gcbmgrOpts gcbmgrOptions
buildOpts build.Options
expected map[string]string
name string
gcbmgrOpts gcbmgrOptions
buildOpts build.Options
listJobOpts fakeListJobs
expectedErr bool
}{
{
name: "list only",
gcbmgrOpts: gcbmgrOptions{
branch: "master",
gcpUser: "test-user",
branch: "master",
gcpUser: "test-user",
lastJobs: 5,
},
listJobOpts: fakeListJobs{
expectedProject: "kubernetes-release-test",
expectedLastJobs: int64(5),
err: nil,
},
expectedErr: false,
},
{
name: "stream the job",
name: "error on list jobs",
gcbmgrOpts: gcbmgrOptions{
branch: "master",
stream: true,
gcpUser: "test-user",
branch: "master",
gcpUser: "test-user",
lastJobs: 10,
},
listJobOpts: fakeListJobs{
expectedProject: "kubernetes-release-test",
expectedLastJobs: int64(10),
err: errors.New("Generic Error"),
},
expectedErr: true,
},
}

Expand All @@ -55,8 +83,16 @@ func TestRunGcbmgrSuccess(t *testing.T) {

gcbmgrOpts = &tc.gcbmgrOpts

f := &tc.listJobOpts
f.t = t
buildListJobs = f.ListJobs

err := runGcbmgr()
require.Nil(t, err)
if tc.expectedErr {
require.NotNil(t, err)
} else {
require.Nil(t, err)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/kylelemons/godebug v1.1.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2
github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481
github.com/olekukonko/tablewriter v0.0.4
github.com/pkg/errors v0.9.1
github.com/psampaz/go-mod-outdated v0.5.0
github.com/sendgrid/rest v2.4.1+incompatible
Expand All @@ -21,7 +22,9 @@ require (
github.com/spf13/cobra v0.0.6
github.com/stretchr/testify v1.5.1
github.com/yuin/goldmark v1.1.25
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
google.golang.org/api v0.20.0
gopkg.in/src-d/go-git.v4 v4.13.1
k8s.io/utils v0.0.0-20200229041039-0a110f9eb7ab
sigs.k8s.io/yaml v1.2.0
Expand Down
16 changes: 15 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bombsimon/wsl/v2 v2.0.0 h1:+Vjcn+/T5lSrO8Bjzhk4v14Un/2UyCA1E3V5j9nwTkQ=
github.com/bombsimon/wsl/v2 v2.0.0/go.mod h1:mf25kr/SqFEPhhcxW1+7pxzGlW+hIl/hYTKY95VwV8U=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand All @@ -53,6 +54,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
Expand Down Expand Up @@ -242,6 +245,8 @@ github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand All @@ -261,6 +266,8 @@ github.com/nozzle/throttler v0.0.0-20180817012639-2ea982251481/go.mod h1:yKZQO8Q
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
Expand All @@ -283,6 +290,7 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
Expand Down Expand Up @@ -440,8 +448,9 @@ golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smto
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
Expand Down Expand Up @@ -521,6 +530,8 @@ google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.9.0 h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8=
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.20.0 h1:jz2KixHX7EcCPiQrySzPdnYT7DbINAypCqKZ1Z7GM40=
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand All @@ -542,8 +553,11 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.23.1 h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk=
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
Expand Down
4 changes: 4 additions & 0 deletions pkg/gcp/build/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ go_library(
"//pkg/command:go_default_library",
"//pkg/git:go_default_library",
"@com_github_google_uuid//:go_default_library",
"@com_github_olekukonko_tablewriter//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@io_k8s_sigs_yaml//:go_default_library",
"@org_golang_google_api//cloudbuild/v1:go_default_library",
"@org_golang_google_api//option:go_default_library",
"@org_golang_x_net//context:go_default_library",
],
)

Expand Down
29 changes: 29 additions & 0 deletions pkg/gcp/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ import (
"sync"

"github.com/google/uuid"
"github.com/olekukonko/tablewriter"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/api/cloudbuild/v1"
"google.golang.org/api/option"

"k8s.io/release/pkg/command"
"k8s.io/release/pkg/git"
Expand Down Expand Up @@ -348,3 +352,28 @@ func mergeMaps(maps ...map[string]string) map[string]string {
}
return out
}

func ListJobs(project string, lastJobs int64) error {
ctx := context.Background()
opts := option.WithCredentialsFile("")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow up I suggest to wrap this in a new struct like we do in the guthub package. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will review the github package and apply the same in a follow up.
thanks!


service, err := cloudbuild.NewService(ctx, opts)
if err != nil {
return errors.Wrap(err, "failed to fetching gcloud credentials... try running \"gcloud auth application-default login\"")
}

req, err := service.Projects.Builds.List(project).PageSize(lastJobs).Do()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a maximum value for the page size? If yes, what do we do if we’re requesting more jobs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried to find in the docs but it does not say anything
https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds/list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, do page sizes > 100 work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did with 301 and returned all 301 last jobs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, thanks for verifying.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried with 500 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is not useful but a user can do weird things 😂

Copy link
Member

@saschagrunert saschagrunert Mar 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on -1? 😁

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it brings the jobs in the future :P

but looks like it not fail

INFO Listing last -1 GCB jobs:
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+
|           START TIME           |          FINISH TIME           |  STATUS   |                                                 CONSOLE LOGS                                                  |
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+
| 2020-03-17T18:01:39.454011569Z | 2020-03-17T18:18:42.306307Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/66caa764-d21b-465d-95d6-d8b754ed945b?project=648026197307 |
| 2020-03-17T17:05:46.596215978Z | 2020-03-17T17:58:40.563946Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/22413ad5-0e74-4118-98a8-c6a6b776f2e5?project=648026197307 |
| 2020-03-17T16:44:14.493028495Z | 2020-03-17T17:01:08.357092Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/313eaeba-386b-4744-ac5e-de2da0c0ec3a?project=648026197307 |
| 2020-03-17T15:47:22.036533888Z | 2020-03-17T16:39:33.880910Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/f7fb4817-0d2e-40ae-9fed-ec2f4ba90bb6?project=648026197307 |
| 2020-03-17T15:46:59.446635185Z | 2020-03-17T15:48:00.752557291Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/9283b1b4-e23c-4160-89d1-c9ca7e7cd326?project=648026197307 |
| 2020-03-17T15:41:08.534867366Z | 2020-03-17T15:48:10.707409281Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/afba1c94-a3b1-4a9f-a025-79549f5bf5f4?project=648026197307 |
| 2020-03-12T23:13:39.983798382Z | 2020-03-12T23:42:05.867161Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/66715bd8-93a2-4000-86e9-ab734b72766a?project=648026197307 |
| 2020-03-12T22:47:12.056531535Z | 2020-03-12T22:47:23.343306181Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/88acc767-adfe-4ea4-8646-0287b05d5410?project=648026197307 |
| 2020-03-12T22:47:18.045150178Z | 2020-03-12T23:16:03.417070Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/c0cdf52a-d386-4de8-8eaa-c6c31fe86960?project=648026197307 |
| 2020-03-12T22:46:46.270468739Z | 2020-03-12T23:17:50.062883Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/0c33f75a-fe5d-4800-8c93-4864545fc96b?project=648026197307 |
| 2020-03-12T20:56:59.329664144Z | 2020-03-12T23:09:49.748778Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/56dcfb8d-4997-4d80-a26b-d98dcb16354e?project=648026197307 |
| 2020-03-12T20:52:03.334708890Z | 2020-03-12T22:40:16.286748Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/bd24d66d-671f-480f-b940-7dd8e4b195b2?project=648026197307 |
| 2020-03-12T20:49:17.189666168Z | 2020-03-12T22:42:03.250553Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/730e2680-1117-4ceb-b7ee-244ddfc73143?project=648026197307 |
| 2020-03-12T20:25:45.541744471Z | 2020-03-12T20:55:39.045461Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/f4553143-76cf-4302-8f8a-eb378d707755?project=648026197307 |
| 2020-03-12T20:19:33.605482117Z | 2020-03-12T20:46:59.117637Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/3cb43a19-5f65-4540-8eb4-ab6a2b44d1ba?project=648026197307 |
| 2020-03-12T20:18:26.464990013Z | 2020-03-12T20:48:07.174950Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/06b6dbbc-8041-47b1-8e21-38d9a62c917a?project=648026197307 |
| 2020-03-12T18:26:12.101181631Z | 2020-03-12T20:11:08.424601Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/53df157a-1a29-45ae-9ef6-2616cf89d0f4?project=648026197307 |
| 2020-03-12T18:25:17.403597155Z | 2020-03-12T18:25:29.064243395Z | CANCELLED | https://console.cloud.google.com/cloud-build/builds/16b647fc-6609-4a3c-a108-615be37b3477?project=648026197307 |
| 2020-03-12T18:21:02.673580173Z | 2020-03-12T20:24:24.667413Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/2a8c78a4-edd6-4769-8d7e-edb6c5b4062b?project=648026197307 |
| 2020-03-12T18:20:59.567154612Z | 2020-03-12T20:16:06.787010Z    | SUCCESS   | https://console.cloud.google.com/cloud-build/builds/27e6b98a-c59c-41e6-8f93-b0089a88c95e?project=648026197307 |
+--------------------------------+--------------------------------+-----------+---------------------------------------------------------------------------------------------------------------+

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: Normalize (set to default count) any non-positive number. Also, log that we're going to do that

if err != nil {
return errors.Wrap(err, "failed to listing the builds")
}

table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Start Time", "Finish Time", "Status", "Console Logs"})

for _, build := range req.Builds {
table.Append([]string{strings.TrimSpace(build.StartTime), strings.TrimSpace(build.FinishTime), strings.TrimSpace(build.Status), strings.TrimSpace(build.LogUrl)})
}
table.Render()

return nil
}
48 changes: 36 additions & 12 deletions repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def go_repositories():
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "golang.org/x/net",
sum = "h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=",
version = "v0.0.0-20191004110552-13f9640d40b9",
sum = "h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=",
version = "v0.0.0-20200301022130-244492dfa37a",
)

go_repository(
Expand Down Expand Up @@ -460,8 +460,8 @@ def go_repositories():
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "github.com/mattn/go-runewidth",
sum = "h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=",
version = "v0.0.4",
sum = "h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=",
version = "v0.0.7",
)

go_repository(
Expand All @@ -487,8 +487,8 @@ def go_repositories():
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "github.com/olekukonko/tablewriter",
sum = "h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=",
version = "v0.0.1",
sum = "h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=",
version = "v0.0.4",
)
go_repository(
name = "com_github_onsi_ginkgo",
Expand Down Expand Up @@ -767,8 +767,8 @@ def go_repositories():
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "google.golang.org/api",
sum = "h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8=",
version = "v0.9.0",
sum = "h1:jz2KixHX7EcCPiQrySzPdnYT7DbINAypCqKZ1Z7GM40=",
version = "v0.20.0",
)
go_repository(
name = "org_golang_google_genproto",
Expand All @@ -783,8 +783,8 @@ def go_repositories():
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "google.golang.org/grpc",
sum = "h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk=",
version = "v1.23.1",
sum = "h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg=",
version = "v1.27.0",
)
go_repository(
name = "org_golang_x_crypto",
Expand Down Expand Up @@ -1619,8 +1619,8 @@ def go_repositories():
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "github.com/prometheus/client_model",
sum = "h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE=",
version = "v0.0.0-20190129233127-fd36f4220a90",
sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=",
version = "v0.0.0-20190812154241-14fe0d1b01d4",
)
go_repository(
name = "com_github_prometheus_common",
Expand Down Expand Up @@ -2024,3 +2024,27 @@ def go_repositories():
sum = "h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=",
version = "v1.0.0",
)
go_repository(
name = "com_github_census_instrumentation_opencensus_proto",
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "github.com/census-instrumentation/opencensus-proto",
sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=",
version = "v0.2.1",
)
go_repository(
name = "com_github_envoyproxy_go_control_plane",
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "github.com/envoyproxy/go-control-plane",
sum = "h1:4cmBvAEBNJaGARUEs3/suWRyfyBfhf7I60WBZq+bv2w=",
version = "v0.9.1-0.20191026205805-5f8ba28d4473",
)
go_repository(
name = "com_github_envoyproxy_protoc_gen_validate",
build_file_generation = "on",
build_file_proto_mode = "disable",
importpath = "github.com/envoyproxy/protoc-gen-validate",
sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=",
version = "v0.1.0",
)