cmd/internal/cmdconfig: fill in experiment descriptions
If an experiment lacks a description in the config file, use
the description from internal.Experiments.
Log an error if the experiment name is not in that map.
Change-Id: I3362d9a71d963a202d1616b9f2c6cf347314332c
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/260117
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/cmd/internal/cmdconfig/cmdconfig.go b/cmd/internal/cmdconfig/cmdconfig.go
index 983e7b4..af9f406 100644
--- a/cmd/internal/cmdconfig/cmdconfig.go
+++ b/cmd/internal/cmdconfig/cmdconfig.go
@@ -73,9 +73,15 @@
var s []string
for _, e := range dc.Experiments {
s = append(s, fmt.Sprintf("%s:%d", e.Name, e.Rollout))
+ if desc, ok := internal.Experiments[e.Name]; ok {
+ if e.Description == "" {
+ e.Description = desc
+ }
+ } else {
+ log.Errorf(ctx, "unknown experiment %q", e.Name)
+ }
}
log.Infof(ctx, "read experiments %s", strings.Join(s, ", "))
-
return dc.Experiments, nil
}
}