From 6132aabeda375d64d589689402a74a573b7ad9a6 Mon Sep 17 00:00:00 2001 From: Sven Sauleau Date: Fri, 2 Feb 2024 12:41:49 +0100 Subject: [PATCH] add PKG_PREFIX --- functions/check-pkg-updates/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions/check-pkg-updates/main.go b/functions/check-pkg-updates/main.go index 42aeea2..cac598f 100644 --- a/functions/check-pkg-updates/main.go +++ b/functions/check-pkg-updates/main.go @@ -23,6 +23,9 @@ var ( CF_ACCOUNT_ID = os.Getenv("CF_ACCOUNT_ID") PKG_AUTOUPDATE_SOURCE = os.Getenv("PKG_AUTOUPDATE_SOURCE") RESTRICT_PKGS = strings.Split(os.Getenv("RESTRICT_PKGS"), ",") + + // If specified, only update packages starting with this prefix. + PKG_PREFIX = os.Getenv("PKG_PREFIX") ) type APIPackage struct { @@ -73,7 +76,11 @@ func Invoke(w http.ResponseWriter, r *http.Request) { func isAllowed(pkg string) bool { if os.Getenv("RESTRICT_PKGS") == "" { - return true + if PKG_PREFIX == "" { + return true + } else { + return strings.HasPrefix(pkg, PKG_PREFIX) + } } for _, n := range RESTRICT_PKGS { if pkg == n {