[SERVER-49373] Provide json and non-json version output Created: 08/Jul/20  Updated: 06/Dec/22  Resolved: 24/Feb/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.0-rc12
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Oleg Pudeyev (Inactive) Assignee: Backlog - Service Architecture
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Service Arch
Participants:

 Description   

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.



 Comments   
Comment by Lauren Lewis (Inactive) [ 24/Feb/22 ]

We haven’t heard back from you for at least one calendar year, so this issue is being closed. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Generated at Thu Feb 08 05:19:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.