Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-metrics/github-exporter/, app-metrics/github-exporter/files/
Date: Sat, 12 Jan 2019 00:49:17
Message-Id: 1547254101.afb543bed5d409f5ed2fd847a846ea702754b70a.williamh@gentoo
commit:     afb543bed5d409f5ed2fd847a846ea702754b70a
Author:     William Hubbs <william.hubbs <AT> sony <DOT> com>
AuthorDate: Sat Jan 12 00:41:56 2019 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Jan 12 00:48:21 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=afb543be

app-metrics/github-exporter: Export github statistics to prometheus

Copyright: Sony Interactive Entertainment Inc.
Package-Manager: Portage-2.3.51, Repoman-2.3.12
Signed-off-by: William Hubbs <williamh <AT> gentoo.org>

 app-metrics/github-exporter/Manifest               | 13 ++++
 .../github-exporter/files/github-exporter.confd    | 14 ++++
 .../github-exporter/files/github-exporter.initd    | 53 +++++++++++++++
 .../github-exporter/github-exporter-04.ebuild      | 75 ++++++++++++++++++++++
 app-metrics/github-exporter/metadata.xml           |  8 +++
 5 files changed, 163 insertions(+)

diff --git a/app-metrics/github-exporter/Manifest b/app-metrics/github-exporter/Manifest
new file mode 100644
index 00000000000..369d2e1e9b5
--- /dev/null
+++ b/app-metrics/github-exporter/Manifest
@@ -0,0 +1,13 @@
+DIST github-exporter-04.tar.gz 7023 BLAKE2B a2502fab29f7d987e7fe02a739d9d3bcc34376315581830033dc99d9c16be0bca52a30b8f491682de34ded4732c9216a05e8bfc1d2ac6510a22bd752a50bb5b9 SHA512 4837d78d058e8adb110ced899a9d136eed86aa3facf7258a6d7b392a3a61aa827662e63f8bd64b0ca44e6ed78518a6ae669068018ffc18d3bb42d19f4fb364be
+DIST github.com-beorn7-perks-3a771d9.tar.gz 10800 BLAKE2B 5487155a4d010af70b6ea2625d10ae03b6642507902d7dc168edb5d7cf0efa1777b248d0df34ed1a2564950b12613256c1c6ce1d8c9723cc34977ed883b21c8d SHA512 c6aa5df262ab607c0a5f64372fc2fec1ddda9e5624e9d9a22cdd1bc11822c99736d88bdf5e3fc6050217b5084548417cb2926c3940e156da9397d828d59ce277
+DIST github.com-fatih-structs-878a968.tar.gz 14629 BLAKE2B 673a25a39cab677bd275ccaf14675a1fa7847d1a089ceaa20cc981ca01a1cbba597e94467e7accdd1a4319acd44c5d7bd0f6e2de0eebd7fe2f43cc6cc9a94271 SHA512 3c00f10e17e6dd818422a6b8e1ef5454b3dd9cc78da22c56ec3c474bd7a590bb3dd56e803c01882b52ce12a6a4deda7935bbb786c3cebc2e60b379337a884752
+DIST github.com-golang-crypto-ff983b9.tar.gz 1645106 BLAKE2B 3d7271479ef812761a02c1d20429800cd29706e802a8ccf57e916bdb8befc87a9b1b1a88d42adb764a32fa5f4c5f5a5e434af63812a5bcd3de625658792a49a3 SHA512 19746e84901c0749da544ba02c74c8ccabfee5f186a0d00509e54f20c191da9ea56844de988265f072af1fae671d78d741a44f782b8c1704c9da0441436c2122
+DIST github.com-golang-protobuf-347cf4a.tar.gz 329489 BLAKE2B 828678cee603917e7f4efee2dd0902730a73932b94b12d4f4b35f0fcecaa329cdc39c3fa9926ce3706f86cc52c0aa4984f68ee0943ecc6d9571b0175ff671ab0 SHA512 de4307b91923a6890ab2f8eaf2ed4f7f32a45a4a0cc7b0d6f53ce31c5fe3ed08f378072075456d2c99c89a3b5acbca315814b8e5ec70e6ceb0ca62f7013f618c
+DIST github.com-golang-sys-48ac38b.tar.gz 1219195 BLAKE2B b632d935ed84ace8ddad5308556ddcfcca7b572fd1f65d8b5c39e9ba2b884c79f5c150cc3efa920654661b0958d894fa23445701dcd1d35f0f49ff4dda3bccd4 SHA512 8cea014c67df943dd68bb8787719acc0925f967f2cef552ae52c595ca4eda38adeab6c92b868822e08601cca20a61f16b78426d8b9252932168ffbd0f2403859
+DIST github.com-infinityworks-go-common-7f20a14.tar.gz 4072 BLAKE2B 79a788813840c8361e80ff882fff680ed83d3fe8485c09856290f0fa183438770210be600a3d6ae0d62e1a1027a43a6eef184d5a4b5f38fec9c15d54f16d384e SHA512 a8bc3d11eead090807bd7b64a71d7b078836e807b2a18ebb8e1b1ef286e920e993d3fe734eeafeccd80c8644b4c466a73b1cf479a4932c84e0e5fc328e50fdd2
+DIST github.com-matttproud-golang_protobuf_extensions-c182aff.tar.gz 37541 BLAKE2B f78899afa1390aca6cb1b412271713c60107771d512ead83482e0bb1716d175b791b4b04bd24b7f469cc1a29176eadcf0545ac3bf166c5b350602420d3c05aec SHA512 141b1b781a4d1c59f5eb1af93c966343b80ed405a5f63774e6cda9f12c34536e892c7a84699d6cf2e9c775457a4c2ad5d5d0b4d302fc25a923ab81d46ad65580
+DIST github.com-prometheus-client_golang-d2ead25.tar.gz 131949 BLAKE2B 352e0ef2bd704f6c490e57520d415e89d950241c39f3cdf851524d4cca87c25c31bf2ffb77914981cb730cb474033f4551b50c5b6085e5e273c2d29aaab1f012 SHA512 ca89d613e8bc6cff928d9ce8d3d563c8277cb31756c66d8c0e6f6b6ce00c1405d10e465245ac63fd6889aeafae0d6914814384e94e127929fbcfd606a59e42a5
+DIST github.com-prometheus-client_model-f287a10.tar.gz 57203 BLAKE2B 2d56b90ced967f5f7a2c59bb330aaf8c56cf522091ee413ff27c22cb9e7d656080bd7d4dd2372938a873617054c7c98925e10fdc7996b136eaa4fd1b6482b734 SHA512 b4f900e725a638a7131eee1c6ff5bf550025b4d9e5bb2dd09149e91ce02a7aba458039c2162b6a1f9a6b6c7c8fc0fc29510b6c752caad51282a960d18860f960
+DIST github.com-prometheus-common-2998b13.tar.gz 87368 BLAKE2B fc6c6e197d4cc61afefa9fb8e3a8d6b36ab029f62e3cf9adf8359e4885554f94427f17218d45c90c9d7f4a6985b2e4143a4d304d39f806bd70d2c6f05de29bc2 SHA512 b2095da96596fc500ece6b331cda2558f8c813720853f2489aee3dec65de95eb13f7b0853e3812433fdc040f16990d2f05b2a6b8b41275210c504ff333ca625d
+DIST github.com-prometheus-procfs-b1a0a9a.tar.gz 61720 BLAKE2B 2f9b25506527aaf6e1bf560a1b680b958d1281acbaa2bb896bfea50b5b7de8992d10e8e812f8ae449ab67145c88179c15afe1f719851d1717b28963071088082 SHA512 5938b4a8fa9a5ee32be995fed0d0e6b26941765470aca4eda63a7c42db457e83da43fde2f33b2d4ded3545e5643f607ec7060406b0a1b15e64cc732bb2badd4a
+DIST github.com-sirupsen-logrus-eef6b76.tar.gz 38613 BLAKE2B 32ff02d46dcdf08b273c406323236b0750433bda16a5072e4161b166863f5a062817166dc871e15fb169bfdb95ff45f167bc30b2e259294e0a51111b8a78afd3 SHA512 e7ca358b72bebbf663af426a110cd8da22bf33e2ec14fb7337af75a1cdd4aecb371436b8cc83f04a52a52ced56c02a762b12c2fe5ae5e64d7aee261a7254b14e

