source

package
v0.103.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 25 Imported by: 123

Documentation

Overview

Package source provides an abstraction to allow a user to loosely define a data source to catalog and expose a common interface that catalogers and use explore and analyze data from the data source. All valid (cataloggable) data sources are defined within this package.

Index

Constants

This section is empty.

Variables

AllScopes is a slice containing all possible scope options

Functions

This section is empty.

Types

type Alias added in v0.85.0

type Alias struct {
	Name    string `json:"name" yaml:"name" mapstructure:"name"`
	Version string `json:"version" yaml:"version" mapstructure:"version"`
}

func (*Alias) IsEmpty added in v0.85.0

func (a *Alias) IsEmpty() bool

type Description added in v0.85.0

type Description struct {
	ID       string `hash:"ignore"` // the id generated from the parent source struct
	Name     string `hash:"ignore"`
	Version  string `hash:"ignore"`
	Metadata interface{}
}

Description represents any static source data that helps describe "what" was cataloged.

type DetectConfig added in v0.85.0

type DetectConfig struct {
	DefaultImageSource string
}

func DefaultDetectConfig added in v0.85.0

func DefaultDetectConfig() DetectConfig

type Detection added in v0.85.0

type Detection struct {
	// contains filtered or unexported fields
}

Detection is an object that captures the detected user input regarding source location, scheme, and provider type. It acts as a struct input for some source constructors.

func Detect added in v0.85.0

func Detect(userInput string, cfg DetectConfig) (*Detection, error)

Detect generates a source Detection that can be used as an argument to generate a new source from specific providers including a registry, with an explicit name.

func (Detection) IsContainerImage added in v0.85.0

func (d Detection) IsContainerImage() bool

func (Detection) NewSource added in v0.85.0

func (d Detection) NewSource(cfg DetectionSourceConfig) (Source, error)

NewSource produces a Source based on userInput like dir: or image:tag

type DetectionSourceConfig added in v0.85.0

type DetectionSourceConfig struct {
	Alias            Alias
	RegistryOptions  *image.RegistryOptions
	Platform         *image.Platform
	Exclude          ExcludeConfig
	DigestAlgorithms []crypto.Hash
	BasePath         string
}

func DefaultDetectionSourceConfig added in v0.85.0

func DefaultDetectionSourceConfig() DetectionSourceConfig

type DirectoryConfig added in v0.85.0

type DirectoryConfig struct {
	Path    string
	Base    string
	Exclude ExcludeConfig
	Alias   Alias
}

type DirectorySource added in v0.85.0

type DirectorySource struct {
	// contains filtered or unexported fields
}

func NewFromDirectory

func NewFromDirectory(cfg DirectoryConfig) (*DirectorySource, error)

func NewFromDirectoryPath added in v0.85.0

func NewFromDirectoryPath(path string) (*DirectorySource, error)

func (*DirectorySource) Close added in v0.85.0

func (s *DirectorySource) Close() error

func (DirectorySource) Describe added in v0.85.0

func (s DirectorySource) Describe() Description

func (*DirectorySource) FileResolver added in v0.85.0

func (s *DirectorySource) FileResolver(_ Scope) (file.Resolver, error)

func (DirectorySource) ID added in v0.85.0

func (s DirectorySource) ID() artifact.ID

type DirectorySourceMetadata added in v0.85.0

type DirectorySourceMetadata struct {
	Path string `json:"path" yaml:"path"`
	Base string `json:"-" yaml:"-"` // though this is important, for display purposes it leaks too much information (abs paths)
}

type ExcludeConfig added in v0.85.0

type ExcludeConfig struct {
	Paths []string
}

type FileConfig added in v0.85.0

type FileConfig struct {
	Path             string
	Exclude          ExcludeConfig
	DigestAlgorithms []crypto.Hash
	Alias            Alias
}

type FileSource added in v0.85.0

type FileSource struct {
	// contains filtered or unexported fields
}

func NewFromFile added in v0.30.0

func NewFromFile(cfg FileConfig) (*FileSource, error)

func (*FileSource) Close added in v0.85.0

func (s *FileSource) Close() error

func (FileSource) Describe added in v0.85.0

func (s FileSource) Describe() Description

