[git] Only complain about non-CIPD git when running in production
Bug: skia:9538
Change-Id: I3b7fb32a2da9de98c6f524d861b8baf8f91596ef
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/255257
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
diff --git a/go/git/git_common/git_common.go b/go/git/git_common/git_common.go
index 443c938..bb55ac9 100644
--- a/go/git/git_common/git_common.go
+++ b/go/git/git_common/git_common.go
@@ -16,6 +16,7 @@
"go.skia.org/infra/go/exec"
"go.skia.org/infra/go/skerr"
"go.skia.org/infra/go/sklog"
+ "go.skia.org/infra/go/util"
)
var (
@@ -41,7 +42,7 @@
return "", 0, 0, skerr.Wrapf(err, "Failed to obtain git version")
}
sklog.Infof("Git is %s; version %d.%d", gitPath, maj, min)
- if !IsFromCIPD(gitPath) {
+ if !IsFromCIPD(gitPath) && !util.IsLocal() {
sklog.Errorf("Git at %s does not appear to be obtained via CIPD; this will be a fatal error soon.", gitPath)
}
git = gitPath
diff --git a/go/util/util.go b/go/util/util.go
index 8d750e5..dbe94b7 100644
--- a/go/util/util.go
+++ b/go/util/util.go
@@ -8,6 +8,7 @@
"crypto/rand"
"crypto/sha256"
"encoding/gob"
+ "flag"
"fmt"
"io"
"io/ioutil"
@@ -1279,3 +1280,18 @@
}
return deduped
}
+
+// IsLocal attempts to determine whether or not we're running on a developer
+// machine vs in Swarming or Kubernetes.
+func IsLocal() bool {
+ // Check the --local flag.
+ localFlag := flag.Lookup("local")
+ if localFlag != nil {
+ return localFlag.Value.String() == "true"
+ }
+
+ // Note: we could also check environment variables we know are present
+ // in Swarming and in Kubernetes, but those would have no effect because
+ // the default is false.
+ return false
+}