8936: address review comments
[arvados.git] / tools / keep-block-check / keep-block-check.go
index ed546f0104db8068fa7d7847cc9b9f2fb718f638..f27a4bc4c1af221b455b6ca4066ff4a85960839a 100644 (file)
@@ -48,10 +48,10 @@ func doMain(args []string) error {
                "",
                "Block hash prefix. When a prefix is specified, only hashes listed in the file with this prefix will be checked.")
 
-       blobSigningTTL := flags.Duration(
+       blobSignatureTTL := flags.Duration(
                "blob-signing-ttl",
-               0*time.Second,
-               "Lifetime of blob permission signatures on the keepservers. If not provided, this will be retrieved from the keepservers.")
+               0,
+               "Lifetime of blob permission signatures on the keepservers. If not provided, this will be retrieved from the API server's discovery document.")
 
        verbose := flags.Bool(
                "v",
@@ -73,12 +73,12 @@ func doMain(args []string) error {
        }
 
        // setup keepclient
-       kc, err := setupKeepClient(config, *keepServicesJSON, *blobSigningTTL)
+       kc, err := setupKeepClient(config, *keepServicesJSON, *blobSignatureTTL)
        if err != nil {
                return fmt.Errorf("Error configuring keepclient: %s", err.Error())
        }
 
-       return performKeepBlockCheck(kc, *blobSigningTTL, blobSigningKey, blockLocators, *verbose)
+       return performKeepBlockCheck(kc, *blobSignatureTTL, blobSigningKey, blockLocators, *verbose)
 }
 
 type apiConfig struct {
@@ -143,7 +143,7 @@ func readConfigFromFile(filename string) (config apiConfig, blobSigningKey strin
 }
 
 // setup keepclient using the config provided
-func setupKeepClient(config apiConfig, keepServicesJSON string, blobSigningTTL time.Duration) (kc *keepclient.KeepClient, err error) {
+func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL time.Duration) (kc *keepclient.KeepClient, err error) {
        arv := arvadosclient.ArvadosClient{
                ApiToken:    config.APIToken,
                ApiServer:   config.APIHost,
@@ -167,11 +167,11 @@ func setupKeepClient(config apiConfig, keepServicesJSON string, blobSigningTTL t
                }
        }
 
-       // Get if blobSigningTTL is not provided
-       if blobSigningTTL == 0 {
+       // Get if blobSignatureTTL is not provided
+       if blobSignatureTTL == 0 {
                value, err := arv.Discovery("blobSignatureTtl")
                if err == nil {
-                       blobSigningTTL = time.Duration(int(value.(float64))) * time.Second
+                       blobSignatureTTL = time.Duration(int(value.(float64))) * time.Second
                } else {
                        return nil, err
                }
@@ -206,7 +206,7 @@ func getBlockLocators(locatorFile, prefix string) (locators []string, err error)
 }
 
 // Get block headers from keep. Log any errors.
-func performKeepBlockCheck(kc *keepclient.KeepClient, blobSigningTTL time.Duration, blobSigningKey string, blockLocators []string, verbose bool) error {
+func performKeepBlockCheck(kc *keepclient.KeepClient, blobSignatureTTL time.Duration, blobSigningKey string, blockLocators []string, verbose bool) error {
        totalBlocks := len(blockLocators)
        notFoundBlocks := 0
        current := 0
@@ -218,7 +218,7 @@ func performKeepBlockCheck(kc *keepclient.KeepClient, blobSigningTTL time.Durati
                getLocator := locator
                if blobSigningKey != "" {
                        expiresAt := time.Now().AddDate(0, 0, 1)
-                       getLocator = keepclient.SignLocator(locator, kc.Arvados.ApiToken, expiresAt, blobSigningTTL, []byte(blobSigningKey))
+                       getLocator = keepclient.SignLocator(locator, kc.Arvados.ApiToken, expiresAt, blobSignatureTTL, []byte(blobSigningKey))
                }
 
                _, _, err := kc.Ask(getLocator)