internal/rosa: enforce exclusions
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m57s
Test / Hakurei (push) Successful in 3m48s
Test / ShareFS (push) Successful in 3m48s
Test / Sandbox (race detector) (push) Successful in 5m24s
Test / Hakurei (race detector) (push) Successful in 6m28s
Test / Flake checks (push) Successful in 1m24s
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m57s
Test / Hakurei (push) Successful in 3m48s
Test / ShareFS (push) Successful in 3m48s
Test / Sandbox (race detector) (push) Successful in 5m24s
Test / Hakurei (race detector) (push) Successful in 6m28s
Test / Flake checks (push) Successful in 1m24s
This restores unexported artifact behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -30,7 +30,7 @@ var (
|
|||||||
// handleInfo writes constant system information.
|
// handleInfo writes constant system information.
|
||||||
func handleInfo(w http.ResponseWriter, _ *http.Request) {
|
func handleInfo(w http.ResponseWriter, _ *http.Request) {
|
||||||
infoPayloadOnce.Do(func() {
|
infoPayloadOnce.Do(func() {
|
||||||
infoPayload.Count = int(rosa.Native().Count())
|
infoPayload.Count = len(rosa.Native().Collect())
|
||||||
infoPayload.HakureiVersion = info.Version()
|
infoPayload.HakureiVersion = info.Version()
|
||||||
})
|
})
|
||||||
// TODO(mae): cache entire response if no additional fields are planned
|
// TODO(mae): cache entire response if no additional fields are planned
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func TestAPIInfo(t *testing.T) {
|
|||||||
checkPayload(t, resp, struct {
|
checkPayload(t, resp, struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
HakureiVersion string `json:"hakurei_version"`
|
HakureiVersion string `json:"hakurei_version"`
|
||||||
}{rosa.Native().Count(), info.Version()})
|
}{len(rosa.Native().Collect()), info.Version()})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIGet(t *testing.T) {
|
func TestAPIGet(t *testing.T) {
|
||||||
@@ -92,11 +92,12 @@ func TestAPIGet(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
count := len(rosa.Native().Collect())
|
||||||
t.Run("index", func(t *testing.T) {
|
t.Run("index", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
checkValidate(
|
checkValidate(
|
||||||
t, "limit=1&sort=0&index", 0, rosa.Native().Count()-1,
|
t, "limit=1&sort=0&index", 0, count-1,
|
||||||
"index must be an integer between 0 and "+strconv.Itoa(rosa.Native().Count()-1),
|
"index must be an integer between 0 and "+strconv.Itoa(count-1),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
for _, p := range rosa.Native().Collect() {
|
for _, p := range rosa.Native().CollectAll() {
|
||||||
select {
|
select {
|
||||||
case w <- p:
|
case w <- p:
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package kernel-source {
|
package kernel-source {
|
||||||
description = "unpatched Linux kernel source tree";
|
description = "unpatched Linux kernel source tree";
|
||||||
website = "https://kernel.org";
|
website = "https://kernel.org";
|
||||||
|
exclude = true;
|
||||||
|
|
||||||
version* = "6.12.87";
|
version* = "6.12.87";
|
||||||
output = remoteTar {
|
output = remoteTar {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package musl-source {
|
package musl-source {
|
||||||
description = "an implementation of the C standard library - source code";
|
description = "an implementation of the C standard library - source code";
|
||||||
|
exclude = true;
|
||||||
|
|
||||||
version* = "1.2.6";
|
version* = "1.2.6";
|
||||||
output = remoteTar {
|
output = remoteTar {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package stage0-dist {
|
package stage0-dist {
|
||||||
description = "Rosa OS stage0 bootstrap seed";
|
description = "Rosa OS stage0 bootstrap seed";
|
||||||
|
exclude = true;
|
||||||
|
|
||||||
version* = "20260504";
|
version* = "20260504";
|
||||||
output = remoteTar {
|
output = remoteTar {
|
||||||
|
|||||||
@@ -384,14 +384,14 @@ func (s *S) mustRegister(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count returns the number of [Artifact] registered to s.
|
// count returns the number of [Artifact] registered to s.
|
||||||
func (s *S) Count() int {
|
func (s *S) count() int {
|
||||||
return int(s.artifactCount.Load())
|
return int(s.artifactCount.Load())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect returns all [ArtifactH] registered to s.
|
// CollectAll returns all [ArtifactH] registered to s.
|
||||||
func (s *S) Collect() (handles P) {
|
func (s *S) CollectAll() (handles P) {
|
||||||
handles = make(P, 0, s.Count())
|
handles = make(P, 0, s.count())
|
||||||
s.artifacts.Range(func(key, _ any) bool {
|
s.artifacts.Range(func(key, _ any) bool {
|
||||||
handles = append(handles, key.(ArtifactH))
|
handles = append(handles, key.(ArtifactH))
|
||||||
return true
|
return true
|
||||||
@@ -402,6 +402,23 @@ func (s *S) Collect() (handles P) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collect returns all non-excluded [ArtifactH] registered to s.
|
||||||
|
func (s *S) Collect() (handles P) {
|
||||||
|
handles = make(P, 0, s.count())
|
||||||
|
s.artifacts.Range(func(key, _ any) bool {
|
||||||
|
h := key.(ArtifactH)
|
||||||
|
meta, _ := s.Std().MustLoad(h)
|
||||||
|
if !meta.Exclude {
|
||||||
|
handles = append(handles, h)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
slices.SortFunc(handles, func(a, b ArtifactH) int {
|
||||||
|
return strings.Compare(a.String(), b.String())
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// deferredGit is a call to Toolchain.newTagRemote from azalea.
|
// deferredGit is a call to Toolchain.newTagRemote from azalea.
|
||||||
type deferredGit struct {
|
type deferredGit struct {
|
||||||
url string
|
url string
|
||||||
@@ -915,6 +932,7 @@ func (ctx *evalContext) pf(
|
|||||||
k("description"): &meta.Description,
|
k("description"): &meta.Description,
|
||||||
k("website"): &meta.Website,
|
k("website"): &meta.Website,
|
||||||
k("version"): &meta.Version,
|
k("version"): &meta.Version,
|
||||||
|
k("exclude"): &meta.Exclude,
|
||||||
k("anitya"): &anitya,
|
k("anitya"): &anitya,
|
||||||
k("latest"): &meta.latest,
|
k("latest"): &meta.latest,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user