util

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package util contains internal utility tools used in imgpkg

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDefaultUploadTagRef

func BuildDefaultUploadTagRef(item WithDigest, importRepo regname.Repository) (regname.Tag, error)

BuildDefaultUploadTagRef Builds a tag from the digest Algorithm and Digest

func Retry

func Retry(doFunc func() error) error

Types

type BufferLogger added in v0.31.0

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

BufferLogger write logs to a buffer

func NewBufferLogger added in v0.31.0

func NewBufferLogger(buf *bytes.Buffer) *BufferLogger

NewBufferLogger creates a new BufferLogger

func (*BufferLogger) Logf added in v0.31.0

func (b *BufferLogger) Logf(msg string, args ...interface{})

Logf writes log to the buffer

type DefaultTagGenerator added in v0.28.0

type DefaultTagGenerator struct{}

DefaultTagGenerator implements GenerateTag and generates default tag

func (DefaultTagGenerator) GenerateTag added in v0.28.0

func (tagGen DefaultTagGenerator) GenerateTag(item imagedigest.DigestWrap, importRepo regname.Repository) (regname.Tag, error)

GenerateTag generates default tag

type LevelLogger added in v0.31.0

type LevelLogger struct {
	LogLevel LogLevel
	// contains filtered or unexported fields
}

LevelLogger allows specifying a log level to a ui.UI

func NewIndentedLevelLogger added in v0.31.0

func NewIndentedLevelLogger(logger LoggerWithLevels) *LevelLogger

NewIndentedLevelLogger creates a new logger with levels and indented by 2 spaces

func NewNoopLevelLogger added in v0.31.0

func NewNoopLevelLogger() *LevelLogger

NewNoopLevelLogger will not print anything

func NewUILevelLogger

func NewUILevelLogger(level LogLevel, logger Logger) *LevelLogger

NewUILevelLogger is a LevelLogger constructor, wrapping a ui.UI with a specific log level

func (LevelLogger) Debugf added in v0.31.0

func (l LevelLogger) Debugf(msg string, args ...interface{})

Debugf used to log debug related messages

func (LevelLogger) Errorf added in v0.31.0

func (l LevelLogger) Errorf(msg string, args ...interface{})

Errorf used to log error related messages

func (LevelLogger) Level added in v0.31.0

func (l LevelLogger) Level() LogLevel

Level retrieve the current log level for this logger

func (LevelLogger) Logf added in v0.31.0

func (l LevelLogger) Logf(msg string, args ...interface{})

Logf logs the provided message

func (LevelLogger) Tracef added in v0.31.0

func (l LevelLogger) Tracef(msg string, args ...interface{})

Tracef used to log trace related messages

func (LevelLogger) Warnf added in v0.31.0

func (l LevelLogger) Warnf(msg string, args ...interface{})

Warnf used to log warning related messages

type LogLevel

type LogLevel int

LogLevel specifies logging level (i.e. DEBUG, WARN)

const (
	// LogTrace most verbose level
	LogTrace LogLevel = iota
	// LogDebug used when more information than normal is needed
	LogDebug LogLevel = iota
	// LogWarn only logs warnings and errors
	LogWarn LogLevel = iota
)

type LogLevelRetriever added in v0.31.0

type LogLevelRetriever interface {
	Level() LogLevel
}

LogLevelRetriever retrieves the log level

type Logger added in v0.31.0

type Logger interface {
	Logf(string, ...interface{})
}

Logger interface that defines the logger functions

type LoggerWithLevels added in v0.31.0

type LoggerWithLevels interface {
	Errorf(msg string, args ...interface{})
	Warnf(msg string, args ...interface{})
	Debugf(msg string, args ...interface{})
	Tracef(msg string, args ...interface{})
	Logf(msg string, args ...interface{})
}

LoggerWithLevels wraps a ui.UI with logging levels

type NoTTYLogger added in v0.31.0

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

NoTTYLogger struct that interacts with the UI. This logger allow writing to the UI when the tty is deactivated

func NewLoggerNoTTY added in v0.31.0

func NewLoggerNoTTY(ui goui.UI) *NoTTYLogger

NewLoggerNoTTY creates a logger that will write even when tty is deactivated

func (*NoTTYLogger) Logf added in v0.31.0

func (n *NoTTYLogger) Logf(msg string, args ...interface{})

Logf Prints log to UI when tty is deactivated

type NonRetryableError

type NonRetryableError struct {
	Message string
}

func (NonRetryableError) Error

func (n NonRetryableError) Error() string

type NoopLogger added in v0.31.0

type NoopLogger struct{}

NoopLogger this logger will not print

func NewNoopLogger added in v0.31.0

func NewNoopLogger() *NoopLogger

NewNoopLogger creates a new noop logger

func (NoopLogger) Logf added in v0.31.0

func (n NoopLogger) Logf(string, ...interface{})

Logf does nothing

type PrefixedLogger added in v0.31.0

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

PrefixedLogger Logger that attached a prefix to each line

func NewIndentedLogger added in v0.31.0

func NewIndentedLogger(logger Logger) *PrefixedLogger

NewIndentedLogger creates a new logger indented by 2 spaces

func NewPrefixedLogger added in v0.31.0

func NewPrefixedLogger(prefix string, logger Logger) *PrefixedLogger

NewPrefixedLogger constructor for building a UI with a prefix when logging a message

func (PrefixedLogger) Logf added in v0.31.0

func (p PrefixedLogger) Logf(msg string, args ...interface{})

Logf logs message provided adds the prefix to each new line of the msg parameter

type ProgressBarLogger

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

ProgressBarLogger display progress bar on output

func (*ProgressBarLogger) End

func (l *ProgressBarLogger) End()

End stops the progress bar and writes the final message

func (*ProgressBarLogger) Start

func (l *ProgressBarLogger) Start(ctx context.Context, progressChan <-chan regv1.Update)

Start the display of the Progress Bar

type ProgressBarNoTTYLogger

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

ProgressBarNoTTYLogger does not display the progress bar

func (*ProgressBarNoTTYLogger) End

func (l *ProgressBarNoTTYLogger) End()

End Write the final message

func (*ProgressBarNoTTYLogger) Start

func (l *ProgressBarNoTTYLogger) Start(ctx context.Context, progressChan <-chan regv1.Update)

Start consuming the progress channel but does not display anything

type ProgressLogger

type ProgressLogger interface {
	Start(ctx context.Context, progress <-chan regv1.Update)
	End()
}

ProgressLogger Progress bar

func NewNoopProgressBar added in v0.31.0

func NewNoopProgressBar() ProgressLogger

NewNoopProgressBar constructs a Noop Progress bar that will not display anything

func NewProgressBar

func NewProgressBar(logger LoggerWithLevels, finalMessage, errorMessagePrefix string) ProgressLogger

NewProgressBar constructor to build a ProgressLogger responsible for printing out a progress bar using updates when writing to a registry via ggcr

type RepoBasedTagGenerator added in v0.28.0

type RepoBasedTagGenerator struct{}

RepoBasedTagGenerator implements GenerateTag and generates repo-based tag

func (RepoBasedTagGenerator) GenerateTag added in v0.28.0

func (tagGen RepoBasedTagGenerator) GenerateTag(item imagedigest.DigestWrap, importRepo regname.Repository) (regname.Tag, error)

GenerateTag generates repo-based tags

type TagGenDigest added in v0.28.0

type TagGenDigest struct {
	Algorithm string
	Hex       string
}

TagGenDigest contains Algorithm and Hex values of image digest

func (TagGenDigest) Digest added in v0.28.0

func (t TagGenDigest) Digest() (regv1.Hash, error)

Digest returns regv1.Hash instance

type TagGenerator added in v0.28.0

type TagGenerator interface {
	GenerateTag(item imagedigest.DigestWrap, destinationRepo regname.Repository) (regname.Tag, error)
}

TagGenerator interface

type Throttle

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

func NewThrottle

func NewThrottle(max int) Throttle

func (Throttle) Done

func (t Throttle) Done()

func (Throttle) Take

func (t Throttle) Take()

type UILogger added in v0.31.0

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

UILogger struct that interacts with the UI. This logger only writes to the UI when the tty is activated

func NewLogger added in v0.31.0

func NewLogger(ui goui.UI) *UILogger

NewLogger creates a logger that will write to the ui when tty is activated

func (*UILogger) Logf added in v0.31.0

func (n *UILogger) Logf(msg string, args ...interface{})

Logf Prints log to UI when tty is activated

type UIPrefixWriter

type UIPrefixWriter struct {
	goui.UI
	// contains filtered or unexported fields
}

UIPrefixWriter prints a prefix when the underlying ui prints a message

func (*UIPrefixWriter) BeginLinef

func (w *UIPrefixWriter) BeginLinef(msg string, args ...interface{})

BeginLinef writes a message and args adding a configured prefix

func (*UIPrefixWriter) Write

func (w *UIPrefixWriter) Write(data []byte) (int, error)

type WithDigest

type WithDigest interface {
	Digest() (regv1.Hash, error)
}

WithDigest are items that Digest() can be called on

Jump to

Keyboard shortcuts

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