Skip to content

Commit

Permalink
add PKG_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
xtuc committed Feb 2, 2024
1 parent 4a8ab76 commit 6132aab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion functions/check-pkg-updates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6132aab

Please sign in to comment.