AGE-120: display message when new version available#54
Conversation
|
I created an alpha prerelease from this branch to test this out on the various platforms. Can get the binary via: curl -fsSL https://tiger-cli-releases.s3.amazonaws.com/install/install.sh | VERSION=v0.0.0-alpha.20 shmacoscurl
homebrew
linuxcurl
deb
rpm + dnfdocker run --rm -it -v ~/Downloads/tiger-cli-0.0.0.alpha.20-1.aarch64.rpm:/tmp/package.rpm rockylinux:9 bash -c "dnf install -y /tmp/package.rpm && tiger version --check"
rpm + yumdocker run --rm -it -v ~/Downloads/tiger-cli-0.0.0.alpha.20-1.aarch64.rpm:/tmp/package.rpm centos:7 bash -c "yum install -y /tmp/package.rpm && tiger version --check"
|
internal/tiger/cmd/config.go
Outdated
| table.Append("version_check_interval", fmt.Sprintf("%d seconds", *cfg.VersionCheckInterval)) | ||
| } | ||
| if cfg.VersionCheckLastTime != nil { | ||
| table.Append("version_check_last_time", time.Unix(int64(*cfg.VersionCheckLastTime), 0).Format(time.RFC1123)) |
| return fmt.Errorf("failed to load config: %w", err) | ||
| } | ||
|
|
||
| if err := logging.Init(cfg.Debug); err != nil { |
There was a problem hiding this comment.
I fixed this unrelated bug, where debug from the config file/env was not being used (only the cli flag worked)
scripts/install.sh
Outdated
| # Test that the binary is executable and get version | ||
| local installed_version | ||
| if installed_version=$("${binary_path}" version 2>/dev/null | head -n1 || echo ""); then | ||
| if installed_version=$("${binary_path}" version -o bare 2>/dev/null | head -n1 || echo ""); then |
cevian
left a comment
There was a problem hiding this comment.
Looks mostly good but I would like to see if we can use more of golang's time and interval types natively
| } | ||
|
|
||
| // DetectInstallMethod determines how Tiger CLI was installed | ||
| func detectInstallMethod(binaryPath string) InstallMethod { |
There was a problem hiding this comment.
dislike this but don't know if there is a better way. We could run tiger config set install_method deb and similar in post-install scripts. but that has its own complexity (which I think is better but wont inisist).
There was a problem hiding this comment.
The GitHub cli uses detection (similar to this), but they also only bother to detect homebrew.
I do think good detection logic is going to be more reliable than writing to the config file, which can easily be altered/reset. Either way, it is easy to think of ways to break it... we could bail on attempts to be helpful, and instead show a more generic "update according to your install method" message (or no message at all).
This is again a case of code written by Claude, that I tested and appears to work well. I'm not convinced that there is a good reason to rework it a different way.
internal/tiger/version/check.go
Outdated
| } | ||
| return "sudo yum update tiger-cli" | ||
| case InstallMethodInstallSh: | ||
| return "curl -fsSL https://tiger-cli-releases.s3.amazonaws.com/install/install.sh | sh" |
There was a problem hiding this comment.
will have to remember to replace when changing url (Not to self)
There was a problem hiding this comment.
This helps, but I think we'll also change the subpath
7b25e54
nathanjcochran
left a comment
There was a problem hiding this comment.
Didn't get far into reviewing, but left a couple minor comments about things I noticed.
Can continue reviewing tomorrow if Mat doesn't get to it first.
internal/tiger/cmd/config_test.go
Outdated
| "releases_url": "https://cli.tigerdata.com", | ||
| "version_check_interval": float64(3600000000000), // JSON unmarshals time.Duration as nanoseconds (1 hour = 3600000000000ns) |
There was a problem hiding this comment.
This test doesn't appear to check for the presence of version_check_last_time. Might be good to include (I think all of the other config options are included here 🤔). Same for the other tests below.
If the problem is that version_check_last_time is non-deterministic, we might want to stub out time.Now and mock it in these tests. That's usually done like this:
- Do this in the code itself, and call
now()instead oftime.Now()
var now = time.Now
- Do this to mock it in the tests (and don't forget to reset it when the test is finished, either via a
defercall or T.Cleanup):
now = func() time.Time {
return time.Date(2025, time.October, 14, 12, 0, 0, 0, time.UTC)
}
internal/tiger/cmd/version.go
Outdated
| }, | ||
| } | ||
|
|
||
| cmd.Flags().BoolVar(&checkVersion, "check", false, "Check for the latest version") |
There was a problem hiding this comment.
I still don't get why we don't just use the existing global. but don't feel too strongly
There was a problem hiding this comment.
This is to force a check, regardless of last check time. The global is --skip-update-check. Maybe you are thinking --skip-update-check=false? That doesn't quite seem clear enough to me, plus it is much more to type.








This pulls the latest release version number from the (configurable) S3 bucket url, compares it to the current version, and outputs a message when outdated. This is performed at most once per hour (also configurable), with the last check time stored in the config file.
We attempt to determine the installation method based on the current binary's path, and output a helpful message for how to upgrade as well (e.g.
brew upgrade tiger-cli).I made
tiger versionskip this implicit check, instead adding an explicittiger version --checkthat forces checking (regardless of last check time).Finally, I also implemented some
--outputoptions for theversioncommand, to conform to table formatting by default, withjson,yaml, andbare(only the version number) to making parsing for scripting tasks easier.Includes the new version when

--checkis used-o barewill be easiest to just capture the version number