Move --eventlog-endpoint out of isolateFlags.

The batcharchive subcommand instantiates multiple isolateFlag structs per
invocation. We want only a single eventlog endpoint per invocation. So, this CL
moves the eventlog-endpoint flag out of isolateFlags, into its own struct that
can be used directly from the batchArchiveRun, expArchiveRun and ArchiveRun
structs.

BUG=727985

Review-Url: https://codereview.chromium.org/2921393002
diff --git a/client/cmd/isolate/archive.go b/client/cmd/isolate/archive.go
index 99ed9e3..5260bc5 100644
--- a/client/cmd/isolate/archive.go
+++ b/client/cmd/isolate/archive.go
@@ -33,6 +33,7 @@
 			c := archiveRun{}
 			c.commonServerFlags.Init(defaultAuthOpts)
 			c.isolateFlags.Init(&c.Flags)
+			c.loggingFlags.Init(&c.Flags)
 			return &c
 		},
 	}
@@ -41,6 +42,7 @@
 type archiveRun struct {
 	commonServerFlags
 	isolateFlags
+	loggingFlags loggingFlags
 }
 
 func (c *archiveRun) Parse(a subcommands.Application, args []string) error {
@@ -103,7 +105,7 @@
 	if item.Error() != nil {
 		archiveDetails.IsolateHash = []string{string(item.Digest())}
 	}
-	eventlogger := NewLogger(ctx, c.isolateFlags.EventlogEndpoint)
+	eventlogger := NewLogger(ctx, c.loggingFlags.EventlogEndpoint)
 	op := logpb.IsolateClientEvent_LEGACY_ARCHIVE.Enum()
 	if err := eventlogger.logStats(ctx, op, start, end, archiveDetails); err != nil {
 		log.Printf("Failed to log to eventlog: %v", err)
diff --git a/client/cmd/isolate/common.go b/client/cmd/isolate/common.go
index 5137f80..ba0da5b 100644
--- a/client/cmd/isolate/common.go
+++ b/client/cmd/isolate/common.go
@@ -71,7 +71,6 @@
 type isolateFlags struct {
 	// TODO(tandrii): move ArchiveOptions from isolate pkg to here.
 	isolate.ArchiveOptions
-	EventlogEndpoint string
 }
 
 func (c *isolateFlags) Init(f *flag.FlagSet) {
@@ -84,8 +83,6 @@
 	f.Var(&c.ConfigVariables, "config-variable", "Config variables are used to determine which conditions should be matched when loading a .isolate file, default: [].")
 	f.Var(&c.PathVariables, "path-variable", "Path variables are used to replace file paths when loading a .isolate file, default: {}")
 	f.Var(&c.ExtraVariables, "extra-variable", "Extraneous variables are replaced on the command entry and on paths in the .isolate file but are not considered relative paths.")
-
-	f.StringVar(&c.EventlogEndpoint, "eventlog-endpoint", "", `The URL destination for eventlogs. The special values "prod" or "test" may be used to target the standard prod or test urls repspectively. An empty string disables eventlogging.`)
 }
 
 // RequiredIsolateFlags specifies which flags are required on the command line
@@ -132,3 +129,12 @@
 	}
 	return nil
 }
+
+// loggingFlags configures eventlog logging.
+type loggingFlags struct {
+	EventlogEndpoint string
+}
+
+func (lf *loggingFlags) Init(f *flag.FlagSet) {
+	f.StringVar(&lf.EventlogEndpoint, "eventlog-endpoint", "", `The URL destination for eventlogs. The special values "prod" or "test" may be used to target the standard prod or test urls repspectively. An empty string disables eventlogging.`)
+}
diff --git a/client/cmd/isolate/exp_archive.go b/client/cmd/isolate/exp_archive.go
index eae05ae..d78eb53 100644
--- a/client/cmd/isolate/exp_archive.go
+++ b/client/cmd/isolate/exp_archive.go
@@ -50,6 +50,7 @@
 			c := &expArchiveRun{}
 			c.commonServerFlags.Init(defaultAuthOpts)
 			c.isolateFlags.Init(&c.Flags)
+			c.loggingFlags.Init(&c.Flags)
 			c.Flags.StringVar(&c.dumpJSON, "dump-json", "",
 				"Write isolated digests of archived trees to this file as JSON")
 			return c
@@ -62,6 +63,7 @@
 type expArchiveRun struct {
 	commonServerFlags // Provides the GetFlags method.
 	isolateFlags      isolateFlags
+	loggingFlags      loggingFlags
 	dumpJSON          string
 }
 
@@ -286,7 +288,7 @@
 		MissBytes:   &checker.Miss.Bytes,
 		IsolateHash: []string{string(isolItem.Digest)},
 	}
-	eventlogger := NewLogger(ctx, c.isolateFlags.EventlogEndpoint)
+	eventlogger := NewLogger(ctx, c.loggingFlags.EventlogEndpoint)
 	op := logpb.IsolateClientEvent_ARCHIVE.Enum()
 	if err := eventlogger.logStats(ctx, op, start, end, archiveDetails); err != nil {
 		log.Printf("Failed to log to eventlog: %v", err)