From 92656b214ed120c631bc6adab3b35992939e2ced Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Thu, 30 Nov 2017 17:26:42 -0300 Subject: [PATCH] 10666: Replaced 'version' package with 'version' var on every go program. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- build/run-tests.sh | 2 -- sdk/go/version/version.go | 15 ---------- sdk/go/version/version_test.go | 30 ------------------- services/arv-git-httpd/main.go | 7 +++-- .../crunch-dispatch-local.go | 7 +++-- .../crunch-dispatch-slurm.go | 7 +++-- services/crunch-run/crunchrun.go | 9 +++--- services/crunchstat/crunchstat.go | 6 ++-- services/health/main.go | 7 +++-- services/keep-balance/main.go | 7 +++-- services/keep-web/handler.go | 3 +- services/keep-web/main.go | 6 ++-- services/keepproxy/keepproxy.go | 7 +++-- services/keepstore/handlers.go | 3 +- services/keepstore/keepstore.go | 7 +++-- services/ws/main.go | 6 ++-- services/ws/router.go | 3 +- tools/arv-sync-groups/arv-sync-groups.go | 7 +++-- tools/keep-block-check/keep-block-check.go | 5 ++-- tools/keep-exercise/keep-exercise.go | 7 +++-- tools/keep-rsync/keep-rsync.go | 5 ++-- 21 files changed, 59 insertions(+), 97 deletions(-) delete mode 100644 sdk/go/version/version.go delete mode 100644 sdk/go/version/version_test.go diff --git a/build/run-tests.sh b/build/run-tests.sh index 8369632921..ffe0e5098b 100755 --- a/build/run-tests.sh +++ b/build/run-tests.sh @@ -102,7 +102,6 @@ sdk/go/manifest sdk/go/blockdigest sdk/go/streamer sdk/go/stats -sdk/go/version sdk/go/crunchrunner sdk/cwl tools/arv-sync-groups @@ -831,7 +830,6 @@ gostuff=( sdk/go/streamer sdk/go/crunchrunner sdk/go/stats - sdk/go/version lib/crunchstat services/arv-git-httpd services/crunchstat diff --git a/sdk/go/version/version.go b/sdk/go/version/version.go deleted file mode 100644 index ef9abe7662..0000000000 --- a/sdk/go/version/version.go +++ /dev/null @@ -1,15 +0,0 @@ -package version - -var ( - // Version will get assigned the release number at compile time - Version string -) - -// GetVersion returns the release number if it was assigned by the compiler -// or "dev" otherwise. -func GetVersion() string { - if Version != "" { - return Version - } - return "dev" -} diff --git a/sdk/go/version/version_test.go b/sdk/go/version/version_test.go deleted file mode 100644 index 426c1247ab..0000000000 --- a/sdk/go/version/version_test.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) The Arvados Authors. All rights reserved. -// -// SPDX-License-Identifier: Apache-2.0 - -package version - -import ( - "testing" - - . "gopkg.in/check.v1" -) - -// Gocheck boilerplate -func Test(t *testing.T) { - TestingT(t) -} - -type TestSuite struct { -} - -var _ = Suite(&TestSuite{}) - -func (s *TestSuite) TestVersion(c *C) { - // Default version string when Version is not set - c.Assert(Version, Equals, "") - c.Assert(GetVersion(), Equals, "dev") - // Simulate linker flag setting Version var - Version = "1.0.0" - c.Assert(GetVersion(), Equals, "1.0.0") -} diff --git a/services/arv-git-httpd/main.go b/services/arv-git-httpd/main.go index 2750ab9eaf..76aacc4e9d 100644 --- a/services/arv-git-httpd/main.go +++ b/services/arv-git-httpd/main.go @@ -14,10 +14,11 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/config" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" "github.com/coreos/go-systemd/daemon" ) +var version = "dev" + // Server configuration type Config struct { Client arvados.Client @@ -62,7 +63,7 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -93,7 +94,7 @@ func main() { if _, err := daemon.SdNotify(false, "READY=1"); err != nil { log.Printf("Error notifying init daemon: %v", err) } - log.Printf("arv-git-httpd %q started", arvadosVersion.GetVersion()) + log.Printf("arv-git-httpd %q started", version) log.Println("Listening at", srv.Addr) log.Println("Repository root", theConfig.RepoRoot) if err := srv.Wait(); err != nil { diff --git a/services/crunch-dispatch-local/crunch-dispatch-local.go b/services/crunch-dispatch-local/crunch-dispatch-local.go index c1d6d562a2..1529c4fbab 100644 --- a/services/crunch-dispatch-local/crunch-dispatch-local.go +++ b/services/crunch-dispatch-local/crunch-dispatch-local.go @@ -21,9 +21,10 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/dispatch" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) +var version = "dev" + func main() { err := doMain() if err != nil { @@ -61,11 +62,11 @@ func doMain() error { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } - log.Printf("crunch-dispatch-local %q started", arvadosVersion.GetVersion()) + log.Printf("crunch-dispatch-local %q started", version) runningCmds = make(map[string]*exec.Cmd) diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go index e743fa5854..5eeb32e62f 100644 --- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go +++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go @@ -23,10 +23,11 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/config" "git.curoverse.com/arvados.git/sdk/go/dispatch" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" "github.com/coreos/go-systemd/daemon" ) +var version = "dev" + // Config used by crunch-dispatch-slurm type Config struct { Client arvados.Client @@ -79,11 +80,11 @@ func doMain() error { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } - log.Printf("crunch-dispatch-slurm %q started", arvadosVersion.GetVersion()) + log.Printf("crunch-dispatch-slurm %q started", version) err := readConfig(&theConfig, *configPath) if err != nil { diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go index c45a3f0599..a957874f91 100644 --- a/services/crunch-run/crunchrun.go +++ b/services/crunch-run/crunchrun.go @@ -32,7 +32,6 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/keepclient" "git.curoverse.com/arvados.git/sdk/go/manifest" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" dockertypes "github.com/docker/docker/api/types" dockercontainer "github.com/docker/docker/api/types/container" @@ -40,6 +39,8 @@ import ( dockerclient "github.com/docker/docker/client" ) +var version = "dev" + // IArvadosClient is the minimal Arvados API methods used by crunch-run. type IArvadosClient interface { Create(resourceType string, parameters arvadosclient.Dict, output interface{}) error @@ -1419,7 +1420,7 @@ func (runner *ContainerRunner) NewArvLogWriter(name string) io.WriteCloser { // Run the full container lifecycle. func (runner *ContainerRunner) Run() (err error) { - runner.CrunchLog.Printf("crunch-run %q started", arvadosVersion.GetVersion()) + runner.CrunchLog.Printf("crunch-run %q started", version) runner.CrunchLog.Printf("Executing container '%s'", runner.Container.UUID) hostname, hosterr := os.Hostname() @@ -1600,11 +1601,11 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } - log.Printf("crunch-run %q started", arvadosVersion.GetVersion()) + log.Printf("crunch-run %q started", version) containerId := flag.Arg(0) diff --git a/services/crunchstat/crunchstat.go b/services/crunchstat/crunchstat.go index 454a5fc3a4..248ec6259d 100644 --- a/services/crunchstat/crunchstat.go +++ b/services/crunchstat/crunchstat.go @@ -17,7 +17,6 @@ import ( "time" "git.curoverse.com/arvados.git/lib/crunchstat" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) const MaxLogLine = 1 << 14 // Child stderr lines >16KiB will be split @@ -25,6 +24,7 @@ const MaxLogLine = 1 << 14 // Child stderr lines >16KiB will be split var ( signalOnDeadPPID int = 15 ppidCheckInterval = time.Second + version = "dev" ) func main() { @@ -44,11 +44,11 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } - reporter.Logger.Printf("crunchstat %q started", arvadosVersion.GetVersion()) + reporter.Logger.Printf("crunchstat %q started", version) if reporter.CgroupRoot == "" { reporter.Logger.Fatal("error: must provide -cgroup-root") diff --git a/services/health/main.go b/services/health/main.go index d04b55bc6c..4b553659ed 100644 --- a/services/health/main.go +++ b/services/health/main.go @@ -9,10 +9,11 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/health" "git.curoverse.com/arvados.git/sdk/go/httpserver" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" log "github.com/Sirupsen/logrus" ) +var version = "dev" + func main() { configFile := flag.String("config", arvados.DefaultConfigFile, "`path` to arvados configuration file") getVersion := flag.Bool("version", false, "Print version information and exit.") @@ -20,14 +21,14 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } log.SetFormatter(&log.JSONFormatter{ TimestampFormat: "2006-01-02T15:04:05.000000000Z07:00", }) - log.Printf("arvados health %q started", arvadosVersion.GetVersion()) + log.Printf("arvados health %q started", version) cfg, err := arvados.GetConfig(*configFile) if err != nil { diff --git a/services/keep-balance/main.go b/services/keep-balance/main.go index fe4a8c41c5..ecc3f2696f 100644 --- a/services/keep-balance/main.go +++ b/services/keep-balance/main.go @@ -16,9 +16,10 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/config" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) +var version = "dev" + const defaultConfigPath = "/etc/arvados/keep-balance/keep-balance.yml" // Config specifies site configuration, like API credentials and the @@ -93,7 +94,7 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -106,7 +107,7 @@ func main() { log.Fatal(config.DumpAndExit(cfg)) } - log.Printf("keep-balance %q started", arvadosVersion.GetVersion()) + log.Printf("keep-balance %q started", version) if *debugFlag { debugf = log.Printf diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go index 161864a8b9..7bdd521226 100644 --- a/services/keep-web/handler.go +++ b/services/keep-web/handler.go @@ -24,7 +24,6 @@ import ( "git.curoverse.com/arvados.git/sdk/go/health" "git.curoverse.com/arvados.git/sdk/go/httpserver" "git.curoverse.com/arvados.git/sdk/go/keepclient" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" "golang.org/x/net/webdav" ) @@ -94,7 +93,7 @@ func (h *handler) serveStatus(w http.ResponseWriter, r *http.Request) { Version string }{ cacheStats: h.Config.Cache.Stats(), - Version: arvadosVersion.GetVersion(), + Version: version, } json.NewEncoder(w).Encode(status) } diff --git a/services/keep-web/main.go b/services/keep-web/main.go index 8bd890322e..938377b525 100644 --- a/services/keep-web/main.go +++ b/services/keep-web/main.go @@ -13,12 +13,12 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/config" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" "github.com/coreos/go-systemd/daemon" ) var ( defaultConfigPath = "/etc/arvados/keep-web/keep-web.yml" + version = "dev" ) // Config specifies server configuration. @@ -94,7 +94,7 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -115,7 +115,7 @@ func main() { log.Fatal(config.DumpAndExit(cfg)) } - log.Printf("keep-web %q started", arvadosVersion.GetVersion()) + log.Printf("keep-web %q started", version) os.Setenv("ARVADOS_API_HOST", cfg.Client.APIHost) srv := &server{Config: cfg} diff --git a/services/keepproxy/keepproxy.go b/services/keepproxy/keepproxy.go index ec074cff3f..59eec0bb04 100644 --- a/services/keepproxy/keepproxy.go +++ b/services/keepproxy/keepproxy.go @@ -26,12 +26,13 @@ import ( "git.curoverse.com/arvados.git/sdk/go/config" "git.curoverse.com/arvados.git/sdk/go/health" "git.curoverse.com/arvados.git/sdk/go/keepclient" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" "github.com/coreos/go-systemd/daemon" "github.com/ghodss/yaml" "github.com/gorilla/mux" ) +var version = "dev" + type Config struct { Client arvados.Client Listen string @@ -80,7 +81,7 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -107,7 +108,7 @@ func main() { log.Fatal(config.DumpAndExit(cfg)) } - log.Printf("keepproxy %q started", arvadosVersion.GetVersion()) + log.Printf("keepproxy %q started", version) arv, err := arvadosclient.New(&cfg.Client) if err != nil { diff --git a/services/keepstore/handlers.go b/services/keepstore/handlers.go index 5cd3aa8b71..daf4fc69dd 100644 --- a/services/keepstore/handlers.go +++ b/services/keepstore/handlers.go @@ -31,7 +31,6 @@ import ( "git.curoverse.com/arvados.git/sdk/go/health" "git.curoverse.com/arvados.git/sdk/go/httpserver" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" log "github.com/Sirupsen/logrus" ) @@ -348,7 +347,7 @@ func (rtr *router) StatusHandler(resp http.ResponseWriter, req *http.Request) { // populate the given NodeStatus struct with current values. func (rtr *router) readNodeStatus(st *NodeStatus) { - st.Version = arvadosVersion.GetVersion() + st.Version = version vols := KeepVM.AllReadable() if cap(st.Volumes) < len(vols) { st.Volumes = make([]*volumeStatusEnt, len(vols)) diff --git a/services/keepstore/keepstore.go b/services/keepstore/keepstore.go index 23af6906bb..06a26984d0 100644 --- a/services/keepstore/keepstore.go +++ b/services/keepstore/keepstore.go @@ -18,11 +18,12 @@ import ( "git.curoverse.com/arvados.git/sdk/go/config" "git.curoverse.com/arvados.git/sdk/go/httpserver" "git.curoverse.com/arvados.git/sdk/go/keepclient" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" log "github.com/Sirupsen/logrus" "github.com/coreos/go-systemd/daemon" ) +var version = "dev" + // A Keep "block" is 64MB. const BlockSize = 64 * 1024 * 1024 @@ -104,7 +105,7 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -119,7 +120,7 @@ func main() { log.Fatal(config.DumpAndExit(theConfig)) } - log.Printf("keepstore %q started", arvadosVersion.GetVersion()) + log.Printf("keepstore %q started", version) err = theConfig.Start() if err != nil { diff --git a/services/ws/main.go b/services/ws/main.go index 30d569c988..df462eafc2 100644 --- a/services/ws/main.go +++ b/services/ws/main.go @@ -11,10 +11,10 @@ import ( "git.curoverse.com/arvados.git/sdk/go/config" "git.curoverse.com/arvados.git/sdk/go/ctxlog" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) var logger = ctxlog.FromContext +var version = "dev" func main() { log := logger(nil) @@ -27,7 +27,7 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -48,7 +48,7 @@ func main() { return } - log.Printf("arvados-ws %q started", arvadosVersion.GetVersion()) + log.Printf("arvados-ws %q started", version) log.Info("started") srv := &server{wsConfig: &cfg} diff --git a/services/ws/router.go b/services/ws/router.go index 5fa1674352..987c225eac 100644 --- a/services/ws/router.go +++ b/services/ws/router.go @@ -15,7 +15,6 @@ import ( "git.curoverse.com/arvados.git/sdk/go/ctxlog" "git.curoverse.com/arvados.git/sdk/go/health" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" "github.com/Sirupsen/logrus" "golang.org/x/net/websocket" ) @@ -124,7 +123,7 @@ func (rtr *router) DebugStatus() interface{} { func (rtr *router) Status() interface{} { return map[string]interface{}{ "Clients": atomic.LoadInt64(&rtr.status.ReqsActive), - "Version": arvadosVersion.GetVersion(), + "Version": version, } } diff --git a/tools/arv-sync-groups/arv-sync-groups.go b/tools/arv-sync-groups/arv-sync-groups.go index 3530ce56de..e88fac66e0 100644 --- a/tools/arv-sync-groups/arv-sync-groups.go +++ b/tools/arv-sync-groups/arv-sync-groups.go @@ -17,9 +17,10 @@ import ( "strings" "git.curoverse.com/arvados.git/sdk/go/arvados" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) +var version = "dev" + type resourceList interface { Len() int GetItems() []interface{} @@ -165,7 +166,7 @@ func ParseFlags(config *ConfigParams) error { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } @@ -287,7 +288,7 @@ func doMain(cfg *ConfigParams) error { } defer f.Close() - log.Printf("arv-sync-groups %q started. Using %q as users id and parent group UUID %q", arvadosVersion.GetVersion(), cfg.UserID, cfg.ParentGroupUUID) + log.Printf("arv-sync-groups %q started. Using %q as users id and parent group UUID %q", version, cfg.UserID, cfg.ParentGroupUUID) // Get the complete user list to minimize API Server requests allUsers := make(map[string]arvados.User) diff --git a/tools/keep-block-check/keep-block-check.go b/tools/keep-block-check/keep-block-check.go index 9d3b45a6bd..9f6ff984ae 100644 --- a/tools/keep-block-check/keep-block-check.go +++ b/tools/keep-block-check/keep-block-check.go @@ -18,9 +18,10 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/keepclient" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) +var version = "dev" + func main() { err := doMain(os.Args[1:]) if err != nil { @@ -73,7 +74,7 @@ func doMain(args []string) error { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } diff --git a/tools/keep-exercise/keep-exercise.go b/tools/keep-exercise/keep-exercise.go index d5386b0ef5..4c8a3449be 100644 --- a/tools/keep-exercise/keep-exercise.go +++ b/tools/keep-exercise/keep-exercise.go @@ -32,9 +32,10 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/keepclient" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) +var version = "dev" + // Command line config knobs var ( BlockSize = flag.Int("block-size", keepclient.BLOCKSIZE, "bytes per read/write op") @@ -54,11 +55,11 @@ func main() { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } - log.Printf("keep-exercise %q started", arvadosVersion.GetVersion()) + log.Printf("keep-exercise %q started", version) arv, err := arvadosclient.MakeArvadosClient() if err != nil { diff --git a/tools/keep-rsync/keep-rsync.go b/tools/keep-rsync/keep-rsync.go index df7f1caf3e..55c1a3b090 100644 --- a/tools/keep-rsync/keep-rsync.go +++ b/tools/keep-rsync/keep-rsync.go @@ -19,9 +19,10 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/keepclient" - arvadosVersion "git.curoverse.com/arvados.git/sdk/go/version" ) +var version = "dev" + func main() { err := doMain() if err != nil { @@ -80,7 +81,7 @@ func doMain() error { // Print version information if requested if *getVersion { - fmt.Printf("Version: %s\n", arvadosVersion.GetVersion()) + fmt.Printf("Version: %s\n", version) os.Exit(0) } -- 2.30.2