MCPcopy Create free account
hub / github.com/rilldata/rill / LatestVersion

Method LatestVersion

cli/pkg/cmdutil/update.go:60–101  ·  view source on GitHub ↗

LatestVersion returns the latest available version of Rill (cached for up to 24 hours).

(ctx context.Context)

Source from the content-addressed store, hash-verified

58
59// LatestVersion returns the latest available version of Rill (cached for up to 24 hours).
60func (h *Helper) LatestVersion(ctx context.Context) (string, error) {
61 cachedVersion, err := h.DotRill.GetVersion()
62 if err != nil {
63 return "", err
64 }
65
66 cachedVersionUpdatedAt, err := h.DotRill.GetVersionUpdatedAt()
67 if err != nil {
68 return "", err
69 }
70
71 if cachedVersion != "" && cachedVersionUpdatedAt != "" {
72 updatedAt, err := time.Parse(time.RFC3339, cachedVersionUpdatedAt)
73 if err != nil {
74 // Set versionTs as empty if any parse errors
75 _ = h.DotRill.SetVersionUpdatedAt("")
76 return "", err
77 }
78
79 if time.Since(updatedAt) < versionCheckTTL {
80 return cachedVersion, nil
81 }
82 }
83
84 // Check with latest release on github if cached version is not available
85 info, err := fetchLatestVersion(ctx)
86 if err != nil {
87 return "", err
88 }
89
90 err = h.DotRill.SetVersionUpdatedAt(time.Now().Format(time.RFC3339))
91 if err != nil {
92 return "", err
93 }
94
95 err = h.DotRill.SetVersion(info.Version)
96 if err != nil {
97 return "", err
98 }
99
100 return info.Version, nil
101}
102
103// githubReleaseInfo represents information about a release.
104type githubReleaseInfo struct {

Callers 3

CheckVersionMethod · 0.95
GetVersionMethod · 0.80
versionHandlerMethod · 0.80

Calls 7

fetchLatestVersionFunction · 0.85
GetVersionUpdatedAtMethod · 0.80
ParseMethod · 0.80
SetVersionUpdatedAtMethod · 0.80
SetVersionMethod · 0.80
GetVersionMethod · 0.65
FormatMethod · 0.65

Tested by

no test coverage detected