github.com/wolfi-dev/wolfictl@v0.16.11/pkg/configs/advisory/v2/index.go (about) 1 package v2 2 3 import ( 4 "context" 5 "io/fs" 6 7 "github.com/wolfi-dev/wolfictl/pkg/configs" 8 "github.com/wolfi-dev/wolfictl/pkg/configs/rwfs" 9 ) 10 11 func NewIndex(ctx context.Context, fsys rwfs.FS) (*configs.Index[Document], error) { 12 return configs.NewIndex[Document](ctx, fsys, newConfigurationDecodeFunc(fsys)) 13 } 14 15 func NewIndexFromPaths(ctx context.Context, fsys rwfs.FS, paths ...string) (*configs.Index[Document], error) { 16 return configs.NewIndexFromPaths[Document](ctx, fsys, newConfigurationDecodeFunc(fsys), paths...) 17 } 18 19 func newConfigurationDecodeFunc(fsys fs.FS) func(context.Context, string) (*Document, error) { 20 return func(_ context.Context, path string) (*Document, error) { 21 file, err := fsys.Open(path) 22 if err != nil { 23 return nil, err 24 } 25 26 return decodeDocument(file) 27 } 28 }