18487: Fixes error checking on nonexistant vocabulary file. Adds tests.
[arvados.git] / lib / config / cmd.go
index e532a7e32a09e1f04a4b93c319fefc8b7bdd21d6..2f90bc80dd850a6fca9db5d3b07a3ed387eb2cd3 100644 (file)
@@ -148,7 +148,7 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
                if cc.API.VocabularyPath == "" {
                        continue
                }
-               _, err = os.Stat(cc.API.VocabularyPath)
+               vd, err := os.ReadFile(cc.API.VocabularyPath)
                if err != nil {
                        if errors.Is(err, os.ErrNotExist) {
                                // If the vocabulary path doesn't exist, it might mean that
@@ -156,11 +156,6 @@ func (checkCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
                                // error.
                                continue
                        }
-                       fmt.Fprintf(stderr, "Error checking vocabulary path %q for cluster %s: %s\n", cc.API.VocabularyPath, id, err)
-                       return 1
-               }
-               vd, err := os.ReadFile(cc.API.VocabularyPath)
-               if err != nil {
                        fmt.Fprintf(stderr, "Error reading vocabulary file %q for cluster %s: %s\n", cc.API.VocabularyPath, id, err)
                        return 1
                }