From c0935bc4e6993746dccf87a38ffac337f1bd029b Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 23 Nov 2023 12:31:06 +0100 Subject: [PATCH 1/3] bump Fastly CLI version --- shopware/fastly-meta/6.4/bin/setup-fastly.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shopware/fastly-meta/6.4/bin/setup-fastly.sh b/shopware/fastly-meta/6.4/bin/setup-fastly.sh index b2f11392..3c27ce96 100755 --- a/shopware/fastly-meta/6.4/bin/setup-fastly.sh +++ b/shopware/fastly-meta/6.4/bin/setup-fastly.sh @@ -54,6 +54,7 @@ install_fastly_cli() { arch=$(uname -m) os="linux" + version="v10.6.4" if [[ "$arch" == "x86_64" ]]; then arch="amd64" @@ -65,7 +66,7 @@ install_fastly_cli() { echo "Detected OS: ${os} and architecture: ${arch}" - file="https://github.com/fastly/cli/releases/download/v2.0.0/fastly_v2.0.0_${os}-${arch}.tar.gz" + file="https://github.com/fastly/cli/releases/download/${version}/fastly_${version}_${os}-${arch}.tar.gz" echo "Downloading ${file}" From d12e93e7508b7480e628be8ee83fa937dfbf3df3 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 23 Nov 2023 13:39:57 +0100 Subject: [PATCH 2/3] Improved VCL snippets management --- shopware/fastly-meta/6.4/bin/setup-fastly.sh | 36 +++++++++++++++---- .../{deliver.vcl => deliver/default.vcl} | 0 .../fastly/{fetch.vcl => fetch/default.vcl} | 0 .../fastly/{hash.vcl => hash/default.vcl} | 0 .../fastly/{hit.vcl => hit/default.vcl} | 0 .../fastly/{recv.vcl => recv/default.vcl} | 0 6 files changed, 29 insertions(+), 7 deletions(-) rename shopware/fastly-meta/6.4/config/fastly/{deliver.vcl => deliver/default.vcl} (100%) rename shopware/fastly-meta/6.4/config/fastly/{fetch.vcl => fetch/default.vcl} (100%) rename shopware/fastly-meta/6.4/config/fastly/{hash.vcl => hash/default.vcl} (100%) rename shopware/fastly-meta/6.4/config/fastly/{hit.vcl => hit/default.vcl} (100%) rename shopware/fastly-meta/6.4/config/fastly/{recv.vcl => recv/default.vcl} (100%) diff --git a/shopware/fastly-meta/6.4/bin/setup-fastly.sh b/shopware/fastly-meta/6.4/bin/setup-fastly.sh index 3c27ce96..bada360a 100755 --- a/shopware/fastly-meta/6.4/bin/setup-fastly.sh +++ b/shopware/fastly-meta/6.4/bin/setup-fastly.sh @@ -79,9 +79,29 @@ install_fastly_cli # Fastly tries to write into /app on platformsh and this throws an error export HOME=/tmp -for vcl in ./config/fastly/*.vcl; do - trigger=$(basename $vcl .vcl) - name="shopware_${trigger}" +for sub in ./config/fastly/*; do + if ! find "$sub" -name '*.vcl' | grep . >/dev/null; then + # No VCL files in "$sub"; moving on to the next dir + continue + fi + for vcl in "$sub"/*.vcl; do + trigger=$(basename "$vcl" .vcl) + priority=$(echo "$trigger" | awk -F '.' '$2 ~ /^[0-9]+$/ { print $2 }') + if test -z "$priority"; then + priority="100" + else + trigger=$(basename "$trigger" ".$priority") + fi + vcl_type=$(basename "$sub") + + # For backward compatibility, default VCLs doesn't include trigger in their name + if [[ "$trigger" == "default" ]]; then + name="shopware_${vcl_type}" + else + name="shopware_${vcl_type}_${trigger}" + fi + + echo "Found VCL snippet $trigger of type $vcl_type with priority $priority" if fastly vcl snippet describe --version=active "--name=$name" > /dev/null; then # The snippet exists on remote @@ -92,21 +112,23 @@ for vcl in ./config/fastly/*.vcl; do remoteContentMd5=$(get_md5 "$remoteContent") if [[ "$localContentMd5" != "$remoteContentMd5" ]]; then - echo "Snippet ${trigger} has changed. Updating" + echo "Snippet ${name} has changed. Updating" create_version_if_not_done - fastly vcl snippet update "--name=shopware_${trigger}" "--content=${vcl}" "--type=${trigger}" --version=latest + fastly vcl snippet update "--name=$name" "--content=${vcl}" "--type=${vcl_type}" "--priority=${priority}" --version=latest else - echo "Snippet ${trigger} is up to date" + echo "Snippet ${name} is up to date" fi else create_version_if_not_done - fastly vcl snippet create "--name=shopware_${trigger}" "--content=${vcl}" "--type=${trigger}" --version=latest + fastly vcl snippet create "--name=shopware_${trigger}" "--content=${vcl}" "--type=${vcl_type}" "--priority=${priority}" --version=latest fi + done done + if [[ "$created_version" == "1" ]]; then echo "Activating latest version" diff --git a/shopware/fastly-meta/6.4/config/fastly/deliver.vcl b/shopware/fastly-meta/6.4/config/fastly/deliver/default.vcl similarity index 100% rename from shopware/fastly-meta/6.4/config/fastly/deliver.vcl rename to shopware/fastly-meta/6.4/config/fastly/deliver/default.vcl diff --git a/shopware/fastly-meta/6.4/config/fastly/fetch.vcl b/shopware/fastly-meta/6.4/config/fastly/fetch/default.vcl similarity index 100% rename from shopware/fastly-meta/6.4/config/fastly/fetch.vcl rename to shopware/fastly-meta/6.4/config/fastly/fetch/default.vcl diff --git a/shopware/fastly-meta/6.4/config/fastly/hash.vcl b/shopware/fastly-meta/6.4/config/fastly/hash/default.vcl similarity index 100% rename from shopware/fastly-meta/6.4/config/fastly/hash.vcl rename to shopware/fastly-meta/6.4/config/fastly/hash/default.vcl diff --git a/shopware/fastly-meta/6.4/config/fastly/hit.vcl b/shopware/fastly-meta/6.4/config/fastly/hit/default.vcl similarity index 100% rename from shopware/fastly-meta/6.4/config/fastly/hit.vcl rename to shopware/fastly-meta/6.4/config/fastly/hit/default.vcl diff --git a/shopware/fastly-meta/6.4/config/fastly/recv.vcl b/shopware/fastly-meta/6.4/config/fastly/recv/default.vcl similarity index 100% rename from shopware/fastly-meta/6.4/config/fastly/recv.vcl rename to shopware/fastly-meta/6.4/config/fastly/recv/default.vcl From 057fe4db2da3ffb9e87f3edb83ef096c99d822e2 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Thu, 23 Nov 2023 14:07:04 +0100 Subject: [PATCH 3/3] Fix snippet name during creation --- shopware/fastly-meta/6.4/bin/setup-fastly.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopware/fastly-meta/6.4/bin/setup-fastly.sh b/shopware/fastly-meta/6.4/bin/setup-fastly.sh index bada360a..2c2f627f 100755 --- a/shopware/fastly-meta/6.4/bin/setup-fastly.sh +++ b/shopware/fastly-meta/6.4/bin/setup-fastly.sh @@ -123,7 +123,7 @@ for sub in ./config/fastly/*; do else create_version_if_not_done - fastly vcl snippet create "--name=shopware_${trigger}" "--content=${vcl}" "--type=${vcl_type}" "--priority=${priority}" --version=latest + fastly vcl snippet create "--name=$name" "--content=${vcl}" "--type=${vcl_type}" "--priority=${priority}" --version=latest fi done done