Skip to content

Commit 5cc755d

Browse files
joelanfordanik120
authored andcommitted
another round of refactoring improvement
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
1 parent f4ed498 commit 5cc755d

File tree

4 files changed

+290
-207
lines changed

4 files changed

+290
-207
lines changed

catalogd/internal/serverutil/serverutil.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
ctrl "sigs.k8s.io/controller-runtime"
1515
"sigs.k8s.io/controller-runtime/pkg/certwatcher"
1616
"sigs.k8s.io/controller-runtime/pkg/log"
17+
"sigs.k8s.io/controller-runtime/pkg/manager"
1718

1819
catalogdmetrics "github.com/operator-framework/operator-controller/catalogd/internal/metrics"
1920
"github.com/operator-framework/operator-controller/catalogd/internal/storage"
@@ -53,7 +54,7 @@ func AddCatalogServerToManager(mgr ctrl.Manager, cfg CatalogServerConfig, tlsFil
5354
OnlyServeWhenLeader: true,
5455
Server: &http.Server{
5556
Addr: cfg.CatalogAddr,
56-
Handler: catalogdmetrics.AddMetricsToHandler(cfg.LocalStorage.StorageServerHandler()),
57+
Handler: handler,
5758
BaseContext: func(_ net.Listener) context.Context {
5859
return log.IntoContext(context.Background(), mgr.GetLogger().WithName("http.catalogs"))
5960
},

catalogd/internal/storage/index.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,20 @@ func (i index) Size() int64 {
5151
return int64(size)
5252
}
5353

54-
func (i index) Get(r io.ReaderAt, schema, packageName, name string) (io.Reader, bool) {
54+
func (i index) Get(r io.ReaderAt, schema, packageName, name string) (io.ReadSeeker, bool) {
5555
sectionSet := i.getSectionSet(schema, packageName, name)
5656

5757
sections := sectionSet.UnsortedList()
5858
slices.SortFunc(sections, func(a, b section) int {
5959
return cmp.Compare(a.offset, b.offset)
6060
})
6161

62-
srs := make([]io.Reader, 0, len(sections))
62+
srs := make([]io.ReadSeeker, 0, len(sections))
6363
for _, s := range sections {
6464
sr := io.NewSectionReader(r, s.offset, s.length)
6565
srs = append(srs, sr)
6666
}
67-
return io.MultiReader(srs...), true
67+
return newMultiReadSeeker(srs...), true
6868
}
6969

7070
func (i *index) getSectionSet(schema, packageName, name string) sets.Set[section] {

0 commit comments

Comments
 (0)