Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-49373

Provide json and non-json version output

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Do
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.4.0-rc12
    • Component/s: None
    • Labels:
      None
    • Service Arch

      In 4.4, the version output changed from being plain text to being a mix of plain text and json.

      4.2 --version output:

      serene% /usr/local/m/versions/4.2/mongo --version
      
      MongoDB shell version v4.2.8
      
      git version: 43d25964249164d76d5e04dd6cf38f6111e21f5f
      
      OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
      
      allocator: tcmalloc
      
      modules: enterprise 
      
      build environment:
      
          distmod: debian10
      
          distarch: x86_64
      
          target_arch: x86_64
      

      4.4 --version output:

      serene% ~me/debs/mongo/devuan/4.4/mongo --version      
      
      MongoDB shell version v4.4.0-rc12
      
      Build Info: {
      
          "version": "4.4.0-rc12",
      
          "gitVersion": "4b96db94125b5e0ca1da0c91f09a5fca8c94d9ab",
      
          "openSSLVersion": "OpenSSL 1.1.1g  21 Apr 2020",
      
          "modules": [
      
              "enterprise"
      
          ],
      
          "allocator": "tcmalloc",
      
          "environment": {
      
              "distarch": "x86_64",
      
              "target_arch": "x86_64"
      
          }
      
      }
      

      While the 4.4 output can be read by humans and can, kind of, be read by machines, I think it is suboptimal for the following reasons:

      > mongo --version | sed -E 's/Build Info: |MongoDB shell.*//'

      Since the format is not documented, there is no guarantee this sed command will work in future versions.

      Additionally, having to perform text transforms on output is awkward.

      • The output is not directly machine-readable (i.e. the output of `mongo --version` cannot be simply piped to a json parser).

      I believe a better implementation would be to provide two version outputs:

      • One in plain text, essentially same as 4.2 output.
      • One in json, i.e. the current 4.4 output starting with the first {.

      The second output could be obtained via, say, --json-version switch.

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: