Skip to content

Commit a9da2f8

Browse files
committed
implement environment variable overrides for user and token in WASM; enhance asset fetching with debug logging
1 parent 8f64b5b commit a9da2f8

File tree

6 files changed

+155
-87
lines changed

6 files changed

+155
-87
lines changed

handler/handler_execute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) {
7373
repo := q.Program
7474
release := q.Release
7575
//not cached - ask github
76-
log.Printf("fetching asset info for %s/%s@%s", user, repo, release)
7776
url := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases", user, repo)
7877
ghas := ghAssets{}
7978
if release == "" || release == "latest" {
@@ -216,6 +215,7 @@ func (h *Handler) getAssetsNoCache(q Query) (string, Assets, error) {
216215
indexKey := cAsset.Key()
217216
// and will only be selected if the exact match failed
218217
if _, exists := index[indexKey]; !exists {
218+
log.Printf("[DEBUG] Adding candidate asset: %s -> %s", cAsset.Name, indexKey)
219219
index[indexKey] = cAsset
220220
}
221221
}

handler/install.sh.qtpl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,22 @@ function install {
5858
GET="$GET -H 'Authorization: $AUTH'"
5959
fi
6060
#find OS #TODO BSDs and other posixs
61-
case `uname -s` in
62-
Darwin) OS="darwin";;
63-
Linux) OS="linux";;
61+
{% if len(r.OS) > 0 %}
62+
OS="{%s r.OS %}"
63+
echo "Override OS: $OS"
64+
{% else %}
65+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
66+
case "$OS" in
67+
darwin) OS="darwin";;
68+
linux) OS="linux";;
6469
*) fail "unknown os: $(uname -s)";;
6570
esac
71+
{% endif %}
6672
#find ARCH
73+
{% if len(r.Arch) > 0 %}
74+
ARCH="{%s r.Arch %}"
75+
echo "Override architecture: $ARCH"
76+
{% else %}
6777
if uname -m | grep -E '(arm|arch)64' > /dev/null; then
6878
ARCH="arm64"
6979
{% if !r.M1Asset %}
@@ -81,6 +91,7 @@ function install {
8191
else
8292
fail "unknown arch: $(uname -m)"
8393
fi
94+
{% endif %}
8495
#choose from asset list
8596
URL=""
8697
FTYPE=""

handler/install.sh.qtpl.go

Lines changed: 91 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

handler/strings.go

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,61 @@ import (
66

77
func getOS(s string) string {
88
s = strings.ToLower(s)
9+
var result string
910
switch {
1011
case osReDarwin.MatchString(s):
11-
return "darwin"
12+
result = "darwin"
1213
case osReDragonfly.MatchString(s):
13-
return "dragonfly"
14+
result = "dragonfly"
1415
case osReWindows.MatchString(s):
15-
return "windows"
16+
result = "windows"
1617
case osReMisc.MatchString(s):
1718
// return the first capturing group (contains only the alphanumeric characters)
18-
return osReMisc.FindStringSubmatch(s)[1]
19+
matches := osReMisc.FindStringSubmatch(s)
20+
if len(matches) > 1 {
21+
result = matches[1]
22+
}
1923
default:
20-
return ""
24+
result = ""
2125
}
26+
return result
2227
}
2328

2429
func getArch(s string) string {
2530
s = strings.ToLower(s)
31+
var result string
2632
switch {
2733
case archReLoong64.MatchString(s):
28-
return "loong64"
34+
result = "loong64"
2935
case archRePPC64.MatchString(s):
30-
return "ppc64"
36+
result = "ppc64"
3137
case archRePPC64LE.MatchString(s):
32-
return "ppc64le"
38+
result = "ppc64le"
3339
case archReRiscv64.MatchString(s):
34-
return "riscv64"
40+
result = "riscv64"
3541
case archReArm64.MatchString(s):
36-
return "arm64"
42+
result = "arm64"
3743
case archReAmd64.MatchString(s):
38-
return "amd64"
44+
result = "amd64"
3945
case archReArm.MatchString(s):
40-
return "arm"
46+
result = "arm"
4147
case archRe386.MatchString(s):
42-
return "386"
48+
result = "386"
4349
case archReMisc.MatchString(s):
44-
return archReMisc.FindStringSubmatch(s)[1]
45-
50+
matches := archReMisc.FindStringSubmatch(s)
51+
if len(matches) > 1 {
52+
result = matches[1]
53+
}
4654
// fuzz match 'x?64(bit)?'
4755
case fuzzArchAmd64.MatchString(s):
48-
return "amd64"
56+
result = "amd64"
4957
// fuzz match 'x?32(bit)?'
5058
case fuzzArch386.MatchString(s):
51-
return "386"
59+
result = "386"
5260
default:
53-
return ""
61+
result = ""
5462
}
63+
return result
5564
}
5665

5766
func getFileExt(s string) string {

0 commit comments

Comments
 (0)