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

warn user if either the client or server is out of date #401

Merged
merged 3 commits into from
Oct 6, 2021
Merged

Conversation

mxyng
Copy link
Collaborator

@mxyng mxyng commented Oct 5, 2021

  • Warn if either client or registry is not at the latest version
$ infra version
Your client (v0.2.4) is out of date. Please update to v0.2.5.

   Client: 0.2.4
 Registry: 0.2.5

  • Provide switches to return only client or only registry version
$ infra version

   Client: 0.0.0-development
 Registry: 0.0.0-development

$ infra version -c

 Client: 0.0.0-development

$ infra version -r

 Registry: 0.0.0-development

Implements #355

internal/cmd/version.go Outdated Show resolved Hide resolved
internal/cmd/version.go Outdated Show resolved Hide resolved
internal/cmd/version.go Outdated Show resolved Hide resolved
internal/cmd/version.go Outdated Show resolved Hide resolved
@mxyng mxyng changed the title warn if client version behind registry warn user if either the client or server is out of date Oct 6, 2021
- run: make release
env:
- run: |
echo $GITHUB_REF | cut -d/ -f3- | tee version
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a way to generate this in goreleaser so doing in bash instead. $GITHUB_REF is "The branch or tag ref that triggered the workflow." It has the format refs/tags/... so need to strip off the first two parts.

https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables

@@ -64,6 +64,17 @@ blobs:
ids:
- zip
- packages
extra_files:
- glob: version
- provider: s3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to create a link to point to latest so uploading another set explicitly called latest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! Will this correctly overwrite the entire folder on deploy? (i.e. making sure there won't be any dangling files in the next deploy?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good question. It's probably not smart enough to clear out the directory so the existing files will probably stick around. Having a latest release might not be necessary. Instead, should be able to publish a version file in the top level directory, e.g. infra

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this PR to publish the version in a latest file that will be published to releases.infrahq.com/infra/latest since we don't need a latest release link

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the file manually for now but this should publish it on the next version bump

.goreleaser.yml Outdated
@@ -64,6 +64,17 @@ blobs:
ids:
- zip
- packages
extra_files:
- glob: version
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publish the generated version alongside the archives and packages

return err
}

fmt.Fprintln(w, "Registry:\t", res.Version)
fmt.Fprintln(w)
if res.StatusCode >= 400 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could check for 200 but this covers much more cases

@mxyng
Copy link
Collaborator Author

mxyng commented Oct 6, 2021

Can add things like upgrade hints or only showing the update message once per new version but that can wait until next iteration.

@mxyng mxyng merged commit ef270a1 into main Oct 6, 2021
@mxyng mxyng deleted the version-check branch October 6, 2021 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants