Skip to content

Commit

Permalink
Allow mkpod to autogenerate buildID when 'snowflake' is specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjwagner committed Jul 23, 2019
1 parent eb0997a commit 53b6b0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions prow/cmd/mkpod/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//prow/apis/prowjobs/v1:go_default_library",
"//prow/pjutil:go_default_library",
"//prow/pod-utils/decorate:go_default_library",
"//vendor/github.com/sirupsen/logrus:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
Expand Down
10 changes: 9 additions & 1 deletion prow/cmd/mkpod/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
"flag"
"fmt"
"io/ioutil"
"k8s.io/test-infra/prow/pjutil"
"os"
"strings"

"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
Expand All @@ -47,7 +49,7 @@ func (o *options) Validate() error {
func gatherOptions() options {
o := options{}
flag.StringVar(&o.prowJobPath, "prow-job", "", "ProwJob to decorate, - for stdin.")
flag.StringVar(&o.buildID, "build-id", "", "Build ID for the job run.")
flag.StringVar(&o.buildID, "build-id", "", "Build ID for the job run or 'snowflake' to generate one. Use 'snowflake' if tot is not used.")
flag.Parse()
return o
}
Expand Down Expand Up @@ -82,6 +84,12 @@ func main() {
o.buildID = job.Status.BuildID
}

if strings.ToLower(o.buildID) == "snowflake" {
// No error possible since this won't use tot.
o.buildID, _ = pjutil.GetBuildID(job.Spec.Job, "")
logrus.WithField("build-id", o.buildID).Info("Generated build-id for job.")
}

if o.buildID == "" {
logrus.Warning("No BuildID found in ProwJob status or given with --build-id, GCS interaction will be poor.")
}
Expand Down

0 comments on commit 53b6b0a

Please sign in to comment.