bigtable/cmd/cbt: add versioning for cbt command
This change adds version strings to the cbt command. They are set via
ldflags from the script we use to build CBT, so we can include the git
revision and current date.
@@ -48,6 +48,10 @@ var (
client *bigtable.Client
adminClient *bigtable.AdminClient
instanceAdminClient *bigtable.InstanceAdminClient
+
+ version = "<unknown version>"
+ revision = "<unknown revision>"
+ revisionDate = "<unknown revision date>"
)
func getCredentialOpts(opts []option.ClientOption) []option.ClientOption {
@@ -179,6 +183,8 @@ For convenience, values of the -project, -instance, -creds,
admin-endpoint = hostname:port
data-endpoint = hostname:port
All values are optional, and all will be overridden by flags.
+
+cbt ` + version + ` ` + revision + ` ` + revisionDate + `
`
var commands = []struct {
@@ -307,6 +313,13 @@ var commands = []struct {
" maxversions=<n> Maximum number of versions to preserve",
Required: cbtconfig.ProjectAndInstanceRequired,
},
+ {
+ Name: "version",
+ Desc: "Print the current cbt version",
+ do: doVersion,
+ Usage: "cbt version",
+ Required: cbtconfig.NoneRequired,
+ },
}
func doCount(ctx context.Context, args ...string) {
@@ -787,3 +800,7 @@ var unitMap = map[string]time.Duration{
"h": time.Hour,
"d": 24 * time.Hour,
}
+
+func doVersion(ctx context.Context, args ...string) {
+ fmt.Printf("%s %s %s\n", version, revision, revisionDate)
+}
