cim

package
v0.0.0-...-2ae20b0 Latest Latest
Warning

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

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

Documentation

Overview

The central package for container-image-mirror controls

Index

Constants

This section is empty.

Variables

View Source
var (
	ConfigGlobalTagLimit          uint          = 1024
	ConfigResolveImagesTimeout    time.Duration = 3 * time.Minute
	ConfigResolveTagsTimeout      time.Duration = 3 * time.Minute
	ConfigCopyImageDefaultTimeout time.Duration = 60 * time.Minute
	ConfigCopyImageTimeout        time.Duration = ConfigCopyImageDefaultTimeout
	ConfigDeleteImageTimeout      time.Duration = 5 * time.Minute
	ConfigEventProcessingTimeout  time.Duration = 10 * time.Second
	ConfigBufferSize              uint          = ConfigGlobalTagLimit
	ConfigNumWorkers              uint          = 8 * uint(runtime.NumCPU())
	ConfigNumParallelCopyJobs     uint          = 4 * uint(runtime.NumCPU())
	ConfigMaxMemBytes             uint64        = 6 * 1024 * 1024 * 1024
)

Functions

func MirrorConfigFromFile

func MirrorConfigFromFile(path string) (*cimapi.MirrorConfig, error)

func Run

func Run(config *cimapi.MirrorConfig, ctx context.Context, log logr.Logger) error

func WrapStdLogger

func WrapStdLogger(logger logr.InfoLogger) *log.Logger

WrapStdLogger wraps a github.com/go-logr/logr into a log.Logger from the golang standard library

Types

type CounterType

type CounterType string
const (
	CounterTypeTotal    CounterType = "Total"
	CounterTypeResolved CounterType = "Resolved"
	CounterTypeCopied   CounterType = "Copied"
	CounterTypeDeleted  CounterType = "Deleted"
	CounterTypeFailed   CounterType = "Failed"
)

type Event

type Event struct {
	Type   EventType
	Source interface{}
	Data   interface{}
}

func NewStatusEvent

func NewStatusEvent(obj string, objType ObjectType, statusType StatusType, val bool) Event

type EventHandler

type EventHandler func(ctx context.Context, log logr.Logger, evt Event) error

type EventType

type EventType string
const (
	EventTypeStatusChange EventType = "StatusChange"
)

type InterleaveBuffer

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

InterleaveBuffer assists interleaving the copyJob stream with the goal of avoiding (if possible) two tags of the same image being copied in parallel since locally restricted sequential copy would allow to use remote registry mounts for shared layers between tags of the same image

func NewInterleaveBuffer

func NewInterleaveBuffer(interval uint) *InterleaveBuffer

NewInterleaveBuffer creates a new InterleaveBuffer that attempts to interleave multiple copyJobs while considering the <interval> between different tags of the same image Usually, interval should be set to the number of parallel go routines (aka size of the worker pool) in the COPY stage

func (*InterleaveBuffer) FlushBuffer

func (i *InterleaveBuffer) FlushBuffer(out chan copyJob)

FlushBuffer handles ordered emptying of elements still in the buffer after all ticks are processed

func (*InterleaveBuffer) Tick

func (i *InterleaveBuffer) Tick(in *copyJob) *copyJob

Tick represents one interleaved iteration Every tick the buffer checks if the tag should be interleaved and returns the same tag or a replacement tag for the current epoch

type ObjectType

type ObjectType string
const (
	ObjectTypeSourceDir ObjectType = "SourceDirectory"
	ObjectTypeImage     ObjectType = "Image"
	ObjectTypeTag       ObjectType = "Tag"
)

type Runner

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

func NewRunner

func NewRunner(config *cimapi.MirrorConfig, log logr.Logger) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run executes the cim run

func (*Runner) Status

func (r *Runner) Status() runnerStatus

func (*Runner) Summary

func (r *Runner) Summary() Summary

Summary returns a summary of the last executed run

type StatusEventData

type StatusEventData struct {
	ObjType    ObjectType
	StatusType StatusType
	Success    bool
}

type StatusType

type StatusType string
const (
	StatusTypeResolved StatusType = "Resolved"
	StatusTypeCopied   StatusType = "Copied"
	StatusTypeDeleted  StatusType = "Deleted"
)

type StdLogWriter

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

StdLogger represents an abstraction to wrap a logr logger into a io.Writer. We use it to integrate golang std log.Logger logs from github.com/google/go-containerregistry

func (*StdLogWriter) Write

func (s *StdLogWriter) Write(p []byte) (n int, err error)

type Summary

type Summary struct {
	NewTags     []TagInfo
	DeletedTags []TagInfo
}

func (Summary) String

func (s Summary) String() string

type TagInfo

type TagInfo string

func (TagInfo) String

func (t TagInfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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