Skip to content

Commit 044d319

Browse files
authored
Enable UI for none auth (#70)
* Update golang and ruby used when testing. * Clean up panics, remove snake-case vars. * Support for ui when using none auth type. * Bump version to 1.1.0 --------- Signed-off-by: Gregory Schofield <greg.c.schofield@gmail.com>
1 parent b4c463f commit 044d319

11 files changed

Lines changed: 82 additions & 42 deletions

File tree

.github/workflows/build-and-release.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ on:
99
pull_request:
1010
branches: [ main ]
1111

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
1215

1316
env:
14-
GO_VERSION: 1.19.8
15-
RUBY_VERSION: 3.1.2
16-
BUNDLER_VERSION: 2.3.7
17+
GO_VERSION: 1.22.1
18+
RUBY_VERSION: 3.3.1
19+
BUNDLER_VERSION: 2.5.9
1720

1821
jobs:
1922
build:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.19
1+
FROM golang:1.22
22
LABEL org.opencontainers.image.source="https://github.com/gemfast/server"
33
WORKDIR /app
44

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ For more information see: https://gemfast.io/docs/configuration/
8080

8181
## UI
8282

83+
🚧 **The UI feature is currently under construction and is considered experimental** 🚧
84+
8385
![Dashboard UI](https://github.com/gemfast/server/raw/main/SCREENSHOT.png)
8486

8587
Gemfast includes a basic ui which is accessible from `my.server.url/ui`. For example, running it locally you can access it at `http://localhost:2020/ui`.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.1
1+
1.1.0

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/gemfast/server
22

3-
go 1.19
3+
go 1.22
4+
5+
toolchain go1.22.1
46

57
require (
68
github.com/akyoto/cache v1.0.6

go.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki
1313
github.com/akyoto/cache v1.0.6 h1:5XGVVYoi2i+DZLLPuVIXtsNIJ/qaAM16XT0LaBaXd2k=
1414
github.com/akyoto/cache v1.0.6/go.mod h1:WfxTRqKhfgAG71Xh6E3WLpjhBtZI37O53G4h5s+3iM4=
1515
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
16+
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
1617
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
1718
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
1819
github.com/appleboy/gin-jwt/v2 v2.8.0 h1:Glo7cb9eBR+hj8Y7WzgfkOlqCaNLjP+RV4dNO3fpdps=
@@ -26,6 +27,7 @@ github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce/go.mod
2627
github.com/aquasecurity/go-version v0.0.0-20201107203531-5e48ac5d022a h1:SMEtDBnLyP/EVOeJhj4yeR8GYPFpBsFBk3lSrpjZ8yI=
2728
github.com/aquasecurity/go-version v0.0.0-20201107203531-5e48ac5d022a/go.mod h1:9Beu8XsUNNfzml7WBf3QmyPToP1wm1Gj/Vc5UJKqTzU=
2829
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
30+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
2931
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
3032
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
3133
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
@@ -53,6 +55,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
5355
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5456
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5557
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU=
58+
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
5659
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
5760
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
5861
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
@@ -68,15 +71,18 @@ github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ
6871
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
6972
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
7073
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
74+
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
7175
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
7276
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
7377
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
7478
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
7579
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
80+
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
7681
github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
7782
github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY=
7883
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
7984
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
85+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
8086
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
8187
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
8288
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
@@ -87,6 +93,7 @@ github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn
8793
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
8894
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
8995
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
96+
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
9097
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
9198
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
9299
github.com/goccy/go-yaml v1.8.1 h1:JuZRFlqLM5cWF6A+waL8AKVuCcqvKOuhJtUQI+L3ez0=
@@ -132,10 +139,13 @@ github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8t
132139
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
133140
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
134141
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
142+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
135143
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
136144
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
137145
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
146+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
138147
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
148+
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
139149
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
140150
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
141151
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
@@ -161,6 +171,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
161171
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
162172
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
163173
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
174+
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
164175
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
165176
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=
166177
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
@@ -178,6 +189,7 @@ github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO
178189
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
179190
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
180191
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
192+
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
181193
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
182194
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
183195
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
@@ -269,6 +281,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
269281
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
270282
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
271283
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
284+
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
272285
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
273286
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
274287
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -302,6 +315,7 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
302315
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
303316
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
304317
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
318+
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
305319
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
306320
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
307321
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
@@ -331,6 +345,7 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh
331345
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
332346
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
333347
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
348+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
334349
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
335350
gopkg.in/go-playground/validator.v9 v9.30.0 h1:Wk0Z37oBmKj9/n+tPyBHZmeL19LaCoK3Qq48VwYENss=
336351
gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=

internal/api/api.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (api *API) Run() {
4949
if api.cfg.Mirrors[0].Enabled {
5050
log.Info().Str("detail", api.cfg.Mirrors[0].Upstream).Msg("mirroring upstream gem server")
5151
}
52-
log.Info().Str("detail", port).Msg("gemfast server listening on port")
52+
log.Info().Str("detail", fmt.Sprintf("http://localhost%s", port)).Msg("gemfast server started")
5353
err := api.router.Run(port)
5454
if err != nil {
5555
log.Fatal().Err(err).Msg("failed to start server")
@@ -86,7 +86,7 @@ func (api *API) registerRoutes() {
8686
case "local":
8787
api.configureLocalAuth()
8888
case "none":
89-
api.configureNoneAuth()
89+
api.configureNoneAuth(ui)
9090
default:
9191
log.Fatal().Msg(fmt.Sprintf("invalid auth type: %s", authMode))
9292
}
@@ -137,7 +137,7 @@ func (api *API) configureLocalAuth() {
137137
api.configurePrivate()
138138
}
139139

140-
func (api *API) configureNoneAuth() {
140+
func (api *API) configureNoneAuth(ui *ui.UI) {
141141
if api.cfg.Mirrors[0].Enabled {
142142
mirror := api.router.Group("/")
143143
api.configureMirror(mirror)
@@ -147,6 +147,12 @@ func (api *API) configureNoneAuth() {
147147
api.configurePrivateWrite(private)
148148
admin := api.router.Group(adminAPIPath)
149149
api.configureAdmin(admin)
150+
if !api.cfg.UIDisabled {
151+
api.router.StaticFS("/ui/assets", http.FS(ui.Assets))
152+
uiGroup := api.router.Group("/ui")
153+
api.configureUI(ui, uiGroup)
154+
log.Info().Str("detail", "/ui").Msg("gemfast ui enabled")
155+
}
150156
}
151157

152158
// /

internal/indexer/indexer.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,13 @@ func (indexer *Indexer) updateSpecsIndex(updated []*spec.Spec, src string, dest
397397
)
398398
if err != nil {
399399
log.Error().Err(err).Str("detail", dest).Msg("failed to create destination spec index file")
400-
panic(err)
401400
}
402401
defer file.Close()
403402

404403
dump := marshal.DumpSpecs(uniqSpecsIdx)
405404
bytesWritten, err := file.Write(dump)
406405
if err != nil {
407406
log.Error().Err(err).Str("detail", dest).Msg("failed to write destination spec index file")
408-
panic(err)
409407
}
410408
log.Info().Str("detail", src).Int("len", len(uniqSpecsIdx)).Msg("updated index")
411409
ch <- bytesWritten

internal/spec/spec.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type Spec struct {
3030
RubyGems string //TODO: parse required_rubygems_version from metadata
3131
}
3232

33-
func untar(dir, full_name, gemfile string) ([]byte, string, error) {
34-
tmpdir, err := os.MkdirTemp(dir, full_name)
33+
func untar(dir, fullName, gemfile string) ([]byte, string, error) {
34+
tmpdir, err := os.MkdirTemp(dir, fullName)
3535
if err != nil {
3636
log.Error().Err(err).Msg("failed to create tmpdir")
3737
return nil, "", err
@@ -62,7 +62,7 @@ func untar(dir, full_name, gemfile string) ([]byte, string, error) {
6262
if err == io.EOF {
6363
break
6464
}
65-
log.Error().Err(err).Str("detail", full_name).Msg("bad header")
65+
log.Error().Err(err).Str("detail", fullName).Msg("bad header")
6666
return nil, "", err
6767
}
6868

@@ -105,24 +105,24 @@ func untar(dir, full_name, gemfile string) ([]byte, string, error) {
105105
}
106106

107107
func GunzipMetadata(path string) (string, error) {
108-
fname := fmt.Sprintf("%s/metadata.gz", path)
109-
file, err := os.Open(fname)
108+
meta := fmt.Sprintf("%s/metadata.gz", path)
109+
file, err := os.Open(meta)
110110
if err != nil {
111-
log.Error().Err(err).Str("detail", fname).Msg("failed to open file")
111+
log.Error().Err(err).Str("detail", meta).Msg("failed to open file")
112112
return "", err
113113
}
114114
defer file.Close()
115115

116116
var fileReader io.ReadCloser = file
117117
gzreader, err := gzip.NewReader(fileReader)
118118
if err != nil {
119-
log.Error().Err(err).Str("detail", fname).Msg("failed to create gzip reader")
119+
log.Error().Err(err).Str("detail", meta).Msg("failed to create gzip reader")
120120
return "", err
121121
}
122122

123123
output, err := io.ReadAll(gzreader)
124124
if err != nil {
125-
log.Error().Err(err).Str("detail", fname).Msg("failed to read gzip content")
125+
log.Error().Err(err).Str("detail", meta).Msg("failed to read gzip content")
126126
return "", err
127127
}
128128

@@ -258,8 +258,8 @@ func ParseGemMetadata(yamlBytes []byte) (*GemMetadata, error) {
258258
}
259259

260260
func FromFile(dir, gemfile string) (*Spec, error) {
261-
path_chunks := strings.Split(gemfile, "/")
262-
full := path_chunks[len(path_chunks)-1]
261+
chunks := strings.Split(gemfile, "/")
262+
full := chunks[len(chunks)-1]
263263
ogName := strings.TrimSuffix(full, ".gem")
264264
log.Trace().Str("detail", gemfile).Msg("untarring gemfile")
265265
sum, tmpdir, err := untar(dir, full, gemfile)

internal/ui/templates/ui/index.tmpl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@
4141
<li class="nav-item">
4242
<a class="nav-link" href="#" hx-get="/ui/upload" hx-target="#content" hx-push-url="true">Upload</a>
4343
</li>
44+
{{ if eq .authType "github" }}
4445
<li class="nav-item">
4546
<a class="nav-link" href="#" hx-get="/ui/tokens" hx-target="#content" hx-push-url="true">API Tokens</a>
4647
</li>
47-
<li class="nav-item">
48-
<a class="nav-link" href="#" hx-get="/ui/license" hx-target="#content" hx-push-url="true">License</a>
49-
</li>
48+
{{ end }}
5049
</ul>
5150
<br>
5251
{{ if eq .authType "github" }}
@@ -77,7 +76,7 @@
7776
<li class="nav-item"><a href="https://gemfast.io" class="nav-link px-2 text-muted">Website</a></li>
7877
<li class="nav-item"><a href="https://gemfast.io/docs/installation/" class="nav-link px-2 text-muted">Documentation</a></li>
7978
</ul>
80-
<p class="text-center text-muted">© 2023 Gemfast</p>
79+
<p class="text-center text-muted">Built with <a href="https://htmx.org/">htmx</a></p>
8180
</footer>
8281
</div>
8382
</body>

0 commit comments

Comments
 (0)