Documentation ¶
Overview ¶
Package index implements all the logic for handling indexes.
Index ¶
- type Config
- type ConfigEntry
- type Entry
- type Index
- func (i *Index) EntryByName(name string) (*Entry, bool)
- func (i *Index) Normalize() error
- func (i *Index) Read(path string) error
- func (i *Index) Remove(entry *Entry) error
- func (i *Index) SearchByKeywords(minScore float64, keywords ...string) []*Entry
- func (i *Index) Upsert(entry *Entry)
- func (i *Index) Write(path string) error
- type MergedIndexes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Configs []ConfigEntry `yaml:"configs"`
}
Config aggregates the info about ConfigEntries.
func (*Config) Get ¶
func (c *Config) Get(name string) *ConfigEntry
Get returns a pointer to an entry in a Config.
func (*Config) Upsert ¶
func (c *Config) Upsert(entry ConfigEntry)
Upsert replaces the entry if already exists otherwise just appends it.
type ConfigEntry ¶
type ConfigEntry struct { AddedTimestamp string `yaml:"added_timestamp"` // CaFile string `yaml:"caFile"` // CertFile string `yaml:"certFile"` // InsecureSkipTLSVerify string `yaml:"insecure_skip_tls_verify"` // KeyFile string `yaml:"keyFile"` Name string `yaml:"name"` // PassCredentialsAll string `yaml:"pass_credentials_all"` // Password string `yaml:"password"` UpdatedTimestamp string `yaml:"updated_timestamp"` URL string `yaml:"url"` }
ConfigEntry contains information about one of the index that were cached locally. TODO: add support for all the other fields.
type Entry ¶
type Entry struct { // Mandatory fields Name string `yaml:"name"` Type string `yaml:"type"` Registry string `yaml:"registry"` Repository string `yaml:"repository"` // Optional fields Description string `yaml:"description"` Home string `yaml:"home"` Keywords []string `yaml:"keywords"` License string `yaml:"license"` Maintainers []struct { Email string `yaml:"email"` Name string `yaml:"name"` } `yaml:"maintainers"` Sources []string `yaml:"sources"` }
Entry describes an entry of the index stored remotely and cached locally.
type Index ¶
Index represents an index.
func (*Index) EntryByName ¶
EntryByName returns a Entry by passing its name.
func (*Index) Normalize ¶
Normalize the index to the canonical form (i.e., entries sorted by name, lexically byte-wise in ascending order).
Since only one possible representation of a normalized index exists, a digest of a normalized index is suitable for integrity checking or similar purposes. Return an error if the index is not in a consistent state.
func (*Index) SearchByKeywords ¶
SearchByKeywords search for entries matching the given keywords in MergedIndexes. minScore is the minimum score to consider a match between a name of an artifact and a keyword. if minScore is not reached, we fallback to a simple partial matching on keywords.
type MergedIndexes ¶
type MergedIndexes struct { Index // contains filtered or unexported fields }
MergedIndexes is used to aggregate all indexes and perform search operations.
func NewMergedIndexes ¶
func NewMergedIndexes() *MergedIndexes
NewMergedIndexes initializes a MergedIndex.
func (*MergedIndexes) IndexByEntry ¶
func (m *MergedIndexes) IndexByEntry(entry *Entry) *Index
IndexByEntry is used to retrieve the original index from an entry in MergedIndexes.
func (*MergedIndexes) Merge ¶
func (m *MergedIndexes) Merge(indexes ...*Index)
Merge creates a new index by merging all the indexes that are passed. Orders matters. Be sure to pass an ordered list of indexes. For our use case, sort by added time.
func (*MergedIndexes) ResolveReference ¶
func (m *MergedIndexes) ResolveReference(name string) (string, error)
ResolveReference is a helper function that parse with the followig logic:
if name is the name of an artifact, it will use the merged index to compute its reference. The tag latest is always appended. e.g "cloudtrail" -> "ghcr.io/falcosecurity/plugins/cloudtrail:latest" if instead a tag or a digest is specified, the name will be used to look up into mergedIndexes, then the tag or digest will be appended. e.g "cloudtrail:0.5.1" -> "ghcr.io/falcosecurity/plugins/cloudtrail:0.5.1" e.g "cloudtrail@sha256:123abc..." -> "ghcr.io/falcosecurity/plugins/cloudtrail@sha256:123abc...
if name is a reference without tag or digest, tag latest is appended. e.g. "ghcr.io/falcosecurity/plugins/cloudtrail" -> "ghcr.io/falcosecurity/plugins/cloudtrail:latest"
if name is a complete reference, it will be returned as is.