X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a6401a8c59a582633de2ae197e71aad493de291a..b36138dd447b5ff557cfbb0e00c28899a9c3af17:/tools/keep-block-check/keep-block-check.go diff --git a/tools/keep-block-check/keep-block-check.go b/tools/keep-block-check/keep-block-check.go index 6cf11a7280..2de7a96c9a 100644 --- a/tools/keep-block-check/keep-block-check.go +++ b/tools/keep-block-check/keep-block-check.go @@ -1,3 +1,7 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + package main import ( @@ -5,17 +9,19 @@ import ( "errors" "flag" "fmt" - "git.curoverse.com/arvados.git/sdk/go/arvadosclient" - "git.curoverse.com/arvados.git/sdk/go/keepclient" "io/ioutil" "log" "net/http" "os" - "regexp" "strings" "time" + + "git.curoverse.com/arvados.git/sdk/go/arvadosclient" + "git.curoverse.com/arvados.git/sdk/go/keepclient" ) +var version = "dev" + func main() { err := doMain(os.Args[1:]) if err != nil { @@ -58,9 +64,20 @@ func doMain(args []string) error { false, "Log progress of each block verification") + getVersion := flags.Bool( + "version", + false, + "Print version information and exit.") + // Parse args; omit the first arg which is the command name flags.Parse(args) + // Print version information if requested + if *getVersion { + fmt.Printf("keep-block-check %s\n", version) + os.Exit(0) + } + config, blobSigningKey, err := loadConfig(*configFile) if err != nil { return fmt.Errorf("Error loading configuration from file: %s", err.Error()) @@ -99,8 +116,6 @@ func loadConfig(configFile string) (config apiConfig, blobSigningKey string, err return } -var matchTrue = regexp.MustCompile("^(?i:1|yes|true)$") - // Read config from file func readConfigFromFile(filename string) (config apiConfig, blobSigningKey string, err error) { if !strings.Contains(filename, "/") { @@ -130,9 +145,9 @@ func readConfigFromFile(filename string) (config apiConfig, blobSigningKey strin case "ARVADOS_API_HOST": config.APIHost = value case "ARVADOS_API_HOST_INSECURE": - config.APIHostInsecure = matchTrue.MatchString(value) + config.APIHostInsecure = arvadosclient.StringBool(value) case "ARVADOS_EXTERNAL_CLIENT": - config.ExternalClient = matchTrue.MatchString(value) + config.ExternalClient = arvadosclient.StringBool(value) case "ARVADOS_BLOB_SIGNING_KEY": blobSigningKey = value } @@ -153,7 +168,7 @@ func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL External: config.ExternalClient, } - // if keepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers + // If keepServicesJSON is provided, use it instead of service discovery if keepServicesJSON == "" { kc, err = keepclient.MakeKeepClient(&arv) if err != nil {