common

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const OCM_TYPE_GROUP_SUFFIX = ".ocm.software"

Variables

View Source
var (
	StdoutPrinter = NewPrinter(os.Stdout)
	StderrPrinter = NewPrinter(os.Stderr)
	NonePrinter   = NewPrinter(nil)
)

Functions

func CompareHistoryElement

func CompareHistoryElement(a, b interface{}) int

func CompareHistorySource

func CompareHistorySource(a, b interface{}) int

func CompareNameVersion added in v0.10.0

func CompareNameVersion(a, b NameVersion) int

func DigestToFileName

func DigestToFileName(digest digest.Digest) string

DigestToFileName returns the file name for a digest.

func Flush

func Flush(o interface{}) error

func IterfaceSlice

func IterfaceSlice(slice interface{}) []interface{}

func PathToDigest

func PathToDigest(path string) digest.Digest

PathToDigest retuurns the digest encoded into a file name.

func SortHistoryElements

func SortHistoryElements(s interface{})

Types

type Flusher

type Flusher interface {
	Flush() error
}

type FlushingPrinter

type FlushingPrinter interface {
	Printer
	Flusher
}

func NewLoggingPrinter

func NewLoggingPrinter(log logging.Logger) FlushingPrinter

NewLoggingPrinter returns a printer logging the output to an info-level log. It should not be used to print binary data, but text data, only.

type History

type History []NameVersion

func (*History) Add

func (h *History) Add(kind string, nv NameVersion) error

Add provided a new extended non-cyclic history. If the new entry would lead to a cycle an appropriate error is returned.

func (History) Append

func (h History) Append(nv ...NameVersion) History

Append provides a new extended history without cycle check.

func (History) Compare

func (h History) Compare(o History) int

func (History) Compare2

func (h History) Compare2(o History) (int, bool)

func (History) Contains

func (h History) Contains(nv NameVersion) bool

func (History) Copy

func (h History) Copy() History

func (History) Cycle added in v0.7.0

func (h History) Cycle(nv NameVersion) (History, History)

func (History) Equals

func (h History) Equals(o History) bool

func (History) HasPrefix

func (h History) HasPrefix(o History) bool

func (History) RemovePrefix

func (h History) RemovePrefix(prefix History) History

func (History) String

func (h History) String() string

type HistoryElement

type HistoryElement interface {
	HistorySource
	GetKey() NameVersion
}

type HistorySource

type HistorySource interface {
	GetHistory() History
}

type NameVersion

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

func NewNameVersion

func NewNameVersion(name, version string) NameVersion

func ParseNameVersion

func ParseNameVersion(s string) (NameVersion, error)

func VersionedElementKey

func VersionedElementKey(v VersionedElement) NameVersion

func (NameVersion) Compare

func (n NameVersion) Compare(o NameVersion) int

func (NameVersion) GetName

func (n NameVersion) GetName() string

func (NameVersion) GetVersion

func (n NameVersion) GetVersion() string

func (NameVersion) MarshalJSON

func (n NameVersion) MarshalJSON() ([]byte, error)

func (NameVersion) String

func (n NameVersion) String() string

type NameVersionInfo

type NameVersionInfo[T any] map[NameVersion]T

func (NameVersionInfo[T]) Add

func (s NameVersionInfo[T]) Add(nv NameVersion, data ...T) bool

func (NameVersionInfo[T]) Contains

func (s NameVersionInfo[T]) Contains(nv NameVersion) bool

type Printer

type Printer interface {
	io.Writer
	Printf(msg string, args ...interface{}) (int, error)

	AddGap(gap string) Printer
}

func AssurePrinter added in v0.3.0

func AssurePrinter(p Printer) Printer

func NewBufferedPrinter

func NewBufferedPrinter() (Printer, *bytes.Buffer)

func NewPrinter

func NewPrinter(writer io.Writer) Printer

type Properties

type Properties map[string]string

Properties describes a set of name/value pairs.

func (Properties) Copy

func (p Properties) Copy() Properties

Copy copies identity.

func (Properties) Digest

func (p Properties) Digest() ([]byte, error)

Digest returns the object digest of a Property set.

func (Properties) Equals

func (p Properties) Equals(o Properties) bool

Equals compares two identities.

func (Properties) Match

func (p Properties) Match(obj map[string]string) (bool, error)

Match implements the selector interface.

func (Properties) Names

func (c Properties) Names() set.Set[string]

Names returns the set of property names.

func (Properties) SetNonEmptyValue

func (p Properties) SetNonEmptyValue(name, value string)

func (Properties) String

func (c Properties) String() string

String returns a string representation.

type VersionedElement

type VersionedElement interface {
	// GetName gets the name of the element
	GetName() string
	// GetVersion gets the version of the element
	GetVersion() string
}

VersionedElement describes an element that has a name and a version.

type WalkingState

type WalkingState[T any, C any] struct {
	LogCtx  logging.Context
	Logger  logging.Logger
	Context C
	Closure NameVersionInfo[T]
	History History
}

func NewWalkingState

func NewWalkingState[T any, C any](ctx C, lctx ...logging.Context) WalkingState[T, C]

func (*WalkingState[T, C]) Add

func (s *WalkingState[T, C]) Add(kind string, nv NameVersion) (bool, error)

func (*WalkingState[T, C]) Contains

func (s *WalkingState[T, C]) Contains(nv NameVersion) bool

func (*WalkingState[T, C]) Get

func (s *WalkingState[T, C]) Get(nv NameVersion) T

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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