remove latest.json and replace with api call to grafana.com

pull/80537/head
Ashley Harrison 2 years ago
parent 083605c17f
commit 02b867d84e
No known key found for this signature in database
GPG Key ID: AEC29E54E8D7CD90
  1. 16
      .drone.yml
  2. 1
      .github/CODEOWNERS
  3. 2
      conf/defaults.ini
  4. 2
      conf/sample.ini
  5. 27
      pkg/services/updatechecker/grafana.go
  6. 1
      scripts/drone/events/main.star
  7. 1
      scripts/drone/events/pr.star
  8. 1
      scripts/drone/pipelines/docs.star
  9. 1
      scripts/drone/pipelines/shellcheck.star
  10. 1
      scripts/drone/pipelines/trigger_downstream.star
  11. 1
      scripts/drone/rgm.star

@ -744,7 +744,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
type: docker type: docker
volumes: volumes:
- host: - host:
@ -1080,7 +1079,6 @@ trigger:
- '*.md' - '*.md'
- docs/** - docs/**
- packages/**/*.md - packages/**/*.md
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -1124,7 +1122,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
include: include:
- scripts/**/*.sh - scripts/**/*.sh
type: docker type: docker
@ -1436,7 +1433,6 @@ trigger:
- '*.md' - '*.md'
- docs/** - docs/**
- packages/**/*.md - packages/**/*.md
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -1493,7 +1489,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -1561,7 +1556,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -1640,7 +1634,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -1714,7 +1707,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -2114,7 +2106,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -2344,7 +2335,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -2399,7 +2389,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -2445,7 +2434,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana-security-mirror - grafana/grafana-security-mirror
type: docker type: docker
@ -2486,7 +2474,6 @@ trigger:
exclude: exclude:
- '*.md' - '*.md'
- docs/** - docs/**
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
status: status:
@ -2887,7 +2874,6 @@ trigger:
- '*.md' - '*.md'
- docs/** - docs/**
- packages/**/*.md - packages/**/*.md
- latest.json
repo: repo:
- grafana/grafana - grafana/grafana
type: docker type: docker
@ -4731,6 +4717,6 @@ kind: secret
name: gcr_credentials name: gcr_credentials
--- ---
kind: signature kind: signature
hmac: 0fb0bf8e3d7ea206f4e58a70ae01017d1e113a1241e78da7dd38d25f894ec04d hmac: e3875bd413d1eb9f9446b87eaee2d917d1548c4476e3047f09adc242ddf5868e
... ...

@ -361,7 +361,6 @@ lerna.json @grafana/frontend-ops
/.eslintrc @grafana/frontend-ops /.eslintrc @grafana/frontend-ops
/.vim @zoltanbedi /.vim @zoltanbedi
/jest.config.js @grafana/frontend-ops /jest.config.js @grafana/frontend-ops
/latest.json @grafana/frontend-ops
/metadata.md @grafana/plugins-platform /metadata.md @grafana/plugins-platform
/stylelint.config.js @grafana/frontend-ops /stylelint.config.js @grafana/frontend-ops
/tools/ @grafana/frontend-ops /tools/ @grafana/frontend-ops

@ -246,7 +246,7 @@ reporting_distributor = grafana-labs
# for new versions of grafana. The check is used # for new versions of grafana. The check is used
# in some UI views to notify that a grafana update exists. # in some UI views to notify that a grafana update exists.
# This option does not cause any auto updates, nor send any information # This option does not cause any auto updates, nor send any information
# only a GET request to https://raw.githubusercontent.com/grafana/grafana/main/latest.json to get the latest version. # only a GET request to https://grafana.com/api/grafana/versions/stable to get the latest version.
check_for_updates = true check_for_updates = true
# Set to false to disable all checks to https://grafana.com # Set to false to disable all checks to https://grafana.com

@ -253,7 +253,7 @@
# for new versions of grafana. The check is used # for new versions of grafana. The check is used
# in some UI views to notify that a grafana update exists. # in some UI views to notify that a grafana update exists.
# This option does not cause any auto updates, nor send any information # This option does not cause any auto updates, nor send any information
# only a GET request to https://raw.githubusercontent.com/grafana/grafana/main/latest.json to get the latest version. # only a GET request to https://grafana.com/api/grafana/versions/stable to get the latest version.
;check_for_updates = true ;check_for_updates = true
# Set to false to disable all checks to https://grafana.com # Set to false to disable all checks to https://grafana.com

