diff --git a/README.md b/README.md index 4cfe6b8..b884fdf 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ The following inputs can be specified to override the default behavior - default: `false` * `pkgDir`: Path where archives (.deb and .rpm) reside - default: `./dist` +* `destPrefix`: Prefix of the destination s3 path for downloading the artifacts + - default: `infrastructure_agent/` ##### Supported `distros` diff --git a/linux/Dockerfile b/linux/Dockerfile index 36a9a43..4b3adc7 100644 --- a/linux/Dockerfile +++ b/linux/Dockerfile @@ -12,6 +12,8 @@ COPY helper*.sh rpm-repos/*.repo ./ ARG STAGING_REPO=false ENV STAGING_REPO=$STAGING_REPO +ARG DEST_PREFIX + # Run helper prepare. This adds the NR repo and installs the agent RUN ./helper.sh prepare @@ -41,4 +43,5 @@ RUN INTEGRATION=$INTEGRATION \ INSTALL_REPO=$INSTALL_REPO \ FAIL_REPO=$FAIL_REPO \ INSTALL_LOCAL=$INSTALL_LOCAL \ + DEST_PREFIX=$DEST_PREFIX \ ./helper.sh install diff --git a/linux/action.sh b/linux/action.sh index 43992de..25d7ef5 100755 --- a/linux/action.sh +++ b/linux/action.sh @@ -8,6 +8,7 @@ set -o pipefail [[ -n $DISTROS ]] || DISTROS="ubuntu:jammy ubuntu:focal ubuntu:bionic debian:bullseye debian:buster rockylinux:8 registry.suse.com/suse/sles12sp5:latest suse" [[ -n $PKGDIR ]] || PKGDIR="./dist" [[ -n $PACKAGE_LOCATION ]] || PACKAGE_LOCATION="local" +[[ -n $DEST_PREFIX ]] || DEST_PREFIX="infrastructure_agent/" # Strip leading v from TAG and REPO_VERSION if present TAG=${TAG/v/} @@ -125,6 +126,7 @@ function build_and_test() { --build-arg INSTALL_LOCAL="$install_local" \ --build-arg FAIL_REPO="$fail_repo" \ --build-arg STAGING_REPO="$STAGING_REPO" \ + --build-arg DEST_PREFIX="$DEST_PREFIX" \ "$dockerdir"; then echo "::endgroup::" echo "❌ Install for $dockertag failed" diff --git a/linux/action.yml b/linux/action.yml index 64056f3..5b8beca 100644 --- a/linux/action.yml +++ b/linux/action.yml @@ -41,6 +41,10 @@ inputs: description: 'Folder containing installer packages' required: false default: "" + destPrefix: + description: 'Prefix of the destination s3 path for downloading the artifacts' + required: false + default: "infrastructure_agent/" runs: using: "composite" @@ -58,3 +62,4 @@ runs: POST_INSTALL_EXTRA: ${{ inputs.postInstallExtra }} DISTROS: ${{ inputs.distros }} PKGDIR: ${{ inputs.pkgDir }} + DEST_PREFIX: ${{ inputs.destPrefix }} diff --git a/linux/helper_rockylinux.sh b/linux/helper_rockylinux.sh index 4d0c777..e238f8e 100755 --- a/linux/helper_rockylinux.sh +++ b/linux/helper_rockylinux.sh @@ -6,6 +6,18 @@ add_repo() { fi cp "newrelic-infra-rockylinux${env}.repo" /etc/yum.repos.d/newrelic-infra.repo + if [ "$STAGING_REPO" = "true" ]; then + if [ "$DEST_PREFIX" != "infrastructure_agent/"]; then + sed -i "s|baseurl=http://nr-downloads-ohai-staging\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/linux/yum/el/__VERSION__/x86_64|baseurl=http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}linux/yum/el/__VERSION__/x86_64|" /etc/yum.repos.d/newrelic-infra.repo + # sed -i "s|gpgkey=http://nr-downloads-ohai-staging\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/gpg/newrelic-infra\.gpg|gpgkey=http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}gpg/newrelic-infra.gpg|" /etc/yum.repos.d/newrelic-infra.repo + fi + else + if [ "$DEST_PREFIX" != "infrastructure_agent/"]; then + sed -i "s|baseurl=http://nr-downloads-main\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/linux/yum/el/__VERSION__/x86_64|baseurl=http://nr-downloads-main.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}linux/yum/el/__VERSION__/x86_64|" /etc/yum.repos.d/newrelic-infra.repo + # sed -i "s|gpgkey=http://nr-downloads-main\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/gpg/newrelic-infra.gpg|gpgkey=http://nr-downloads-main.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}gpg/newrelic-infra.gpg|" /etc/yum.repos.d/newrelic-infra.repo + fi + fi + # Get rockylinux version from docker tag, assuming it has a `:[0-9]` format version=${BASE_IMAGE##*:} sed -i "s/__VERSION__/$version/" /etc/yum.repos.d/newrelic-infra.repo diff --git a/linux/helper_suse.sh b/linux/helper_suse.sh index 5658808..cacfaaf 100755 --- a/linux/helper_suse.sh +++ b/linux/helper_suse.sh @@ -32,6 +32,17 @@ add_repo() { cp "newrelic-infra-suse${env}.repo" tmp.repo sed -e "s/__VERSION__/$VERSION_ID/g" tmp.repo > /etc/zypp/repos.d/newrelic-infra.repo + if [ "$STAGING_REPO" = "true" ]; then + if [ "$DEST_PREFIX" != "infrastructure_agent/"]; then + sed -i "s|baseurl=http://nr-downloads-ohai-staging\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/linux/zypp/sles/__VERSION__/x86_64|baseurl=http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}linux/zypp/sles/__VERSION__/x86_64|" /etc/zypp/repos.d/newrelic-infra.repo + # sed -i "s|gpgkey=http://download\.newrelic\.com/infrastructure_agent/gpg/newrelic-infra\.gpg|gpgkey=http://download.newrelic.com/${DEST_PREFIX}gpg/newrelic-infra.gpg|" /etc/zypp/repos.d/newrelic-infra.repo + fi + else + if [ "$DEST_PREFIX" != "infrastructure_agent/"]; then + sed -i "s|baseurl=http://nr-downloads-main\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/linux/zypp/sles/__VERSION__/x86_64|baseurl=http://nr-downloads-main.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}linux/zypp/sles/__VERSION__/x86_64|" /etc/zypp/repos.d/newrelic-infra.repo + # sed -i "s|gpgkey=http://nr-downloads-main\.s3-website-us-east-1\.amazonaws\.com/infrastructure_agent/gpg/newrelic-infra.gpg|gpgkey=http://nr-downloads-main.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}gpg/newrelic-infra.gpg|" /etc/zypp/repos.d/newrelic-infra.repo + fi + fi zypper --gpg-auto-import-keys ref } diff --git a/linux/helper_ubuntu.sh b/linux/helper_ubuntu.sh index a237e12..4dcfec3 100755 --- a/linux/helper_ubuntu.sh +++ b/linux/helper_ubuntu.sh @@ -9,8 +9,16 @@ add_repo() { apt update && apt -y install wget gnupg if [ "$STAGING_REPO" = "true" ]; then - repo="http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/infrastructure_agent/linux/apt" + echo "staginRepo is true" + if [ "$DEST_PREFIX" != "infrastructure_agent/" ]; then + echo "destPrefix is not infrastructure_agent/ it is $DEST_PREFIX" + repo="http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/${DEST_PREFIX}linux/apt" + else + echo "destPrefix is $DEST_PREFIX" + repo="http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/infrastructure_agent/linux/apt" + fi else + echo "staginRepo is false" repo="http://nr-downloads-main.s3-website-us-east-1.amazonaws.com/infrastructure_agent/linux/apt" fi