Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version CLI #259

Closed
jsimnz opened this issue Mar 1, 2022 · 5 comments · Fixed by #339
Closed

Version CLI #259

jsimnz opened this issue Mar 1, 2022 · 5 comments · Fixed by #339
Assignees
Labels
area/cli Related to the CLI binary feature New feature or request
Milestone

Comments

@jsimnz
Copy link
Member

jsimnz commented Mar 1, 2022

Need version subcommand on CLI

@jsimnz jsimnz added this to the DefraDB v0.3 milestone Mar 1, 2022
@shahzadlone shahzadlone self-assigned this Mar 8, 2022
@jsimnz jsimnz assigned orpheuslummis and unassigned shahzadlone Mar 10, 2022
@jsimnz jsimnz added area/cli Related to the CLI binary feature New feature or request labels Mar 10, 2022
@orpheuslummis
Copy link
Contributor

Just FYI:

https://go.dev/doc/go1.18#go-command

The go command now embeds version control information in binaries.

debug/buildinfo package

@orpheuslummis
Copy link
Contributor

will be done as part of #271

@shahzadlone
Copy link
Member

#339 resolves this however with a caveat:

The commit hash that is returned for the version probably shouldn't be hardcoded. Because the releasing tag commit (final commit) will not know it's own hash in advance to place in the commit (as commit hashes dependent on the time the commit happened at and who made the commit). The other approach might be to put the hash of one commit before the released tag.`

This would be resolved by @orpheuslummis, related note:

I want to add that I'll provide an update to the implementation as part the CLI overhaul I'm working on to include things like top-level version package to have default version information of potentially multiple components
Makefile -> git describe -> build tags defining defradb version variable
as part of the configuration overhaul i'm introducing a --no-color which will conditionally turn off the coloring, and an output global flag (text, json) to globally decide on the default output type used
I think the added color dependency looks fine - convenient, popular/supported, probably not heavy

@jsimnz
Copy link
Member Author

jsimnz commented Apr 18, 2022

Added a comment/review to the outstanding PR, I think if its going to be included in part with the CLI overhaul by orpheus, it should just all be done there.

Should use an "LDFlag" approach similar to Tendermint, found here:
https://github.com/tendermint/tendermint/blob/851c0dc4f3088723c724cb01c4877ee78c3d6ffc/version/version.go#L6
and
https://github.com/tendermint/tendermint/blob/851c0dc4f3088723c724cb01c4877ee78c3d6ffc/Makefile#L14

Which defines a dedicated version package, then using compiler build flags to set those variables via a makefile

@shahzadlone
Copy link
Member

Future implementation (ldflags) will be lead by @orpheuslummis (#349)

shahzadlone added a commit that referenced this issue Apr 20, 2022
Adds the ability to check DefraDB's latest release version.
Resolves #259 

```
Usage:
  defradb version [flags]

Flags:
  -f, --format string   The version's format can be one of: 'short', 'json'
```

Example [default]:
>> `defradb version`
```
DefraDB's Version Information:
  *   version tag  = 0.2.1
  *   build commit = e4328e0
  *   release date = 2022-03-07T00:12:07Z
```

Example [short flag]:
```
>> $ defradb version -f short

0.2.1
```

Example [json flag]:
```
>> $ defradb version --format json

{"tag":"0.2.1","commit":"e4328e0","date":"2022-03-07T00:12:07Z"}
```
shahzadlone added a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
Adds the ability to check DefraDB's latest release version.
Resolves sourcenetwork#259 

```
Usage:
  defradb version [flags]

Flags:
  -f, --format string   The version's format can be one of: 'short', 'json'
```

Example [default]:
>> `defradb version`
```
DefraDB's Version Information:
  *   version tag  = 0.2.1
  *   build commit = e4328e0
  *   release date = 2022-03-07T00:12:07Z
```

Example [short flag]:
```
>> $ defradb version -f short

0.2.1
```

Example [json flag]:
```
>> $ defradb version --format json

{"tag":"0.2.1","commit":"e4328e0","date":"2022-03-07T00:12:07Z"}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to the CLI binary feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants