index

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package index implements the index struct and its logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CosignSignature

type CosignSignature struct {
	CertificateOidcIssuer       string `yaml:"certificate-oidc-issuer"`
	CertificateOidcIssuerRegexp string `yaml:"certificate-oidc-issuer-regexp"`
	CertificateIdentity         string `yaml:"certificate-identity"`
	CertificateIdentityRegexp   string `yaml:"certificate-identity-regexp"`
	CertificateGithubWorkflow   string `yaml:"certificate-github-workflow"`
}

CosignSignature contains certificate information for cosign keyless signature verification, equivalent to the cosign command line arguments.

type Entry

type Entry struct {
	// Mandatory fields
	Name       string     `yaml:"name"`
	Type       string     `yaml:"type"`
	Registry   string     `yaml:"registry"`
	Repository string     `yaml:"repository"`
	Signature  *Signature `yaml:"signature,omitempty"`
	// Optional fields
	Description string     `yaml:"description"`
	Home        string     `yaml:"home"`
	Keywords    []string   `yaml:"keywords"`
	License     string     `yaml:"license"`
	Maintainers Maintainer `yaml:"maintainers"`
	Sources     []string   `yaml:"sources"`
}

Entry describes an entry of the index stored remotely and cached locally.

type Index

type Index struct {
	Name    string
	Entries []*Entry
	// contains filtered or unexported fields
}

Index represents an index.

func New

func New(name string) *Index

New returns a new empty Index.

func (*Index) EntryByName

func (i *Index) EntryByName(name string) (*Entry, bool)

EntryByName returns a Entry by passing its name.

func (*Index) Normalize

func (i *Index) Normalize() error

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) Read

func (i *Index) Read(path string) error

Read reads entries from a file.

func (*Index) ReadBytes

func (i *Index) ReadBytes(bytes []byte) error

ReadBytes reads entries from a byte slice.

func (*Index) Remove

func (i *Index) Remove(entry *Entry) error

Remove removes an entry from the Index.

func (*Index) SearchByKeywords

func (i *Index) SearchByKeywords(minScore float64, keywords ...string) []*Entry

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.

func (*Index) Upsert

func (i *Index) Upsert(entry *Entry)

Upsert adds a new entry to the Index or updates an existing one.

func (*Index) Write

func (i *Index) Write(path string) error

Write writes entries to a file.

type Maintainer

type Maintainer []struct {
	Email string `yaml:"email"`
	Name  string `yaml:"name"`
}

Maintainer represents an index maintainer.

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 following logic:

  1. 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...

  2. 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"

  3. if name is a complete reference, it will be returned as is.

func (*MergedIndexes) SignatureForIndexRef

func (m *MergedIndexes) SignatureForIndexRef(name string) *Signature

SignatureForIndexRef is a helper function that will identify signature data if available for the specified name corresponding to an entry in the index. Returns nil if not found or if the specified name is a full reference.

type Signature

type Signature struct {
	Cosign *CosignSignature `yaml:"cosign,omitempty"`
}

Signature represents all the metadata necessary to perform signature verification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL