imager

package
v0.0.0-...-ee9d8c9 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

An Imager runs kubectl and communicates with the server to image a given container. Multiple imagers may be run at once.

Index

Constants

View Source
const CONTAINER_NAME_PREFIX = "Defaulting debug container name to "

Variables

This section is empty.

Functions

func SimpleImagePods

func SimpleImagePods(ctx context.Context, config ImagerConfig, pods []string) []error

Simple function to image one or more pods at once. The caller must fill in all fields of 'config' other than 'Pod'. Returns an array of errors returned by the imagers.

func WaitForServerStart

func WaitForServerStart(rd *bufio.Reader) (containerName string, err error)

Reads lines from the reader until it has read the auto-generated debug container name and the server start message. Returns the container name.

Types

type ClientApi

type ClientApi struct {
	*rpc.Client
	// contains filtered or unexported fields
}

func NewClientApi

func NewClientApi(ctx context.Context, conn io.ReadWriteCloser) *ClientApi

func (*ClientApi) GenerateDiff

func (c *ClientApi) GenerateDiff(meta *fsdiff.DirMeta) (err error)

func (*ClientApi) GetTargetRoots

func (c *ClientApi) GetTargetRoots() ([]string, error)

Attemts to determine a path to access the root of the target container from the debug container.

func (*ClientApi) RpcCall

func (c *ClientApi) RpcCall(method string, args, reply any) error

func (*ClientApi) SetConfig

func (c *ClientApi) SetConfig(config *tkserver.ServerConfig) (err error)

func (*ClientApi) TarProgress

func (c *ClientApi) TarProgress() (float64, error)

func (*ClientApi) TarStart

func (c *ClientApi) TarStart() error

type ImageCache

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

Caches DirMeta objects for base images (tar files). This way in a batch-processing scenario we're not re-reading the same tar file mulitple times.

func (*ImageCache) Request

func (ic *ImageCache) Request(fpath string) *ImageRequest

type ImageRequest

type ImageRequest struct {
	*task.BaseTask
	// Resolved path
	Path string
}

func (*ImageRequest) Value

func (ir *ImageRequest) Value() *fsdiff.DirMeta

type Imager

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

func NewImager

func NewImager(parent context.Context, config ImagerConfig) *Imager

Returns a new imager created with the given configuration.

func (*Imager) CloseUpdates

func (m *Imager) CloseUpdates()

Close the update channel so the imager does not block.

func (*Imager) DownloadFile

func (m *Imager) DownloadFile(remotePath, localPath string) error

Download a file

func (*Imager) GetOutputName

func (m *Imager) GetOutputName() string

Returns the tar file that will be created

func (*Imager) GetProgress

func (m *Imager) GetProgress() float64

Returns the progress amount on the current task, if applicable, or -1 if the current task has no progress indicator.

func (*Imager) GetTask

func (m *Imager) GetTask() string

Returns the current task name

func (*Imager) Start

func (m *Imager) Start() (err error)

func (*Imager) Updates

func (m *Imager) Updates() <-chan struct{}

Gets the update channel, which will trigger when a progress update occurs. Current progress and current task can be obtained with the relevant methods.

type ImagerConfig

type ImagerConfig struct {
	// Command that runs 'kubectl'
	KubectlCmd []string
	// Pod name to image
	Pod string
	// Container on the pod
	Container string
	// Debug image name and version (default: "taki-collector")
	DebugImage string
	// List of paths to ignore
	Ignored []string
	// Image cache instance
	MetaCache *ImageCache
	// Base image path
	BaseImage string
}

func (ImagerConfig) Defaults

func (c ImagerConfig) Defaults() ImagerConfig

Returns a copy of the config with default values set if they weren't already.

type ProcIO

type ProcIO struct {
	*bufio.ReadWriter
	// contains filtered or unexported fields
}

Takes an exec.Cmd and wraps the Stdin and Stdout/Stderr in buffered readers/writers. Stdout and Stderr are combined into one stream.

func NewProcIO

func NewProcIO(proc *exec.Cmd) (*ProcIO, error)

func (*ProcIO) Close

func (p *ProcIO) Close() error

Jump to

Keyboard shortcuts

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