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.
|
||||
func handleInfo(w http.ResponseWriter, _ *http.Request) {
|
||||
infoPayloadOnce.Do(func() {
|
||||
infoPayload.Count = int(rosa.Native().Count())
|
||||
infoPayload.Count = len(rosa.Native().Collect())
|
||||
infoPayload.HakureiVersion = info.Version()
|
||||
})
|
||||
// TODO(mae): cache entire response if no additional fields are planned
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestAPIInfo(t *testing.T) {
|
||||
checkPayload(t, resp, struct {
|
||||
Count int `json:"count"`
|
||||
HakureiVersion string `json:"hakurei_version"`
|
||||
}{rosa.Native().Count(), info.Version()})
|
||||
}{len(rosa.Native().Collect()), info.Version()})
|
||||
}
|
||||
|
||||
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.Parallel()
|
||||
checkValidate(
|
||||
t, "limit=1&sort=0&index", 0, rosa.Native().Count()-1,
|
||||
"index must be an integer between 0 and "+strconv.Itoa(rosa.Native().Count()-1),
|
||||
t, "limit=1&sort=0&index", 0, count-1,
|
||||
"index must be an integer between 0 and "+strconv.Itoa(count-1),
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ func main() {
|
||||
}
|
||||
|
||||
done:
|
||||
for _, p := range rosa.Native().Collect() {
|
||||
for _, p := range rosa.Native().CollectAll() {
|
||||
select {
|
||||
case w <- p:
|
||||
break
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package kernel-source {
|
||||
description = "unpatched Linux kernel source tree";
|
||||
website = "https://kernel.org";
|
||||
exclude = true;
|
||||
|
||||
version* = "6.12.87";
|
||||
output = remoteTar {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package musl-source {
|
||||
description = "an implementation of the C standard library - source code";
|
||||
exclude = true;
|
||||
|
||||
version* = "1.2.6";
|
||||
output = remoteTar {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package stage0-dist {
|
||||
description = "Rosa OS stage0 bootstrap seed";
|
||||
exclude = true;
|
||||
|
||||
version* = "20260504";
|
||||
output = remoteTar {
|
||||
|
||||
@@ -384,14 +384,14 @@ func (s *S) mustRegister(
|
||||
})
|
||||
}
|
||||
|
||||
// Count returns the number of [Artifact] registered to s.
|
||||
func (s *S) Count() int {
|
||||
// count returns the number of [Artifact] registered to s.
|
||||
func (s *S) count() int {
|
||||
return int(s.artifactCount.Load())
|
||||
}
|
||||
|
||||
// Collect returns all [ArtifactH] registered to s.
|
||||
func (s *S) Collect() (handles P) {
|
||||
handles = make(P, 0, s.Count())
|
||||
// CollectAll returns all [ArtifactH] registered to s.
|
||||
func (s *S) CollectAll() (handles P) {
|
||||
handles = make(P, 0, s.count())
|
||||
s.artifacts.Range(func(key, _ any) bool {
|
||||
handles = append(handles, key.(ArtifactH))
|
||||
return true
|
||||
@@ -402,6 +402,23 @@ func (s *S) Collect() (handles P) {
|
||||
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.
|
||||
type deferredGit struct {
|
||||
url string
|
||||
@@ -915,6 +932,7 @@ func (ctx *evalContext) pf(
|
||||
k("description"): &meta.Description,
|
||||
k("website"): &meta.Website,
|
||||
k("version"): &meta.Version,
|
||||
k("exclude"): &meta.Exclude,
|
||||
k("anitya"): &anitya,
|
||||
k("latest"): &meta.latest,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user