func (FileSource) FileResolver added in v0.85.0

func (s FileSource) FileResolver(_ Scope) (file.Resolver, error)

func (FileSource) ID added in v0.85.0

func (s FileSource) ID() artifact.ID

type FileSourceMetadata added in v0.85.0

type FileSourceMetadata struct {
	Path     string        `json:"path" yaml:"path"`
	Digests  []file.Digest `json:"digests,omitempty" yaml:"digests,omitempty"`
	MIMEType string        `json:"mimeType" yaml:"mimeType"`
}

type Scope

type Scope string

Scope indicates "how" or from "which perspectives" the source object should be cataloged from.

const (
	// UnknownScope is the default scope
	UnknownScope Scope = "unknown-scope"
	// SquashedScope indicates to only catalog content visible from the squashed filesystem representation (what can be seen only within the container at runtime)
	SquashedScope Scope = "squashed"
	// AllLayersScope indicates to catalog content on all layers, regardless if it is visible from the container at runtime.
	AllLayersScope Scope = "all-layers"
)

func ParseScope

func ParseScope(userStr string) Scope

ParseScope returns a scope as indicated from the given string.

func (Scope) String

func (o Scope) String() string

type Source

type Source interface {
	artifact.Identifiable
	FileResolver(Scope) (file.Resolver, error)
	Describe() Description
	io.Closer
}

func FromDescription added in v0.85.0

func FromDescription(d Description) Source

type StereoscopeImageConfig added in v0.85.0

type StereoscopeImageConfig struct {
	Reference       string
	From            image.Source
	Platform        *image.Platform
	RegistryOptions *image.RegistryOptions
	Exclude         ExcludeConfig
	Alias           Alias
}

type StereoscopeImageSource added in v0.85.0

type StereoscopeImageSource struct {
	// contains filtered or unexported fields
}

func NewFromStereoscopeImage added in v0.85.0

func NewFromStereoscopeImage(cfg StereoscopeImageConfig) (*StereoscopeImageSource, error)

func NewFromStereoscopeImageObject added in v0.85.0

func NewFromStereoscopeImageObject(img *image.Image, reference string, alias *Alias) (*StereoscopeImageSource, error)

func (StereoscopeImageSource) Close added in v0.85.0

func (s StereoscopeImageSource) Close() error

func (StereoscopeImageSource) Describe added in v0.85.0

func (s StereoscopeImageSource) Describe() Description

func (StereoscopeImageSource) FileResolver added in v0.85.0

func (s StereoscopeImageSource) FileResolver(scope Scope) (file.Resolver, error)

func (StereoscopeImageSource) ID added in v0.85.0

type StereoscopeImageSourceMetadata added in v0.85.0

type StereoscopeImageSourceMetadata struct {
	UserInput      string                     `json:"userInput"`
	ID             string                     `json:"imageID"`
	ManifestDigest string                     `json:"manifestDigest"`
	MediaType      string                     `json:"mediaType"`
	Tags           []string                   `json:"tags"`
	Size           int64                      `json:"imageSize"`
	Layers         []StereoscopeLayerMetadata `json:"layers"`
	RawManifest    []byte                     `json:"manifest"`
	RawConfig      []byte                     `json:"config"`
	RepoDigests    []string                   `json:"repoDigests"`
	Architecture   string                     `json:"architecture"`
	Variant        string                     `json:"architectureVariant,omitempty"`
	OS             string                     `json:"os"`
	Labels         map[string]string          `json:"labels,omitempty"`
}

StereoscopeImageSourceMetadata represents all static metadata that defines what a container image is. This is useful to later describe "what" was cataloged without needing the more complicated stereoscope Image objects or FileResolver objects.

func NewStereoscopeImageMetadata added in v0.85.0

func NewStereoscopeImageMetadata(img *image.Image, userInput string) StereoscopeImageSourceMetadata

NewStereoscopeImageMetadata creates a new ImageMetadata object populated from the given stereoscope Image object and user configuration.

type StereoscopeLayerMetadata added in v0.85.0

type StereoscopeLayerMetadata struct {
	MediaType string `json:"mediaType"`
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
}

StereoscopeLayerMetadata represents all static metadata that defines what a container image layer is.

Jump to

Keyboard shortcuts

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