@ -20,7 +20,7 @@ import (
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
) )
const grafanaLatestJSONURL = "https://raw.githubusercontent.com/grafana/grafana/main/latest.json" const grafanaStableVersionURL = "https://grafana.com/api/grafana/versions/stable"
type GrafanaService struct { type GrafanaService struct {
hasUpdate bool hasUpdate bool
@ -92,13 +92,13 @@ func (s *GrafanaService) instrumentedCheckForUpdates(ctx context.Context) {
func (s *GrafanaService) checkForUpdates(ctx context.Context) error { func (s *GrafanaService) checkForUpdates(ctx context.Context) error {
ctxLogger := s.log.FromContext(ctx) ctxLogger := s.log.FromContext(ctx)
ctxLogger.Debug("Checking for updates") ctxLogger.Debug("Checking for updates")
req, err := http.NewRequestWithContext(ctx, http.MethodGet, grafanaLatestJSONURL, nil) req, err := http.NewRequestWithContext(ctx, http.MethodGet, grafanaStableVersionURL, nil)
if err != nil { if err != nil {
return err return err
} }
resp, err := s.httpClient.Do(req) resp, err := s.httpClient.Do(req)
if err != nil { if err != nil {
return fmt.Errorf("failed to get latest.json repo from github.com: %w", err) return fmt.Errorf("failed to get stable version from grafana.com: %w", err)
} }
defer func() { defer func() {
if err := resp.Body.Close(); err != nil { if err := resp.Body.Close(); err != nil {
@ -107,27 +107,24 @@ func (s *GrafanaService) checkForUpdates(ctx context.Context) error {
}() }()
body, err := io.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("update check failed, reading response from github.com: %w", err) return fmt.Errorf("update check failed, reading response from grafana.com: %w", err)
} }
type latestJSON struct { type grafanaVersionJSON struct {
Stable string `json:"stable"` Version string `json:"version"`
Testing string `json:"testing"`
} }
var latest latestJSON var latest grafanaVersionJSON
err = json.Unmarshal(body, &latest) err = json.Unmarshal(body, &latest)
if err != nil { if err != nil {
return fmt.Errorf("failed to unmarshal latest.json: %w", err) return fmt.Errorf("failed to unmarshal response from grafana.com: %w", err)
} }
s.mutex.Lock() s.mutex.Lock()
defer s.mutex.Unlock() defer s.mutex.Unlock()
if strings.Contains(s.grafanaVersion, "-") { // only check for updates in stable versions
s.latestVersion = latest.Testing if !strings.Contains(s.grafanaVersion, "-") {
s.hasUpdate = !strings.HasPrefix(s.grafanaVersion, latest.Testing) s.latestVersion = latest.Version
} else { s.hasUpdate = latest.Version != s.grafanaVersion
s.latestVersion = latest.Stable
s.hasUpdate = latest.Stable != s.grafanaVersion
} }
currVersion, err1 := version.NewVersion(s.grafanaVersion) currVersion, err1 := version.NewVersion(s.grafanaVersion)

@ -55,7 +55,6 @@ trigger = {
"exclude": [ "exclude": [
"*.md", "*.md",
"docs/**", "docs/**",
"latest.json",
], ],
}, },
"repo": [ "repo": [

@ -62,7 +62,6 @@ trigger = {
"exclude": [ "exclude": [
"*.md", "*.md",
"docs/**", "docs/**",
"latest.json",
], ],
}, },
} }

@ -24,7 +24,6 @@ docs_paths = {
"*.md", "*.md",
"docs/**", "docs/**",
"packages/**/*.md", "packages/**/*.md",
"latest.json",
], ],
} }

@ -20,7 +20,6 @@ trigger = {
"exclude": [ "exclude": [
"*.md", "*.md",
"docs/**", "docs/**",
"latest.json",
], ],
"include": ["scripts/**/*.sh"], "include": ["scripts/**/*.sh"],
}, },

@ -20,7 +20,6 @@ trigger = {
"exclude": [ "exclude": [
"*.md", "*.md",
"docs/**", "docs/**",
"latest.json",
], ],
}, },
"repo": [ "repo": [

@ -55,7 +55,6 @@ docs_paths = {
"*.md", "*.md",
"docs/**", "docs/**",
"packages/**/*.md", "packages/**/*.md",
"latest.json",
], ],
} }

Loading…
Cancel
Save