diff --git a/app-metrics/github-exporter/files/github-exporter.confd b/app-metrics/github-exporter/files/github-exporter.confd
new file mode 100644
index 00000000000..35368901c8f
--- /dev/null
+++ b/app-metrics/github-exporter/files/github-exporter.confd
@@ -0,0 +1,14 @@
+# settings for github-exporter
+
+# I will list the required variables here, but there are several more.
+# Please see the README for all of them.
+
+# LISTEN_PORT specifies the port the exporter will use. Below is the default.
+# LISTEN_PORT=9171
+
+# ORGS should contain a list of github organizations you wish to monitor.
+# ORGS="org1,org2"
+
+# REPOS should contain a list of github repos you want tomonitor.
+# If neither ORGS nor REPOS is set, the exporter will refuse to run.
+#  REPOS="user1/repo1,user2/repo2"

diff --git a/app-metrics/github-exporter/files/github-exporter.initd b/app-metrics/github-exporter/files/github-exporter.initd
new file mode 100644
index 00000000000..45ea133260a
--- /dev/null
+++ b/app-metrics/github-exporter/files/github-exporter.initd
@@ -0,0 +1,53 @@
+#!/sbin/openrc-run
+
+description="github exporter for Prometheus"
+command=/usr/bin/github-exporter
+command_background=yes
+command_user=${RC_SVCNAME}:${RC_SVCNAME}
+pidfile=/var/run/github-exporter.pid
+error_log="/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"
+output_log="/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"
+
+depend() {
+	after net
+}
+
+start_pre() {
+	local env_args
+	if [ -z "${ORGS}" ] && [ -z "${REPOS}" ]; then
+		eerror "ORGS and / or REPOS must be set."
+		return 1
+	fi
+	if [ -n "${GITHUB_TOKEN}" ] && [ -n "${GITHUB_TOKEN_FILE}" ]; then
+	eerror "Please set only one of GITHUB_TOKEN or GITHUB_TOKEN_FILE"
+	return 1
+	fi
+	if [ -n "${API_URL}" ]; then
+		env_args="${env_args} -e API_URL=${API_URL}"
+	fi
+	if [ -n "${GITHUB_TOKEN}" ]; then
+	env_args="${env_args} -e GITHUB_TOKEN=${GITHUB_TOKEN}"
+	elif [ -n "${GITHUB_TOKEN_FILE}" ]; then
+	env_args="${env_args} -e GITHUB_TOKEN_FILE=${GITHUB_TOKEN_FILE}"
+	fi
+	if [ -z "${LISTEN_PORT}" ]; then
+		env_args="${env_args} -e LISTEN_PORT=9171"
+	else
+		env_args="${env_args} -e LISTEN_PORT=${LISTEN_PORT}"
+	fi
+	if [ -n "${LOG_LEVEL}" ]; then
+	env_args="${env_args} -e LOG_LEVEL=${LOG_LEVEL}"
+	fi
+	if [ -n "${METRICS_PATH}" ]; then
+	env_args="${env_args} -e METRICS_PATH=${METRICS_PATH}"
+	fi
+	if [ -n "${ORGS}" ]; then
+		env_args="${env_args} -e ORGS=${ORGS}"
+	fi
+	if [ -n "${REPOS}" ]; then
+		env_args="${env_args} -e REPOS=${REPOS}"
+	fi
+	start_stop_daemon_args="${start_stop_daemon_args} ${env_args}"
+	supervise_daemon_args="${supervise_daemon_args} ${env_args}"
+	return 0
+}

