diff --git a/exporters/powerdns/build-exporter-linux.sh b/exporters/powerdns/build-exporter-linux.sh index f9f1d22a..e92e1b21 100755 --- a/exporters/powerdns/build-exporter-linux.sh +++ b/exporters/powerdns/build-exporter-linux.sh @@ -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" "$@" diff --git a/exporters/powerdns/build-exporter-windows.sh b/exporters/powerdns/build-exporter-windows.sh old mode 100644 new mode 100755 index 9e95aaeb..da1b005f --- a/exporters/powerdns/build-exporter-windows.sh +++ b/exporters/powerdns/build-exporter-windows.sh @@ -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" "$@" diff --git a/exporters/powerdns/build-exporter.sh b/exporters/powerdns/build-exporter.sh new file mode 100755 index 00000000..daaedb10 --- /dev/null +++ b/exporters/powerdns/build-exporter.sh @@ -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 diff --git a/exporters/powerdns/exporter.yml b/exporters/powerdns/exporter.yml index 3f6aabd4..8bdddaba 100644 --- a/exporters/powerdns/exporter.yml +++ b/exporters/powerdns/exporter.yml @@ -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