Skip to content

Commit

Permalink
powerdns: use forked repo
Browse files Browse the repository at this point in the history
  • Loading branch information
kang-makes committed Aug 29, 2024
1 parent 145c0b8 commit e76f0b9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 61 deletions.
31 changes: 2 additions & 29 deletions exporters/powerdns/build-exporter-linux.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
#!/bin/bash

set -euo pipefail

# ###############################################################
# Integration variables
root_dir=$1
integration_dir="${root_dir}/exporters/powerdns"
integration_bin_dir="${integration_dir}/target/bin"

# ###############################################################
# Clone exporter
tmp_dir=$(mktemp -d)
git clone --no-checkout "${EXPORTER_REPO_URL}" "${tmp_dir}"
cd "${tmp_dir}"

if [[ -z "${EXPORTER_TAG}" ]]
then
git -c advice.detachedHead=false checkout "${EXPORTER_COMMIT}"
else
git checkout "${EXPORTER_TAG}" -d
fi

IFS=',' read -r -a goarchs <<< "$PACKAGE_LINUX_GOARCHS"
for goarch in "${goarchs[@]}"
do
echo "Build exporter Linux ${goarch}"
GOARCH=${goarch} make build
mkdir -p "${integration_bin_dir}/linux_${goarch}"
cp "${tmp_dir}/powerdns_exporter" "${integration_bin_dir}/linux_${goarch}/powerdns-exporter"
done
location=$(dirname "${BASH_SOURCE[0]}")
${location}/build-exporter.sh "linux" "$@"
32 changes: 2 additions & 30 deletions exporters/powerdns/build-exporter-windows.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,5 @@
# This script is not currently used as we are not packaging
# this integration for Windows. It is kept for testing purposes.

set -euo pipefail

# ###############################################################
# Integration variables
root_dir=$1
integration_dir="${root_dir}/exporters/powerdns"
integration_bin_dir="${integration_dir}/target/bin"

# ###############################################################
# Clone exporter
tmp_dir=$(mktemp -d)
git clone --no-checkout ${EXPORTER_REPO_URL} "${tmp_dir}"
cd "${tmp_dir}"

if [[ -z $EXPORTER_TAG ]]
then
git -c advice.detachedHead=false checkout ${EXPORTER_COMMIT}
else
git checkout ${EXPORTER_TAG} -d
fi

# ###############################################################
# Build exporter
make build

# ###############################################################
# Move binary to its final path to be copied from the next step
mkdir -p ${integration_bin_dir}

cp "${tmp_dir}/powerdns_exporter" "${integration_bin_dir}/powerdns-exporter"
location=$(dirname "${BASH_SOURCE[0]}")
${location}/build-exporter.sh "windows" "$@"
38 changes: 38 additions & 0 deletions exporters/powerdns/build-exporter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -euo pipefail

# ###############################################################
# Integration variables
os="$1"
root_dir="$2"
integration_dir="${root_dir}/exporters/powerdns"
integration_bin_dir="${integration_dir}/target/bin"
download_url="https://github.com/newrelic-forks/prometheus-powerdns_exporter/releases/download"

# ###############################################################
# Validate variables
if ! [ -z "$EXPORTER_COMMIT" ]; then
echo "This script does not support to build by commit anymore."
exit 1
fi

if [ -z "$EXPORTER_TAG" ]; then
echo "This script requires .exporter_tag to download the exporter."
exit 2
fi

if [ "$os" != "linux" ] && [ "$os" != "windows" ]; then
echo "os not supported: $os."
exit 3
fi

# ###############################################################
# Download the exporter
IFS=',' read -r -a goarchs <<< "$PACKAGE_LINUX_GOARCHS"
for goarch in "${goarchs[@]}"
do
echo "Downloading exporter for ${os} ${goarch}"
mkdir -p "${integration_bin_dir}/${os}_${goarch}"
curl -qsLo "${integration_bin_dir}/${os}_${goarch}/powerdns-exporter" "${download_url}/${EXPORTER_TAG}/prometheus-powerdns_exporter_${EXPORTER_TAG}_${os}_${goarch}"
done
4 changes: 2 additions & 2 deletions exporters/powerdns/exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ exporter_license_path: LICENSE
# URL to the git project hosting the exporter
exporter_repo_url: https://github.com/lotusnoir/prometheus-powerdns_exporter
# Tag of the exporter to checkout
exporter_tag:
exporter_tag: 0.3.0
# Commit of the exporter to checkout (used if tag property is empty)
exporter_commit: fffbd7c4768681f93988c2c3287b690db20e6ce0
exporter_commit:
# Changelog to add to the new release
exporter_changelog: https://github.com/lotusnoir/prometheus-powerdns_exporter/tags
# Enable packages for Linux
Expand Down

0 comments on commit e76f0b9

Please sign in to comment.