mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 10:36:12 +00:00
Use drone/envsubst module for bash variable expansion
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/drone/envsubst"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
@@ -339,7 +340,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
||||
for _, download := range pkgInfo.Downloads {
|
||||
// Replace variables in download url
|
||||
downloadUrl := download.Url
|
||||
downloadUrl = os.Expand(downloadUrl, func(s string) string {
|
||||
downloadUrl, err := envsubst.Eval(downloadUrl, func(s string) string {
|
||||
switch s {
|
||||
case "BPM_PKG_VERSION":
|
||||
return pkgInfo.Version
|
||||
@@ -349,6 +350,9 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
||||
return ""
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch download.Type {
|
||||
case "", "file":
|
||||
@@ -420,7 +424,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
||||
case "git":
|
||||
// Replace variables in git branch
|
||||
gitBranch := download.GitBranch
|
||||
gitBranch = os.Expand(gitBranch, func(s string) string {
|
||||
gitBranch, err := envsubst.Eval(gitBranch, func(s string) string {
|
||||
switch s {
|
||||
case "BPM_PKG_VERSION":
|
||||
return pkgInfo.Version
|
||||
@@ -430,6 +434,9 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
||||
return ""
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "clone", "--depth=1", downloadUrl)
|
||||
if gitBranch != "" {
|
||||
@@ -442,7 +449,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
err := cmd.Run()
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ module git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
github.com/drone/envsubst v1.0.3
|
||||
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
github.com/drone/envsubst v1.0.3 h1:PCIBwNDYjs50AsLZPYdfhSATKaRg/FJmDc2D6+C2x8g=
|
||||
github.com/drone/envsubst v1.0.3/go.mod h1:N2jZmlMufstn1KEqvbHjw40h1KyTmnVzHcSc9bFiJ2g=
|
||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f h1:xt29M2T6STgldg+WEP51gGePQCsQvklmP2eIhPIBK3g=
|
||||
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f/go.mod h1:i4sF0l1fFnY1aiw08QQSwVAFxHEm311Me3WsU/X7nL0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
||||
Reference in New Issue
Block a user