ref: Add -v23.metadata, which dumps metadata for the binary.
The metadata package is a map from string ids to string values,
and provides a mechanism to set the ldflags on the go toolchain
to get metadata linked into your binary during build time. It
also provides utilities to insert more metadata in package init
functions, and to convert into XML and base64.
Every binary built with the metadata package will now
automatically get a flag -v23.metadata, which dumps the metadata
for the program binary in XML.
The format looks like this:
<metadata>
<md id="build.Manifest"><![CDATA[
<manifest label="">
<imports></imports>
<projects>
<project exclude="false" name="release.go.v23"...
...
</projects>
<tools></tools>
</manifest>
]]></md>
<md id="build.Platform">amd64unknown-linux-unknown</md>
<md id="build.Pristine">false</md>
<md id="build.Time">2015-05-04T08:40:22Z</md>
<md id="build.User">Todd Wang</md>
<md id="go.Arch">amd64</md>
<md id="go.OS">linux</md>
<md id="go.Version">go1.4.1</md>
<md id="v23.RPCEndpointVersion">5</md>
<md id="v23.RPCVersionMax">10</md>
<md id="v23.RPCVersionMin">9</md>
</metadata>
This addresses one part of vanadium/issues#407
MultiPart: 3/3
Change-Id: I33b45fb9d3d79c4aaa92b1ab3af8d0c6a65d736c
diff --git a/cmd/gclogs/doc.go b/cmd/gclogs/doc.go
index adffadf..95cbf6c 100644
--- a/cmd/gclogs/doc.go
+++ b/cmd/gclogs/doc.go
@@ -51,6 +51,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.permissions.file=map[]
diff --git a/cmd/mounttable/doc.go b/cmd/mounttable/doc.go
index 562e14d..7763255 100644
--- a/cmd/mounttable/doc.go
+++ b/cmd/mounttable/doc.go
@@ -40,6 +40,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.proxy=
object name of proxy service to use to export services across network
boundaries
diff --git a/cmd/namespace/doc.go b/cmd/namespace/doc.go
index 2f82af3..b6e2957 100644
--- a/cmd/namespace/doc.go
+++ b/cmd/namespace/doc.go
@@ -48,6 +48,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.proxy=
object name of proxy service to use to export services across network
boundaries
diff --git a/cmd/principal/doc.go b/cmd/principal/doc.go
index 5ef91ab..ae4f429 100644
--- a/cmd/principal/doc.go
+++ b/cmd/principal/doc.go
@@ -49,6 +49,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.permissions.file=map[]
diff --git a/cmd/uniqueid/doc.go b/cmd/uniqueid/doc.go
index 9ad2e59..ce5859d 100644
--- a/cmd/uniqueid/doc.go
+++ b/cmd/uniqueid/doc.go
@@ -36,6 +36,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.permissions.file=map[]
diff --git a/cmd/vdl/doc.go b/cmd/vdl/doc.go
index e977881..4130b33 100644
--- a/cmd/vdl/doc.go
+++ b/cmd/vdl/doc.go
@@ -37,6 +37,10 @@
-vdl.config=vdl.config
Basename of the optional per-package config file.
+The global flags are:
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
+
Vdl generate
Generate compiles packages and their transitive dependencies, and generates code
diff --git a/cmd/vom/doc.go b/cmd/vom/doc.go
index 4bdba37..09aebc3 100644
--- a/cmd/vom/doc.go
+++ b/cmd/vom/doc.go
@@ -35,6 +35,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.permissions.file=map[]
diff --git a/cmd/vomtestgen/doc.go b/cmd/vomtestgen/doc.go
index 1d9e7af..08a4f97 100644
--- a/cmd/vomtestgen/doc.go
+++ b/cmd/vomtestgen/doc.go
@@ -52,6 +52,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.permissions.file=map[]
diff --git a/cmd/vrpc/doc.go b/cmd/vrpc/doc.go
index aeaa638..0311b7a 100644
--- a/cmd/vrpc/doc.go
+++ b/cmd/vrpc/doc.go
@@ -40,6 +40,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.proxy=
object name of proxy service to use to export services across network
boundaries
diff --git a/cmd/vrun/doc.go b/cmd/vrun/doc.go
index aebe0ba..52398a5 100644
--- a/cmd/vrun/doc.go
+++ b/cmd/vrun/doc.go
@@ -40,6 +40,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=
diff --git a/lib/flags/flags.go b/lib/flags/flags.go
index d133d1f..d459483 100644
--- a/lib/flags/flags.go
+++ b/lib/flags/flags.go
@@ -12,7 +12,6 @@
"sync"
"v.io/v23/verror"
- "v.io/x/lib/buildinfo"
"v.io/x/ref/envvar"
)
@@ -453,28 +452,6 @@
// TODO(cnicolaou): implement a single env var 'VANADIUM_OPTS'
// that can be used to specify any command line.
- fs := f.FlagSet
- if fs == flag.CommandLine {
- // We treat the default command-line flag set specially w.r.t.
- // printing out the build binary metadata: we want to display it
- // as the first thing in the help message for the binary.
- //
- // We do this by overriding the usage function for the duration
- // of the Parse.
- oldUsage := fs.Usage
- defer func() {
- fs.Usage = oldUsage
- }()
- fs.Usage = func() {
- fmt.Fprintf(os.Stderr, "Binary info: %s\n", buildinfo.Info())
- if oldUsage == nil {
- flag.Usage()
- } else {
- oldUsage()
- }
- }
- }
-
if err := f.FlagSet.Parse(args); err != nil {
return err
}
diff --git a/lib/stats/sysstats/sysstats.go b/lib/stats/sysstats/sysstats.go
index 947b017..2fafa14 100644
--- a/lib/stats/sysstats/sysstats.go
+++ b/lib/stats/sysstats/sysstats.go
@@ -14,7 +14,7 @@
"strings"
"time"
- "v.io/x/lib/buildinfo"
+ "v.io/x/lib/metadata"
"v.io/x/ref/lib/stats"
)
@@ -33,7 +33,7 @@
stats.NewIntegerFunc("system/GOMAXPROCS", func() int64 { return int64(runtime.GOMAXPROCS(0)) })
exportEnv()
exportMemStats()
- exportBuildInfo()
+ exportMetaData()
}
func exportEnv() {
@@ -80,11 +80,10 @@
}()
}
-func exportBuildInfo() {
- kv := []stats.KeyValue{}
- v := reflect.ValueOf(*buildinfo.Info())
- for i := 0; i < v.NumField(); i++ {
- kv = append(kv, stats.KeyValue{v.Type().Field(i).Name, v.Field(i).Interface()})
+func exportMetaData() {
+ var kv []stats.KeyValue
+ for id, value := range metadata.ToMap() {
+ kv = append(kv, stats.KeyValue{id, value})
}
- stats.NewMap("system/buildinfo").Set(kv)
+ stats.NewMap("system/metadata").Set(kv)
}
diff --git a/profiles/internal/naming/endpoint.go b/profiles/internal/naming/endpoint.go
index 5190d82..6f70248 100644
--- a/profiles/internal/naming/endpoint.go
+++ b/profiles/internal/naming/endpoint.go
@@ -13,6 +13,7 @@
"strings"
"v.io/v23/naming"
+ "v.io/x/lib/metadata"
)
const (
@@ -148,6 +149,10 @@
return Network
}
+func init() {
+ metadata.Insert("v23.RPCEndpointVersion", fmt.Sprint(defaultVersion))
+}
+
var defaultVersion = 5
func (ep *Endpoint) VersionedString(version int) string {
diff --git a/profiles/internal/rpc/stress/mtstress/doc.go b/profiles/internal/rpc/stress/mtstress/doc.go
index f23772f..82fe778 100644
--- a/profiles/internal/rpc/stress/mtstress/doc.go
+++ b/profiles/internal/rpc/stress/mtstress/doc.go
@@ -41,6 +41,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=
diff --git a/profiles/internal/rpc/version/version.go b/profiles/internal/rpc/version/version.go
index c23913b..44cad53 100644
--- a/profiles/internal/rpc/version/version.go
+++ b/profiles/internal/rpc/version/version.go
@@ -5,8 +5,11 @@
package version
import (
+ "fmt"
+
"v.io/v23/rpc/version"
"v.io/v23/verror"
+ "v.io/x/lib/metadata"
)
// Range represents a range of RPC versions.
@@ -14,15 +17,20 @@
Min, Max version.RPCVersion
}
-var (
- // SupportedRange represents the range of protocol verions supported by this
- // implementation.
- // Max should be incremented whenever we make a protocol
- // change that's not both forward and backward compatible.
- // Min should be incremented whenever we want to remove
- // support for old protocol versions.
- SupportedRange = &Range{Min: version.RPCVersion9, Max: version.RPCVersion10}
-)
+// SupportedRange represents the range of protocol verions supported by this
+// implementation.
+//
+// Max is incremented whenever we make a protocol change that's not both forward
+// and backward compatible.
+//
+// Min is incremented whenever we want to remove support for old protocol
+// versions.
+var SupportedRange = &Range{Min: version.RPCVersion9, Max: version.RPCVersion10}
+
+func init() {
+ metadata.Insert("v23.RPCVersionMax", fmt.Sprint(SupportedRange.Max))
+ metadata.Insert("v23.RPCVersionMin", fmt.Sprint(SupportedRange.Min))
+}
const pkgPath = "v.io/x/ref/profiles/internal/rpc/version"
diff --git a/profiles/internal/rt/runtime.go b/profiles/internal/rt/runtime.go
index 320a1b2..88d092c 100644
--- a/profiles/internal/rt/runtime.go
+++ b/profiles/internal/rt/runtime.go
@@ -25,7 +25,7 @@
"v.io/v23/security"
"v.io/v23/verror"
"v.io/v23/vtrace"
- "v.io/x/lib/buildinfo"
+ "v.io/x/lib/metadata"
"v.io/x/lib/vlog"
"v.io/x/ref/lib/flags"
"v.io/x/ref/lib/stats"
@@ -97,17 +97,17 @@
if err != nil && err != vlog.Configured {
return nil, nil, nil, err
}
- // We want to print out buildinfo only into the log files, to avoid
+ // We want to print out metadata only into the log files, to avoid
// spamming stderr, see #1246.
//
// TODO(caprita): We should add it to the log file header information;
// since that requires changes to the llog and vlog packages, for now we
- // condition printing of buildinfo on having specified an explicit
- // log_dir for the program. It's a hack, but it gets us the buildinfo
- // fo device manager-run apps and avoids it for command-lines, which is
+ // condition printing of metadata on having specified an explicit
+ // log_dir for the program. It's a hack, but it gets us the metadata
+ // to device manager-run apps and avoids it for command-lines, which is
// a good enough approximation.
if vlog.Log.LogDir() != os.TempDir() {
- vlog.Infof("Binary info: %s", buildinfo.Info())
+ vlog.Infof(metadata.ToXML())
}
// Setup the initial trace.
diff --git a/services/application/application/doc.go b/services/application/application/doc.go
index d0bca56..9ec0e14 100644
--- a/services/application/application/doc.go
+++ b/services/application/application/doc.go
@@ -38,6 +38,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=
diff --git a/services/binary/binary/doc.go b/services/binary/binary/doc.go
index 9714180..04a4f73 100644
--- a/services/binary/binary/doc.go
+++ b/services/binary/binary/doc.go
@@ -37,6 +37,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=
diff --git a/services/build/build/doc.go b/services/build/build/doc.go
index 2fa4527..20bda16 100644
--- a/services/build/build/doc.go
+++ b/services/build/build/doc.go
@@ -34,6 +34,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=
diff --git a/services/debug/debug/doc.go b/services/debug/debug/doc.go
index 42eaf67..ad9e01e 100644
--- a/services/debug/debug/doc.go
+++ b/services/debug/debug/doc.go
@@ -38,6 +38,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=
diff --git a/services/device/device/doc.go b/services/device/device/doc.go
index 3fe77dd..732c29c 100644
--- a/services/device/device/doc.go
+++ b/services/device/device/doc.go
@@ -76,6 +76,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.permissions.file=map[]
specify a perms file as <name>:<permsfile>
-v23.permissions.literal=
diff --git a/services/device/deviced/doc.go b/services/device/deviced/doc.go
index 3468792..cc1c5bb 100644
--- a/services/device/deviced/doc.go
+++ b/services/device/deviced/doc.go
@@ -78,6 +78,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.permissions.file=map[]
diff --git a/services/device/internal/impl/device_service.go b/services/device/internal/impl/device_service.go
index 43d0a38..1678fb8 100644
--- a/services/device/internal/impl/device_service.go
+++ b/services/device/internal/impl/device_service.go
@@ -61,7 +61,7 @@
"v.io/v23/services/binary"
"v.io/v23/services/device"
"v.io/v23/verror"
- "v.io/x/lib/buildinfo"
+ "v.io/x/lib/metadata"
"v.io/x/lib/vlog"
"v.io/x/ref/envvar"
vexec "v.io/x/ref/lib/exec"
@@ -121,14 +121,14 @@
// CreationInfo holds data about the binary that originally created the device manager on-disk state
type CreatorInfo struct {
- Version Version
- BuildInfo string
+ Version Version
+ MetaData string
}
func SaveCreatorInfo(dir string) error {
info := CreatorInfo{
- Version: CurrentVersion,
- BuildInfo: buildinfo.Info().String(),
+ Version: CurrentVersion,
+ MetaData: metadata.ToXML(),
}
jsonInfo, err := json.Marshal(info)
if err != nil {
diff --git a/services/profile/profile/doc.go b/services/profile/profile/doc.go
index 3fee387..51ea9ca 100644
--- a/services/profile/profile/doc.go
+++ b/services/profile/profile/doc.go
@@ -38,6 +38,8 @@
directory to use for storing security credentials
-v23.i18n-catalogue=
18n catalogue files to load, comma separated
+ -v23.metadata=<just specify -v23.metadata to activate>
+ Displays metadata for the program and exits.
-v23.namespace.root=[/(dev.v.io/role/vprod/service/mounttabled)@ns.dev.v.io:8101]
local namespace root; can be repeated to provided multiple roots
-v23.proxy=