Commit aaef7180 authored by Jérome Perrin's avatar Jérome Perrin

Go modules and Grafana

See merge request nexedi/slapos!929
parents 414e79e6 60189013
...@@ -5,6 +5,7 @@ extends = ...@@ -5,6 +5,7 @@ extends =
../gcc/buildout.cfg ../gcc/buildout.cfg
../git/buildout.cfg ../git/buildout.cfg
../pkgconfig/buildout.cfg ../pkgconfig/buildout.cfg
./buildout.hash.cfg
parts = gowork go parts = gowork go
...@@ -102,6 +103,13 @@ environment-extra = ...@@ -102,6 +103,13 @@ environment-extra =
# [gowork] # [gowork]
# buildflags = -race # buildflags = -race
# #
# - If some environment variables are needed during the build, they can be
# added with environment option, e.g. this way:
#
# [gowork]
# environment =
# CGO_ENABLED = 1
# FOO = bar
# #
# Users can also add `install` field to [gowork] to request Go programs to be # Users can also add `install` field to [gowork] to request Go programs to be
# automatically installed, for example: # automatically installed, for example:
...@@ -142,6 +150,9 @@ cpkgpath = ...@@ -142,6 +150,9 @@ cpkgpath =
# by default don't `go install` anything # by default don't `go install` anything
install = install =
# empty key=value environment by default
environment =
# everything is done by dependent parts # everything is done by dependent parts
recipe = plone.recipe.command recipe = plone.recipe.command
command = : command = :
...@@ -151,10 +162,9 @@ env.sh = ${gowork-env.sh:output} ...@@ -151,10 +162,9 @@ env.sh = ${gowork-env.sh:output}
[gowork-env.sh] [gowork-env.sh]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/goenv.sh.in url = ${:_profile_base_location_}/${:filename}
output = ${gowork.dir:directory}/env.sh output = ${gowork.dir:directory}/env.sh
depends = ${gowork.dir:recipe} depends = ${gowork.dir:recipe}
md5sum = 6efdf5d63381c240c7d206d7939a63f7
[gowork.dir] [gowork.dir]
directory = ${buildout:directory}/go.work directory = ${buildout:directory}/go.work
...@@ -172,7 +182,8 @@ stop-on-error = true ...@@ -172,7 +182,8 @@ stop-on-error = true
# clients can put program list to install to gowork:install # clients can put program list to install to gowork:install
[gowork.goinstall] [gowork.goinstall]
recipe = plone.recipe.command recipe = plone.recipe.command
command = bash -c ". ${gowork:env.sh} && command = bash -c ". ${gowork:env.sh}
set -e
for x in $(echo -n '${gowork:install}' |tr '\n' ' '); do for x in $(echo -n '${gowork:install}' |tr '\n' ' '); do
case "\$x" in case "\$x" in
......
# THIS IS NOT A BUILDOUT FILE, despite purposedly using a compatible syntax.
# The only allowed lines here are (regexes):
# - "^#" comments, copied verbatim
# - "^[" section beginings, copied verbatim
# - lines containing an "=" sign which must fit in the following categorie.
# - "^\s*filename\s*=\s*path\s*$" where "path" is relative to this file
# Copied verbatim.
# - "^\s*hashtype\s*=.*" where "hashtype" is one of the values supported
# by the re-generation script.
# Re-generated.
# - other lines are copied verbatim
# Substitution (${...:...}), extension ([buildout] extends = ...) and
# section inheritance (< = ...) are NOT supported (but you should really
# not need these here).
[gowork-env.sh]
filename = goenv.sh.in
md5sum = f6d0fc24e3f08f27bc2bd85003ca5ec2
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
# Usage: env.sh [/path/to/env.sh] # Usage: env.sh [/path/to/env.sh]
# ---- 8< ---- (buildout substitution here) # ---- 8< ---- (buildout substitution here)
# extend environment
while read x ; do
k=$(echo $x | cut -d '=' -f 1 | sed -e 's/[[:space:]]*$//' )
v=$(echo $x | cut -d '=' -f 2- | sed -e 's/^[[:space:]]*//' )
if [ -n "$k" ]
then export $k="$v"
fi
done <<-EOF
${gowork:environment}
EOF
# PATH so that go & friends work out of the box # PATH so that go & friends work out of the box
export PATH=${gowork:golang}/bin:${git:location}/bin:${pkgconfig:location}/bin:${buildout:bin-directory}:${gcc:prefix}/bin:$PATH export PATH=${gowork:golang}/bin:${git:location}/bin:${pkgconfig:location}/bin:${buildout:bin-directory}:${gcc:prefix}/bin:$PATH
X=${gowork:directory} X=${gowork:directory}
......
# Code generated by gowork-snapshot; DO NOT EDIT.
# list of go git repositories to fetch
[gowork.goinstall]
depends_gitfetch =
${go_github.com_golang_dep:recipe}
${go_github.com_grafana_grafana:recipe}
${go_github.com_grafana_loki:recipe}
${go_github.com_influxdata_influxdb:recipe}
${go_github.com_influxdata_telegraf:recipe}
[go_github.com_golang_dep]
<= go-git-package
go.importpath = github.com/golang/dep
repository = https://github.com/golang/dep
revision = 1f7c19e5f5
[go_github.com_grafana_grafana]
<= go-git-package
go.importpath = github.com/grafana/grafana
repository = https://github.com/grafana/grafana
revision = v7.4.3-0-g010f20c1c8
[go_github.com_grafana_loki]
<= go-git-package
go.importpath = github.com/grafana/loki
repository = https://github.com/grafana/loki
revision = v2.1.0-188-g877f524c36
[go_github.com_influxdata_influxdb]
<= go-git-package
go.importpath = github.com/influxdata/influxdb
repository = https://github.com/influxdata/influxdb
revision = v1.8.4-0-gbc8ec4384e
[go_github.com_influxdata_telegraf]
<= go-git-package
go.importpath = github.com/influxdata/telegraf
repository = https://github.com/influxdata/telegraf
revision = v1.17.3-0-g24a552b90b
...@@ -8,7 +8,6 @@ extends = ...@@ -8,7 +8,6 @@ extends =
../../component/curl/buildout.cfg ../../component/curl/buildout.cfg
../../component/dash/buildout.cfg ../../component/dash/buildout.cfg
buildout.hash.cfg buildout.hash.cfg
gowork.cfg
versions = versions versions = versions
parts = parts =
...@@ -31,53 +30,62 @@ part = python3 ...@@ -31,53 +30,62 @@ part = python3
[yarn] [yarn]
<= yarn-1.22.10 <= yarn-1.22.10
[go_github.com_grafana_grafana]
<= go-git-package
go.importpath = github.com/grafana/grafana
repository = https://github.com/grafana/grafana
revision = v7.4.3-0-g010f20c1c8
[go_github.com_grafana_loki]
<= go-git-package
go.importpath = github.com/grafana/loki
repository = https://github.com/grafana/loki
revision = v2.1.0-188-g877f524c36
[go_github.com_influxdata_influxdb]
<= go-git-package
go.importpath = github.com/influxdata/influxdb
repository = https://github.com/influxdata/influxdb
revision = v1.8.4-0-gbc8ec4384e
[go_github.com_influxdata_telegraf]
<= go-git-package
go.importpath = github.com/influxdata/telegraf
repository = https://github.com/influxdata/telegraf
revision = v1.17.3-0-g24a552b90b
[gowork] [gowork]
# All the softwares installed in the go workspace have "non standard" installation
# methods, so we install them in specific parts with custom commands.
# They will be installed because they are dependencies of ${gowork.goinstall}
install = install =
${go_github.com_grafana_loki:location}:./cmd/loki
${go_github.com_grafana_loki:location}:./cmd/promtail
${go_github.com_influxdata_telegraf:location}:./cmd/...
${go_github.com_influxdata_influxdb:location}:./cmd/...
# use recent go
golang = ${golang1.16:location}
# disable cgo, to prevent loki/promtail from using go-systemd
environment =
CGO_ENABLED = 0
telegraf-bin = ${:bin}/telegraf telegraf-bin = ${:bin}/telegraf
influx-bin = ${:bin}/influx influx-bin = ${:bin}/influx
influxd-bin = ${:bin}/influxd influxd-bin = ${:bin}/influxd
grafana-bin = ${:bin}/grafana-server grafana-bin = ${:bin}/grafana-server
grafana-homepath = ${go_github.com_grafana_grafana:location} grafana-homepath = ${grafana:homepath}
loki-bin = ${:bin}/loki loki-bin = ${:bin}/loki
promtail-bin = ${:bin}/promtail promtail-bin = ${:bin}/promtail
# use recent go
golang = ${golang1.16:location}
[gowork.goinstall] [grafana]
command = : recipe = plone.recipe.command
depends = command = bash -c "
${influxdb-install:recipe} cd ${:homepath} &&
${telegraf-install:recipe} . ${gowork:env.sh} &&
${grafana-install:recipe} # Unlike the loki, grafana _needs_ CGO_ENABLED, so we override here
${loki-install:recipe} export CGO_ENABLED=1 &&
${promtail-install:recipe}
[influxdb-install]
<= gowork.goinstall
command = bash -c ". ${gowork:env.sh} && \
go install -v github.com/golang/dep/cmd/dep && \
cd ${gowork:directory}/src/github.com/influxdata/influxdb && \
go install ./..."
update-command =
[telegraf-install]
<= gowork.goinstall
command = bash -c ". ${gowork:env.sh} && \
go install -v github.com/golang/dep/cmd/dep && \
cd ${gowork:directory}/src/github.com/influxdata/telegraf && \
${make:location}/bin/make &&
cp telegraf ${gowork:bin}"
update-command =
[grafana-install]
<= gowork.goinstall
command = bash -c ". ${gowork:env.sh} && \
cd ${gowork:directory}/src/github.com/grafana/grafana && \
go run build.go setup && \ go run build.go setup && \
go run build.go build && \ go run build.go build && \
${yarn:location}/bin/yarn install --pure-lockfile && \ ${yarn:location}/bin/yarn install --pure-lockfile && \
...@@ -87,28 +95,8 @@ command = bash -c ". ${gowork:env.sh} && \ ...@@ -87,28 +95,8 @@ command = bash -c ". ${gowork:env.sh} && \
rm -rf ${buildout:directory}/.cache/Cypress/ && \ rm -rf ${buildout:directory}/.cache/Cypress/ && \
rm -rf ${buildout:directory}/.cache/yarn/ rm -rf ${buildout:directory}/.cache/yarn/
" "
update-command = homepath = ${go_github.com_grafana_grafana:location}
stop-on-error = true
[loki-install]
<= gowork.goinstall
# loki also uses nodejs
command = bash -c "export PATH=${nodejs:location}/bin/:$PATH && \
. ${gowork:env.sh} && \
go install -v github.com/golang/dep/cmd/dep && \
cd ${gowork:directory}/src/github.com/grafana/loki && \
go install ./cmd/loki"
update-command =
[promtail-install]
<= gowork.goinstall
# CGO_ENABLED is to disable systemd support (did not compile in my case)
command = bash -c "export CGO_ENABLED=0 && \
. ${gowork:env.sh} && \
go install -v github.com/golang/dep/cmd/dep && \
cd ${gowork:directory}/src/github.com/grafana/loki && \
go install ./cmd/promtail"
update-command =
[download-file-base] [download-file-base]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment