[resultstore] Support initialization via command line flags
IN-699 #comment
Change-Id: I460a7fa7353935cb179ce88b1ade6074740d9238
diff --git a/resultstore/resultstore.go b/resultstore/resultstore.go
index 1d20af1..e083ab1 100644
--- a/resultstore/resultstore.go
+++ b/resultstore/resultstore.go
@@ -14,9 +14,11 @@
"google.golang.org/grpc/credentials"
)
-const (
+var (
// Google Cloud API scope required to use ResultStore Upload API.
- scope = "https://www.googleapis.com/auth/cloud-platform"
+ RequiredScopes = []string{
+ "https://www.googleapis.com/auth/cloud-platform",
+ }
)
// Connect returns a new UploadClient connected to the ResultStore backend at the given host.
@@ -78,3 +80,19 @@
panic("invalid environment: " + e)
}
}
+
+func (e Environment) String() string {
+ return string(e)
+}
+
+// Set implements flag.Var
+func (e *Environment) Set(value string) error {
+ switch value {
+ case string(Production), string(Staging):
+ *e = Environment(value)
+ default:
+ return fmt.Errorf("invalid environment: %q", value)
+ }
+
+ return nil
+}