Skip to content

Commit

Permalink
Merge pull request protobom#231 from jhoward-lm/backend-interface-update
Browse files Browse the repository at this point in the history
Revert StoreRetriever to only accept Document
  • Loading branch information
puerco authored May 30, 2024
2 parents f8cd372 + 6951a4d commit 066088a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
3 changes: 1 addition & 2 deletions pkg/reader/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/protobom/protobom/pkg/formats"
"github.com/protobom/protobom/pkg/native"
"github.com/protobom/protobom/pkg/sbom"
"github.com/protobom/protobom/pkg/storage"
)

Expand Down Expand Up @@ -70,7 +69,7 @@ func WithSniffer(s Sniffer) ReaderOption {
}
}

func WithStoreRetriever(sb storage.StoreRetriever[*sbom.Document]) ReaderOption {
func WithStoreRetriever(sb storage.StoreRetriever) ReaderOption {
return func(r *Reader) {
if sb != nil {
r.Storage = sb
Expand Down
2 changes: 1 addition & 1 deletion pkg/reader/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func GetFormatUnserializer(format formats.Format) (native.Unserializer, error) {

type Reader struct {
sniffer Sniffer
Storage storage.StoreRetriever[*sbom.Document]
Storage storage.StoreRetriever
Options *Options
}

Expand Down
28 changes: 10 additions & 18 deletions pkg/storage/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,23 @@

package storage

import (
"github.com/protobom/protobom/pkg/sbom"
)
import "github.com/protobom/protobom/pkg/sbom"

type (
ProtobomType interface {
*sbom.Document | *sbom.DocumentType | *sbom.Edge | *sbom.ExternalReference |
*sbom.Metadata | *sbom.Node | *sbom.NodeList | *sbom.Person | *sbom.Purpose | *sbom.Tool |
map[sbom.HashAlgorithm]string | map[sbom.SoftwareIdentifierType]string
}

Storer[T ProtobomType] interface {
Store(T, *StoreOptions) error
Storer interface {
Store(*sbom.Document, *StoreOptions) error
}

Retriever[T ProtobomType] interface {
Retrieve(string, *RetrieveOptions) (T, error)
Retriever interface {
Retrieve(string, *RetrieveOptions) (*sbom.Document, error)
}

StoreRetriever[T ProtobomType] interface {
Storer[T]
Retriever[T]
StoreRetriever interface {
Storer
Retriever
}

Backend[T ProtobomType] interface {
StoreRetriever[T]
Backend interface {
StoreRetriever
}
)
2 changes: 1 addition & 1 deletion pkg/storage/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sigs.k8s.io/release-utils/util"
)

var _ StoreRetriever[*sbom.Document] = (*FileSystem)(nil)
var _ StoreRetriever = (*FileSystem)(nil)

type FileSystemOptions struct {
// Path is the path top the directory where the storage
Expand Down
3 changes: 1 addition & 2 deletions pkg/writer/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/protobom/protobom/pkg/formats"
"github.com/protobom/protobom/pkg/native"
"github.com/protobom/protobom/pkg/sbom"
"github.com/protobom/protobom/pkg/storage"
)

Expand Down Expand Up @@ -39,7 +38,7 @@ func WithFormat(f formats.Format) WriterOption {
}
}

func WithStoreRetriever(sb storage.StoreRetriever[*sbom.Document]) WriterOption {
func WithStoreRetriever(sb storage.StoreRetriever) WriterOption {
return func(w *Writer) {
if sb != nil {
w.Storage = sb
Expand Down
2 changes: 1 addition & 1 deletion pkg/writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

type Writer struct {
Storage storage.StoreRetriever[*sbom.Document]
Storage storage.StoreRetriever
Options *Options
}

Expand Down

0 comments on commit 066088a

Please sign in to comment.