Documentation ¶
Overview ¶
Package source (go:generate go run -mod=mod github.com/golang/mock/mockgen -package mock -source=./$GOFILE -destination=../mock/$GOFILE)
Index ¶
- Constants
- func GetPathToLibrary(platform, relativeBasePath string) string
- func ListSupportedPlatforms() []string
- func ReadMetadata(queryDir string) map[string]interface{}
- func ReadQuery(queryDir string) (model.QueryMetadata, error)
- type ExcludeQueries
- type FilesystemSource
- type IncludeQueries
- type QueriesSource
- type QuerySelectionFilter
Constants ¶
const ( // QueryFileName The default query file name QueryFileName = "query.rego" // MetadataFileName The default metadata file name MetadataFileName = "metadata.json" // LibraryFileName The default library file name LibraryFileName = "library.rego" // LibrariesDefaultBasePath the path to rego libraries LibrariesDefaultBasePath = "./assets/libraries/" )
Variables ¶
This section is empty.
Functions ¶
func GetPathToLibrary ¶
GetPathToLibrary returns the libraries path for a given platform
func ListSupportedPlatforms ¶
func ListSupportedPlatforms() []string
ListSupportedPlatforms returns a list of supported platforms
func ReadMetadata ¶
ReadMetadata read query's metadata file inside the query directory
Types ¶
type ExcludeQueries ¶
ExcludeQueries is a struct that represents the option to exclude queries by ids or by categories
type FilesystemSource ¶
FilesystemSource this type defines a struct with a path to a filesystem source of queries Source is the path to the queries Types are the types given by the flag --type for query selection mechanism
func NewFilesystemSource ¶
func NewFilesystemSource(source string, types []string) *FilesystemSource
NewFilesystemSource initializes a NewFilesystemSource with source to queries and types of queries to load
func (*FilesystemSource) CheckType ¶
func (s *FilesystemSource) CheckType(queryPlatform interface{}) bool
CheckType checks if the queries have the type passed as an argument in '--type' flag to be loaded
func (*FilesystemSource) GetQueries ¶
func (s *FilesystemSource) GetQueries(queryFilter QuerySelectionFilter) ([]model.QueryMetadata, error)
GetQueries walks a given filesource path returns all queries found in an array of QueryMetadata struct
func (*FilesystemSource) GetQueryLibrary ¶ added in v1.2.2
func (s *FilesystemSource) GetQueryLibrary(platform string) (string, error)
GetQueryLibrary returns the library.rego for the platform passed in the argument
type IncludeQueries ¶ added in v1.3.2
type IncludeQueries struct {
ByIDs []string
}
IncludeQueries is a struct that represents the option to include queries by ID taking precedence over exclusion
type QueriesSource ¶
type QueriesSource interface { GetQueries(querySelection QuerySelectionFilter) ([]model.QueryMetadata, error) GetQueryLibrary(platform string) (string, error) }
QueriesSource wraps an interface that contains basic methods: GetQueries and GetQueryLibrary GetQueries gets all queries from a QueryMetadata list GetQueryLibrary gets a library of rego functions given a plataform's name
type QuerySelectionFilter ¶ added in v1.3.2
type QuerySelectionFilter struct { IncludeQueries IncludeQueries ExcludeQueries ExcludeQueries }
QuerySelectionFilter is a struct that represents the optionn to select queries to be executed