Documentation ¶
Overview ¶
Package to export utility functions used in testing for use by other projects.
Index ¶
- Constants
- func CreateSourceString(user, password, host, dbName, SSLMode string) string
- func DoTestStorage(t *testing.T, ...)
- func RegisterDefaultStorageTypeProviders() error
- func RegisterStorageTypeProvider(storageType string, ...) error
- func TestNote(pID string) *pb.Note
- func TestOccurrence(pID, noteName string) *pb.Occurrence
- type EmbeddedStore
- func (m *EmbeddedStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*pb.Note) ([]*pb.Note, []error)
- func (m *EmbeddedStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*pb.Occurrence) ([]*pb.Occurrence, []error)
- func (m *EmbeddedStore) CreateNote(ctx context.Context, pID, nID, uID string, n *pb.Note) (*pb.Note, error)
- func (m *EmbeddedStore) CreateOccurrence(ctx context.Context, pID, uID string, o *pb.Occurrence) (*pb.Occurrence, error)
- func (m *EmbeddedStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)
- func (m *EmbeddedStore) DeleteNote(ctx context.Context, pID, nID string) error
- func (m *EmbeddedStore) DeleteOccurrence(ctx context.Context, pID, oID string) error
- func (m *EmbeddedStore) DeleteProject(ctx context.Context, pID string) error
- func (m *EmbeddedStore) GetNote(ctx context.Context, pID, nID string) (*pb.Note, error)
- func (m *EmbeddedStore) GetOccurrence(ctx context.Context, pID, oID string) (*pb.Occurrence, error)
- func (m *EmbeddedStore) GetOccurrenceNote(ctx context.Context, pID, oID string) (*pb.Note, error)
- func (m *EmbeddedStore) GetProject(ctx context.Context, pID string) (*prpb.Project, error)
- func (m *EmbeddedStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*pb.VulnerabilityOccurrencesSummary, error)
- func (m *EmbeddedStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
- func (m *EmbeddedStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Note, string, error)
- func (m *EmbeddedStore) ListOccurrences(ctx context.Context, pID, filters, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
- func (m *EmbeddedStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)
- func (m *EmbeddedStore) UpdateNote(ctx context.Context, pID, nID string, n *pb.Note, mask *fieldmaskpb.FieldMask) (*pb.Note, error)
- func (m *EmbeddedStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *pb.Occurrence, ...) (*pb.Occurrence, error)
- type Gs
- type MemStore
- func (m *MemStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*gpb.Note) ([]*gpb.Note, []error)
- func (m *MemStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*gpb.Occurrence) ([]*gpb.Occurrence, []error)
- func (m *MemStore) CreateNote(ctx context.Context, pID, nID, uID string, n *gpb.Note) (*gpb.Note, error)
- func (m *MemStore) CreateOccurrence(ctx context.Context, pID, uID string, o *gpb.Occurrence) (*gpb.Occurrence, error)
- func (m *MemStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)
- func (m *MemStore) DeleteNote(ctx context.Context, pID, nID string) error
- func (m *MemStore) DeleteOccurrence(ctx context.Context, pID, oID string) error
- func (m *MemStore) DeleteProject(ctx context.Context, pID string) error
- func (m *MemStore) GetNote(ctx context.Context, pID, nID string) (*gpb.Note, error)
- func (m *MemStore) GetOccurrence(ctx context.Context, pID, oID string) (*gpb.Occurrence, error)
- func (m *MemStore) GetOccurrenceNote(ctx context.Context, pID, oID string) (*gpb.Note, error)
- func (m *MemStore) GetProject(ctx context.Context, pID string) (*prpb.Project, error)
- func (m *MemStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*gpb.VulnerabilityOccurrencesSummary, error)
- func (m *MemStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*gpb.Occurrence, string, error)
- func (m *MemStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*gpb.Note, string, error)
- func (m *MemStore) ListOccurrences(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*gpb.Occurrence, string, error)
- func (m *MemStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)
- func (m *MemStore) UpdateNote(ctx context.Context, pID, nID string, n *gpb.Note, mask *fieldmaskpb.FieldMask) (*gpb.Note, error)
- func (m *MemStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *gpb.Occurrence, ...) (*gpb.Occurrence, error)
- type PgSQLStore
- func (pg *PgSQLStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*pb.Note) ([]*pb.Note, []error)
- func (pg *PgSQLStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*pb.Occurrence) ([]*pb.Occurrence, []error)
- func (pg *PgSQLStore) CreateNote(ctx context.Context, pID, nID, uID string, n *pb.Note) (*pb.Note, error)
- func (pg *PgSQLStore) CreateOccurrence(ctx context.Context, pID, uID string, o *pb.Occurrence) (*pb.Occurrence, error)
- func (pg *PgSQLStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)
- func (pg *PgSQLStore) DeleteNote(ctx context.Context, pID, nID string) error
- func (pg *PgSQLStore) DeleteOccurrence(ctx context.Context, pID, oID string) error
- func (pg *PgSQLStore) DeleteProject(ctx context.Context, pID string) error
- func (pg *PgSQLStore) GetNote(ctx context.Context, pID, nID string) (*pb.Note, error)
- func (pg *PgSQLStore) GetOccurrence(ctx context.Context, pID, oID string) (*pb.Occurrence, error)
- func (pg *PgSQLStore) GetOccurrenceNote(ctx context.Context, pID, oID string) (*pb.Note, error)
- func (pg *PgSQLStore) GetProject(ctx context.Context, pID string) (*prpb.Project, error)
- func (pg *PgSQLStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*pb.VulnerabilityOccurrencesSummary, error)
- func (pg *PgSQLStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
- func (pg *PgSQLStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Note, string, error)
- func (pg *PgSQLStore) ListOccurrences(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
- func (pg *PgSQLStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)
- func (pg *PgSQLStore) UpdateNote(ctx context.Context, pID, nID string, n *pb.Note, mask *fieldmaskpb.FieldMask) (*pb.Note, error)
- func (pg *PgSQLStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *pb.Occurrence, ...) (*pb.Occurrence, error)
- type Ps
- type Storage
Constants ¶
const (
TestNoteID = "CVE-1999-0710"
)
Variables ¶
This section is empty.
Functions ¶
func CreateSourceString ¶
CreateSourceString generates DB source path.
func DoTestStorage ¶ added in v0.1.2
func DoTestStorage(t *testing.T, createStore func(t *testing.T) (grafeas.Storage, project.Storage, func()))
Tests implementations of grafeas.Storage and project.Storage createStore is a function that creates new grafeas.Storage and project.Storage instances and a corresponding cleanUp function that will be run at the end of each test case. TODO: add testing for CreateTime and UpdateTime
func RegisterDefaultStorageTypeProviders ¶ added in v0.1.2
func RegisterDefaultStorageTypeProviders() error
RegisterDefaultStorageTypeProviders adds support for memstore, embedded and Postgres storage types TODO(#341) remove support for Postgres and move to a separate Register...() implementation in a separate project
func RegisterStorageTypeProvider ¶ added in v0.1.2
func RegisterStorageTypeProvider(storageType string, provider func(storageType string, storageConfig *config.StorageConfiguration) (*Storage, error)) error
RegisterStorageTypeProvider registers a new provider to create a specific type of Storage
func TestOccurrence ¶
func TestOccurrence(pID, noteName string) *pb.Occurrence
Types ¶
type EmbeddedStore ¶
type EmbeddedStore struct {
// contains filtered or unexported fields
}
EmbeddedStore is a storage solution for Grafeas based on boltdb
func NewEmbeddedStore ¶
func NewEmbeddedStore(config *config.EmbeddedStoreConfig) *EmbeddedStore
NewEmbeddedStore creates a embeddedS store with initialized filesystem
func (*EmbeddedStore) BatchCreateNotes ¶
func (m *EmbeddedStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*pb.Note) ([]*pb.Note, []error)
BatchCreateNotes batch creates the specified notes in embedded store.
func (*EmbeddedStore) BatchCreateOccurrences ¶
func (m *EmbeddedStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*pb.Occurrence) ([]*pb.Occurrence, []error)
BatchCreateOccurrence batch creates the specified occurrences in embedded store.
func (*EmbeddedStore) CreateNote ¶
func (m *EmbeddedStore) CreateNote(ctx context.Context, pID, nID, uID string, n *pb.Note) (*pb.Note, error)
CreateNote creates the specified note in embedded store.
func (*EmbeddedStore) CreateOccurrence ¶
func (m *EmbeddedStore) CreateOccurrence(ctx context.Context, pID, uID string, o *pb.Occurrence) (*pb.Occurrence, error)
CreateOccurrence creates the specified occurrence in embedded store.
func (*EmbeddedStore) CreateProject ¶
func (m *EmbeddedStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)
CreateProject creates the specified project in embedded store.
func (*EmbeddedStore) DeleteNote ¶
func (m *EmbeddedStore) DeleteNote(ctx context.Context, pID, nID string) error
DeleteNote deletes the specified note in embedded store.
func (*EmbeddedStore) DeleteOccurrence ¶
func (m *EmbeddedStore) DeleteOccurrence(ctx context.Context, pID, oID string) error
DeleteOccurrence deletes the specified occurrence in embedded store.
func (*EmbeddedStore) DeleteProject ¶
func (m *EmbeddedStore) DeleteProject(ctx context.Context, pID string) error
DeleteProject deletes the specified project from embedded store.
func (*EmbeddedStore) GetOccurrence ¶
func (m *EmbeddedStore) GetOccurrence(ctx context.Context, pID, oID string) (*pb.Occurrence, error)
GetOccurrence gets the specified occurrence from embedded store.
func (*EmbeddedStore) GetOccurrenceNote ¶
GetOccurrenceNote gets the note for the specified occurrence from embedded store.
func (*EmbeddedStore) GetProject ¶
GetProject gets the specified project from embedded store.
func (*EmbeddedStore) GetVulnerabilityOccurrencesSummary ¶
func (m *EmbeddedStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*pb.VulnerabilityOccurrencesSummary, error)
GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.
func (*EmbeddedStore) ListNoteOccurrences ¶
func (m *EmbeddedStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
ListNoteOccurrences returns up to pageSize number of occurrences on the note for the project beginning at pageToken, or from start if pageToken is empty.
func (*EmbeddedStore) ListNotes ¶
func (m *EmbeddedStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Note, string, error)
ListNotes returns up to pageSize number of notes for the project beginning at pageToken, or from start if pageToken is the empty string.
func (*EmbeddedStore) ListOccurrences ¶
func (m *EmbeddedStore) ListOccurrences(ctx context.Context, pID, filters, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
ListOccurrences returns up to pageSize number of occurrences for this project (pID) beginning at pageToken (or from start if pageToken is the empty string).
func (*EmbeddedStore) ListProjects ¶
func (m *EmbeddedStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)
ListProjects returns up to pageSize number of projects beginning at pageToken, or from start if pageToken is the empty string.
func (*EmbeddedStore) UpdateNote ¶
func (m *EmbeddedStore) UpdateNote(ctx context.Context, pID, nID string, n *pb.Note, mask *fieldmaskpb.FieldMask) (*pb.Note, error)
UpdateNote updates the specified note in embedded store.
func (*EmbeddedStore) UpdateOccurrence ¶
func (m *EmbeddedStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *pb.Occurrence, mask *fieldmaskpb.FieldMask) (*pb.Occurrence, error)
UpdateOccurrence updates the specified occurrence in embedded store.
type MemStore ¶
MemStore is an in-memory storage solution for Grafeas
func NewMemStore ¶
func NewMemStore() *MemStore
NewMemStore creates a MemStore with all maps initialized.
func (*MemStore) BatchCreateNotes ¶
func (m *MemStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*gpb.Note) ([]*gpb.Note, []error)
BatchCreateNotes batch creates the specified notes in memstore.
func (*MemStore) BatchCreateOccurrences ¶
func (m *MemStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*gpb.Occurrence) ([]*gpb.Occurrence, []error)
BatchCreateOccurrence batch creates the specified occurrences in memstore.
func (*MemStore) CreateNote ¶
func (m *MemStore) CreateNote(ctx context.Context, pID, nID, uID string, n *gpb.Note) (*gpb.Note, error)
CreateNote creates the specified note in memstore.
func (*MemStore) CreateOccurrence ¶
func (m *MemStore) CreateOccurrence(ctx context.Context, pID, uID string, o *gpb.Occurrence) (*gpb.Occurrence, error)
CreateOccurrence creates the specified occurrence in memstore.
func (*MemStore) CreateProject ¶
func (m *MemStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)
CreateProject creates the specified project in memstore.
func (*MemStore) DeleteNote ¶
DeleteNote deletes the specified note in memstore.
func (*MemStore) DeleteOccurrence ¶
DeleteOccurrence deletes the specified occurrence in memstore.
func (*MemStore) DeleteProject ¶
DeleteProject deletes the specified project from memstore.
func (*MemStore) GetOccurrence ¶
GetOccurrence gets the specified occurrence from memstore.
func (*MemStore) GetOccurrenceNote ¶
GetOccurrenceNote gets the note for the specified occurrence from memstore.
func (*MemStore) GetProject ¶
GetProject gets the specified project from memstore.
func (*MemStore) GetVulnerabilityOccurrencesSummary ¶
func (m *MemStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*gpb.VulnerabilityOccurrencesSummary, error)
GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.
func (*MemStore) ListNoteOccurrences ¶
func (m *MemStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*gpb.Occurrence, string, error)
ListNoteOccurrences returns up to pageSize number of occurrences on the note for the project beginning at pageToken, or from start if pageToken is empty.
func (*MemStore) ListNotes ¶
func (m *MemStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*gpb.Note, string, error)
ListNotes returns up to pageSize number of notes for the project pID beginning at pageToken, or from start if pageToken is the empty string.
func (*MemStore) ListOccurrences ¶
func (m *MemStore) ListOccurrences(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*gpb.Occurrence, string, error)
ListOccurrences returns up to pageSize number of occurrences for this project beginning at pageToken, or from start if pageToken is the empty string.
func (*MemStore) ListProjects ¶
func (m *MemStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)
ListProjects returns up to pageSize number of projects beginning at pageToken, or from start if pageToken is the empty string.
func (*MemStore) UpdateNote ¶
func (m *MemStore) UpdateNote(ctx context.Context, pID, nID string, n *gpb.Note, mask *fieldmaskpb.FieldMask) (*gpb.Note, error)
UpdateNote updates the specified note in memstore.
func (*MemStore) UpdateOccurrence ¶
func (m *MemStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *gpb.Occurrence, mask *fieldmaskpb.FieldMask) (*gpb.Occurrence, error)
UpdateOccurrence updates the specified occurrence in memstore.
type PgSQLStore ¶
func NewPgSQLStore ¶
func NewPgSQLStore(config *config.PgSQLConfig) (*PgSQLStore, error)
func (*PgSQLStore) BatchCreateNotes ¶
func (pg *PgSQLStore) BatchCreateNotes(ctx context.Context, pID, uID string, notes map[string]*pb.Note) ([]*pb.Note, []error)
BatchCreateNotes batch creates the specified notes in memstore.
func (*PgSQLStore) BatchCreateOccurrences ¶
func (pg *PgSQLStore) BatchCreateOccurrences(ctx context.Context, pID string, uID string, occs []*pb.Occurrence) ([]*pb.Occurrence, []error)
BatchCreateOccurrences batch creates the specified occurrences in PostreSQL.
func (*PgSQLStore) CreateNote ¶
func (pg *PgSQLStore) CreateNote(ctx context.Context, pID, nID, uID string, n *pb.Note) (*pb.Note, error)
CreateNote adds the specified note
func (*PgSQLStore) CreateOccurrence ¶
func (pg *PgSQLStore) CreateOccurrence(ctx context.Context, pID, uID string, o *pb.Occurrence) (*pb.Occurrence, error)
CreateOccurrence adds the specified occurrence
func (*PgSQLStore) CreateProject ¶
func (pg *PgSQLStore) CreateProject(ctx context.Context, pID string, p *prpb.Project) (*prpb.Project, error)
CreateProject adds the specified project to the store
func (*PgSQLStore) DeleteNote ¶
func (pg *PgSQLStore) DeleteNote(ctx context.Context, pID, nID string) error
DeleteNote deletes the note with the given pID and nID
func (*PgSQLStore) DeleteOccurrence ¶
func (pg *PgSQLStore) DeleteOccurrence(ctx context.Context, pID, oID string) error
DeleteOccurrence deletes the occurrence with the given pID and oID
func (*PgSQLStore) DeleteProject ¶
func (pg *PgSQLStore) DeleteProject(ctx context.Context, pID string) error
DeleteProject deletes the project with the given pID from the store
func (*PgSQLStore) GetOccurrence ¶
func (pg *PgSQLStore) GetOccurrence(ctx context.Context, pID, oID string) (*pb.Occurrence, error)
GetOccurrence returns the occurrence with pID and oID
func (*PgSQLStore) GetOccurrenceNote ¶
GetOccurrenceNote gets the note for the specified occurrence from PostgreSQL.
func (*PgSQLStore) GetProject ¶
GetProject returns the project with the given pID from the store
func (*PgSQLStore) GetVulnerabilityOccurrencesSummary ¶
func (pg *PgSQLStore) GetVulnerabilityOccurrencesSummary(ctx context.Context, projectID, filter string) (*pb.VulnerabilityOccurrencesSummary, error)
GetVulnerabilityOccurrencesSummary gets a summary of vulnerability occurrences from storage.
func (*PgSQLStore) ListNoteOccurrences ¶
func (pg *PgSQLStore) ListNoteOccurrences(ctx context.Context, pID, nID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
ListNoteOccurrences returns up to pageSize number of occurrences on the particular note (nID) for this project (pID) projects beginning at pageToken (or from start if pageToken is the empty string).
func (*PgSQLStore) ListNotes ¶
func (pg *PgSQLStore) ListNotes(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Note, string, error)
ListNotes returns up to pageSize number of notes for this project (pID) beginning at pageToken (or from start if pageToken is the empty string).
func (*PgSQLStore) ListOccurrences ¶
func (pg *PgSQLStore) ListOccurrences(ctx context.Context, pID, filter, pageToken string, pageSize int32) ([]*pb.Occurrence, string, error)
ListOccurrences returns up to pageSize number of occurrences for this project beginning at pageToken, or from start if pageToken is the empty string.
func (*PgSQLStore) ListProjects ¶
func (pg *PgSQLStore) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error)
ListProjects returns up to pageSize number of projects beginning at pageToken (or from start if pageToken is the empty string).
func (*PgSQLStore) UpdateNote ¶
func (pg *PgSQLStore) UpdateNote(ctx context.Context, pID, nID string, n *pb.Note, mask *fieldmaskpb.FieldMask) (*pb.Note, error)
UpdateNote updates the existing note with the given pID and nID
func (*PgSQLStore) UpdateOccurrence ¶
func (pg *PgSQLStore) UpdateOccurrence(ctx context.Context, pID, oID string, o *pb.Occurrence, mask *fieldmaskpb.FieldMask) (*pb.Occurrence, error)
UpdateOccurrence updates the existing occurrence with the given projectID and occurrenceID
type Ps ¶ added in v0.1.2
use type aliasing to get multiple inheritance even though both interfaces are called Storage
type Storage ¶ added in v0.1.2
unified interface that basically gives us a single interface called Storage that implements both anonymous interfaces.
func CreateStorageOfType ¶ added in v0.1.2
func CreateStorageOfType(storageType string, storageConfig *config.StorageConfiguration) (*Storage, error)
CreateStorageOfType will create an instance of Storage by name or an error if that type is unsupported.