batch

package
v0.0.0-...-5dd6c5c Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fixpath

func Fixpath(name string) string

Fixpath returns an absolute path on the current OS which is mostly relevant for windows.

func ReadImages

func ReadImages(client *rokka.Client, images chan string, r Reader, bar *pb.ProgressBar) error

ReadImages is a simple wrapper around the Reader.Read call. In the future there may be things we can move here.

func WriteImages

func WriteImages(client *rokka.Client, images chan string, results chan OperationResult, w Writer, concurrency int, flushInterval int)

WriteImages creates a group of goroutines bound by the concurrency option. It executes the Writer.Write command for each flushInterval amount of images.

Types

type CopyAllSourceImagesWriter

type CopyAllSourceImagesWriter struct {
	SourceOrganization      string
	DestinationOrganization string
}

CopyAllSourceImagesWriter uses the copy all API to transfer images from one organization to a destination organization.

func (*CopyAllSourceImagesWriter) Write

func (cas *CopyAllSourceImagesWriter) Write(client *rokka.Client, images []string) OperationResult

type DeleteAllSourceImagesWriter

type DeleteAllSourceImagesWriter struct {
	Organization string
}

DeleteAllSourceImagesWriter deletes source images of an organization.

func (*DeleteAllSourceImagesWriter) Write

func (das *DeleteAllSourceImagesWriter) Write(client *rokka.Client, images []string) OperationResult

type MassUploadOptions

type MassUploadOptions struct {
	Recursive  bool
	Extensions []string
}

MassUploadOptions are specific CLI flags for the mass upload CLI cmd.

type MassUploader

type MassUploader struct {
	BasePath     string
	Recursive    bool
	Extensions   []string
	Organization string
	UserMetadata map[string]interface{}
}

MassUploader is both a Reader and Writer which reads from the fileSystem and creates source images in the writer.

func (*MassUploader) Read

func (mu *MassUploader) Read(client *rokka.Client, images chan string, bar *pb.ProgressBar) error

Read walks the directory specified in the CLI and adds the found images (filtered by extensions) to the image channel.

func (*MassUploader) Write

func (mu *MassUploader) Write(client *rokka.Client, images []string) OperationResult

Write creates source images for each image.

type NoopWriter

type NoopWriter struct{}

NoopWriter does not do anything. It is used for the dry run.

func (*NoopWriter) Write

func (nw *NoopWriter) Write(client *rokka.Client, images []string) OperationResult

type OperationResult

type OperationResult struct {
	NotOK int
	OK    int
	Error error
}

OperationResult contains the result of the operation

type Options

type Options struct {
	DryRun      bool
	Concurrency int
	NoProgress  bool
	Force       bool
}

Options are used for the CLI flags for all batch commands

type ProgressCounter

type ProgressCounter interface {
	Count(client *rokka.Client) (int, error)
}

ProgressCounter returns the total images to be processed. It is used for the progress bar and confirmation messages of the batch CLIs. It's an optional interface to implement because not all operations allow to know beforehand how many images there are.

type Reader

type Reader interface {
	Read(client *rokka.Client, images chan string, bar *pb.ProgressBar) error
}

Reader allows to read from an arbitrary location and inserts the image identifications to the channel for concurrent processing. The values within the images channel are string, and therefore can be pretty much anything. The writer used after reading needs to know and understand what an image string actually represents. E.g. in the case of copy-all it's an existing image hash. In the case of massUpload it's a filesystem path to an image.

type SourceImagesReader

type SourceImagesReader struct {
	Organization string
}

SourceImagesReader reads images from rokka on an organization.

func (*SourceImagesReader) Count

func (sir *SourceImagesReader) Count(client *rokka.Client) (int, error)

Count fetches one image in order to get the Total amount of images available.

func (*SourceImagesReader) Read

func (sir *SourceImagesReader) Read(client *rokka.Client, images chan string, bar *pb.ProgressBar) error

Read uses the search API to paginate through all images.

type Writer

type Writer interface {
	Write(client *rokka.Client, images []string) OperationResult
}

Writer operates on the previously found image list and executes a write operation. This can be pretty much anything. For example it could create source images on rokka. Or delete a source image on rokka.

Jump to

Keyboard shortcuts

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