result

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 20

Documentation

Index

Constants

View Source
const (
	AttestationReasonKey     = "reason"
	AttestationSBOMCore      = "sbom-core"
	AttestationInlineOnlyKey = "inline-only"
)
View Source
const (
	AttestationReasonSBOM       = "sbom"
	AttestationReasonProvenance = "provenance"
)

Variables

This section is empty.

Functions

func EachRef

func EachRef[U comparable, V comparable](a *Result[U], b *Result[V], fn func(U, V) error) (err error)

EachRef iterates over references in both a and b. a and b are assumed to be of the same size and map their references to the same set of keys

func FromDigestMap

func FromDigestMap(m map[string]string) []digest.Digest

func ToDigestMap

func ToDigestMap(ds ...digest.Digest) map[string]string

Types

type Attestation

type Attestation[T any] struct {
	Kind pb.AttestationKind

	Metadata map[string][]byte

	Ref         T
	Path        string
	ContentFunc func() ([]byte, error)

	InToto InTotoAttestation
}

func ConvertAttestation

func ConvertAttestation[U comparable, V comparable](a *Attestation[U], fn func(U) (V, error)) (*Attestation[V], error)

type InTotoAttestation

type InTotoAttestation struct {
	PredicateType string
	Subjects      []InTotoSubject
}

type InTotoSubject

type InTotoSubject struct {
	Kind pb.InTotoSubjectKind

	Name   string
	Digest []digest.Digest
}

type Result

type Result[T comparable] struct {
	Ref          T
	Refs         map[string]T
	Metadata     map[string][]byte
	Attestations map[string][]Attestation[T]
	// contains filtered or unexported fields
}

func ConvertResult

func ConvertResult[U comparable, V comparable](r *Result[U], fn func(U) (V, error)) (*Result[V], error)

ConvertResult transforms a Result[U] into a Result[V], using a transfomer function that converts a U to a V. Zero values of type U are converted to zero values of type V directly, without passing through the transformer function.

func (*Result[T]) AddAttestation

func (r *Result[T]) AddAttestation(k string, v Attestation[T])

func (*Result[T]) AddMeta

func (r *Result[T]) AddMeta(k string, v []byte)

func (*Result[T]) AddRef

func (r *Result[T]) AddRef(k string, ref T)

func (*Result[T]) Clone added in v0.13.0

func (r *Result[T]) Clone() *Result[T]

func (*Result[T]) EachRef

func (r *Result[T]) EachRef(fn func(T) error) (err error)

func (*Result[T]) FindRef

func (r *Result[T]) FindRef(key string) (T, bool)

func (*Result[T]) SetRef

func (r *Result[T]) SetRef(ref T)

func (*Result[T]) SingleRef

func (r *Result[T]) SingleRef() (T, error)

Jump to

Keyboard shortcuts

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