diff options
author | Chris Akritidis <43294513+cakrit@users.noreply.github.com> | 2019-02-20 19:56:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-20 19:56:44 +0100 |
commit | 88c6daad7965c10797a7badde4cd6851d35647cd (patch) | |
tree | d836ef080df335fd49d3f2aa68675d3760165ab6 /web/api/formatters | |
parent | 8a0ce020550567e022b322a4199b1f1e1d6af90c (diff) |
Correct version check in UI (#5429)
* Correct version check in UI. Support stable and nightly release channel.
* Use github releases instead of latest versions, get nightlies from GCS
* Prevent cross-origin errors by using the google API
Diffstat (limited to 'web/api/formatters')
-rw-r--r-- | web/api/formatters/charts2json.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/web/api/formatters/charts2json.c b/web/api/formatters/charts2json.c index f60f7f5409..413f1a6d1f 100644 --- a/web/api/formatters/charts2json.c +++ b/web/api/formatters/charts2json.c @@ -4,6 +4,38 @@ // generate JSON for the /api/v1/charts API call +static inline const char* get_release_channel() { + static int use_stable = -1; + + if (use_stable == -1) { + char filename[FILENAME_MAX + 1]; + snprintfz(filename, FILENAME_MAX, "%s/.environment", netdata_configured_user_config_dir); + procfile *ff = procfile_open(filename, "=", PROCFILE_FLAG_DEFAULT); + if(!ff) { + use_stable=1; + } else { + procfile_set_quotes(ff, "'\""); + ff = procfile_readall(ff); + if(!ff) { + use_stable=1; + } else { + unsigned int i; + for(i = 0; i < procfile_lines(ff); i++) { + if (!procfile_linewords(ff, i)) continue; + + if (!strcmp(procfile_lineword(ff, i, 0), "RELEASE_CHANNEL") && !strcmp(procfile_lineword(ff, i, 1), "stable")) { + use_stable = 1; + break; + } + } + procfile_close(ff); + if (use_stable == -1) use_stable = 0; + } + } + } + return (use_stable)?"stable":"nightly"; +} + void charts2json(RRDHOST *host, BUFFER *wb) { static char *custom_dashboard_info_js_filename = NULL; size_t c, dimensions = 0, memory = 0, alarms = 0; @@ -17,6 +49,7 @@ void charts2json(RRDHOST *host, BUFFER *wb) { buffer_sprintf(wb, "{\n" "\t\"hostname\": \"%s\"" ",\n\t\"version\": \"%s\"" + ",\n\t\"release_channel\": \"%s\"" ",\n\t\"os\": \"%s\"" ",\n\t\"timezone\": \"%s\"" ",\n\t\"update_every\": %d" @@ -25,6 +58,7 @@ void charts2json(RRDHOST *host, BUFFER *wb) { ",\n\t\"charts\": {" , host->hostname , host->program_version + , get_release_channel() , host->os , host->timezone , host->rrd_update_every |