diff --git a/app-metrics/github-exporter/github-exporter-04.ebuild b/app-metrics/github-exporter/github-exporter-04.ebuild
new file mode 100644
index 00000000000..6bc641ecb2f
--- /dev/null
+++ b/app-metrics/github-exporter/github-exporter-04.ebuild
@@ -0,0 +1,75 @@
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+EGO_PN=github.com/infinityworks/github-exporter
+
+EGO_VENDOR=(
+	"github.com/beorn7/perks 3a771d9"
+	"github.com/fatih/structs 878a968"
+	"github.com/golang/protobuf 347cf4a"
+	"github.com/infinityworks/go-common 7f20a14"
+	"github.com/matttproud/golang_protobuf_extensions  c182aff"
+	"github.com/prometheus/client_golang d2ead25"
+	"github.com/prometheus/client_model f287a10"
+	"github.com/prometheus/common 2998b13"
+	"github.com/prometheus/procfs b1a0a9a"
+	"github.com/sirupsen/logrus eef6b76"
+	"golang.org/x/crypto ff983b9 github.com/golang/crypto"
+	"golang.org/x/sys 48ac38b github.com/golang/sys"
+)
+
+inherit golang-build golang-vcs-snapshot systemd
+
+DESCRIPTION="Github statistics exporter for prometheus"
+HOMEPAGE="https://github.com/infinityworks/github-exporter"
+SRC_URI="https://${EGO_PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
+	${EGO_VENDOR_URI}"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64"
+
+RESTRICT="strip"
+
+pkg_setup() {
+	enewgroup ${PN}
+	enewuser ${PN} -1 -1 -1 ${PN}
+}
+
+src_prepare() {
+	default
+	sed -i -e 's/infinityworksltd/infinityworks/' \
+		"src/${EGO_PN}/main.go" \
+		"src/${EGO_PN}/config/config.go" \
+		"src/${EGO_PN}/exporter/structs.go" \
+		|| die "sed failed"
+	sed -i -e 's/Sirupsen/sirupsen/' \
+		"src/${EGO_PN}/main.go" \
+		"src/${EGO_PN}/config/config.go" \
+		"src/${EGO_PN}/exporter/gather.go" \
+		"src/${EGO_PN}/exporter/http.go" \
+		"src/${EGO_PN}/exporter/prometheus.go" \
+		|| die "sed failed"
+}
+
+src_compile() {
+	set -- env GOPATH="${S}" go build -v "${EGO_PN}"
+	echo "$@"
+	"$@" || die "build failed"
+}
+
+src_install() {
+	dobin ${PN}
+	cd "src/${EGO_PN}" || die
+dodoc *.md
+	newconfd "${FILESDIR}"/${PN}.confd ${PN}
+	newinitd "${FILESDIR}"/${PN}.initd ${PN}
+}
+
+pkg_postinst() {
+	if [[ -z "${REPLACING_VERSIONS}" ]]; then
+		elog "Before you can use ${PN}, you must configure it in"
+		elog "${EROOT}/etc/conf.d/${PN}"
+	fi
+}

diff --git a/app-metrics/github-exporter/metadata.xml b/app-metrics/github-exporter/metadata.xml
new file mode 100644
index 00000000000..c36c37139fa
--- /dev/null
+++ b/app-metrics/github-exporter/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>williamh@g.o</email>
+		<name>William Hubbs</name>
+	</maintainer>
+</pkgmetadata>