Skip to content

Commit

Permalink
Merge pull request #25 from Dynatrace/configure-technology-support
Browse files Browse the repository at this point in the history
Configure technology support
Solves #24
  • Loading branch information
arthfl authored Oct 22, 2024
2 parents 90d2520 + 26f2936 commit c2010be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The Dynatrace buildpack supports the following configurations:
| DT_TAGS | *Optional* - The tags you want to add to the monitored apps. |
| DT_NETWORK_ZONE | *Optional* - To look for communication endpoints located on the indicated region. |
| SKIP_ERRORS | *Optional* - If set to 1, app deployment won't fail on agent installer download errors |
| DT_TECHNOLOGY | *Optional* - Configure specific OneAgent codemodules. This will potentially decrease the required disk space a lot. Falls back to `all` when not set, therefore including all suported technologies. Supported values can be found on https://docs.dynatrace.com/docs/dynatrace-api/environment-api/deployment/oneagent/download-oneagent-version#parameters in the "include" row |


## License
Expand Down
26 changes: 15 additions & 11 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir> <env-dir>

set -e # fail fast
# set -x # enable debugging
set -e -o pipefail

# Configure directories
BUILD_DIR=$1
CACHE_DIR=$2
ENV_DIR=$3
BP_DIR=`cd $(dirname $0); cd ..; pwd`
BP_DIR="$(cd "$(dirname "$0")"; cd ..; pwd)"

PROFILE_PATH="$BUILD_DIR/.profile.d/dynatrace.sh"
EXPORT_PATH=/dev/null
Expand Down Expand Up @@ -39,15 +38,15 @@ downloadAgent() {
puts_error "Neither curl nor wget executable found!"
exit 1
fi

local RETRYTIMEOUT=0
local DOWNLOADERRORS=0
while [[ $DOWNLOADERRORS -lt 3 ]]; do
sleep $RETRYTIMEOUT

puts_step "Downloading OneAgent installer from ${DOWNLOADURL}"
$DOWNLOADCOMMAND --header "$DOWNLOADHEADER"

if [[ $? != 0 ]]; then
DOWNLOADERRORS=$((DOWNLOADERRORS+1))
RETRYTIMEOUT=$(($RETRYTIMEOUT+5))
Expand All @@ -70,7 +69,7 @@ downloadAgent() {
fi
}

export_env $ENV_DIR '^(DT_|SSL_MODE|SKIP_ERRORS|BUILDPACK_)' ''
export_env "$ENV_DIR" '^(DT_|SSL_MODE|SKIP_ERRORS|BUILDPACK_)' ''

# DT_TENANT and DT_API_TOKEN must be set
if [ -z "${DT_TENANT}" ] || [ -z "${DT_API_TOKEN}" ]; then
Expand All @@ -85,9 +84,14 @@ puts_verbose "ENV_DIR = $ENV_DIR"
# Creating directories# Ensure directories exists
mkdir -p "$BUILD_DIR/.profile.d"

if [[ ! -v DT_TECHNOLOGY ]]; then
puts_warn "No technology specified, falling back to 'all'"
DT_TECHNOLOGY="all"
fi

# Compile OneAgent Download URL
DT_API_URL="${DT_API_URL:-https://$DT_TENANT.live.dynatrace.com/api}"
DT_DOWNLOAD_URL="${DT_DOWNLOAD_URL:-$DT_API_URL/v1/deployment/installer/agent/unix/paas-sh/latest?&arch=x86}"
DT_DOWNLOAD_URL="${DT_DOWNLOAD_URL:-$DT_API_URL/v1/deployment/installer/agent/unix/paas-sh/latest?&arch=x86&include=${DT_TECHNOLOGY}}"
DT_DOWNLOAD_HEADER="Authorization: Api-Token ${DT_API_TOKEN}"

puts_verbose "DT_TENANT=$DT_TENANT"
Expand All @@ -112,11 +116,11 @@ puts_step "Configuring Dynatrace Oneagent..."
# determine default values for connection parameters
DT_MANIFEST="$BUILD_DIR/dynatrace/oneagent/manifest.json"

MANIFEST_TENANT=$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantUUID"])' <$DT_MANIFEST)
MANIFEST_TOKEN=$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantToken"])' <$DT_MANIFEST)
MANIFEST_ENDPOINTS=$(python3 -c 'import sys, json; print(";".join(json.load(sys.stdin)["communicationEndpoints"]))' <$DT_MANIFEST)
MANIFEST_TENANT="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantUUID"])' <$DT_MANIFEST)"
MANIFEST_TOKEN="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["tenantToken"])' <$DT_MANIFEST)"
MANIFEST_ENDPOINTS="$(python3 -c 'import sys, json; print(";".join(json.load(sys.stdin)["communicationEndpoints"]))' <$DT_MANIFEST)"

VERSION=$(python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])' <$DT_MANIFEST)
VERSION="$(python3 -c 'import json,sys; print(json.load(sys.stdin)["version"])' <$DT_MANIFEST)"

# support pipelined deployments by overriding default values
set_env "DT_TENANT" "\${DT_TENANT:-$MANIFEST_TENANT}"
Expand Down

0 comments on commit c2010be

Please sign in to comment.