scope

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scope 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

Functions

This section is empty.

Types

type ContentResolver

type ContentResolver interface {
	MultipleFileContentsByRef(f ...file.Reference) (map[file.Reference]string, error)
}

ContentResolver knows how to get file content for given file.References

type DirSource

type DirSource struct {
	Path string // the root path to be cataloged
}

DirSource represents a data source that is a filesystem directory tree

type FileResolver

type FileResolver interface {
	FilesByPath(paths ...file.Path) ([]file.Reference, error)
	FilesByGlob(patterns ...string) ([]file.Reference, error)
}

FileResolver knows how to get file.References for given string paths and globs

type ImageSource

type ImageSource struct {
	Img *image.Image // the image object to be cataloged
}

ImageSource represents a data source that is a container image

type Option

type Option int
const (
	UnknownScope Option = iota
	SquashedScope
	AllLayersScope
)

func ParseOption

func ParseOption(userStr string) Option

func (Option) String

func (o Option) String() string

type Resolver

type Resolver interface {
	ContentResolver
	FileResolver
}

Resolver is an interface that encompasses how to get specific file references and file contents for a generic data source.

type Scope

type Scope struct {
	Option   Option      // specific perspective to catalog
	Resolver Resolver    // a Resolver object to use in file path/glob resolution and file contents resolution
	ImgSrc   ImageSource // the specific image to be cataloged
	DirSrc   DirSource   // the specific directory to be cataloged
}

Scope is an object that captures the data source to be cataloged, configuration, and a specific resolver used in cataloging (based on the data source and configuration)

func NewScope

func NewScope(userInput string, o Option) (Scope, func(), error)

NewScope produces a Scope based on userInput like dir: or image:tag

func NewScopeFromDir

func NewScopeFromDir(path string) (Scope, error)

NewScopeFromDir creates a new scope object tailored to catalog a given filesystem directory recursively.

func NewScopeFromImage

func NewScopeFromImage(img *image.Image, option Option) (Scope, error)

NewScopeFromImage creates a new scope object tailored to catalog a given container image, relative to the option given (e.g. all-layers, squashed, etc)

func (Scope) Source

func (s Scope) Source() interface{}

Source returns the configured data source (either a dir source or container image source)

Directories

Path Synopsis
Package resolvers provides concrete implementations for the scope.Resolver interface for all supported data sources and scope options.
Package resolvers provides concrete implementations for the scope.Resolver interface for all supported data sources and scope options.

Jump to

Keyboard shortcuts

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