provider

package
v0.0.0-...-e417875 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DriverStatusHealthy represents the healthy status
	DriverStatusHealthy = "Healthy"

	// DriverStatusUnHealthy represents the unhealthy status
	DriverStatusUnHealthy = "Unhealthy"
)
View Source
const (
	// DriverDragonfly represents the driver for dragonfly
	DriverDragonfly = "dragonfly"
	// DriverKraken represents the driver for kraken
	DriverKraken = "kraken"
)
View Source
const (
	// SupportedType indicates the supported preheating type 'image'.
	SupportedType = "image"
)

Variables

This section is empty.

Functions

func MockDragonflyProvider

func MockDragonflyProvider() *httptest.Server

MockDragonflyProvider mocks a Dragonfly server.

func MockKrakenProvider

func MockKrakenProvider() *httptest.Server

MockKrakenProvider mocks a Kraken server.

Types

type DragonflyDriver

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

DragonflyDriver implements the provider driver interface for Alibaba dragonfly. More details, please refer to https://github.com/alibaba/Dragonfly

func (*DragonflyDriver) CheckProgress

func (dd *DragonflyDriver) CheckProgress(taskID string) (*PreheatingStatus, error)

CheckProgress implements @Driver.CheckProgress.

func (*DragonflyDriver) GetHealth

func (dd *DragonflyDriver) GetHealth() (*DriverStatus, error)

GetHealth implements @Driver.GetHealth.

func (*DragonflyDriver) Preheat

func (dd *DragonflyDriver) Preheat(preheatingImage *PreheatImage) (*PreheatingStatus, error)

Preheat implements @Driver.Preheat.

func (*DragonflyDriver) Self

func (dd *DragonflyDriver) Self() *Metadata

Self implements @Driver.Self.

type Driver

type Driver interface {
	// Self returns the metadata of the driver.
	// The metadata includes: name, icon(optional), maintainers(optional), version and source repo.
	Self() *Metadata

	// Try to get the health status of the driver.
	// If succeed, a non nil status object will be returned;
	// otherwise, a non nil error will be set.
	GetHealth() (*DriverStatus, error)

	// Preheat the specified image
	// If succeed, a non nil result object with preheating task id will be returned;
	// otherwise, a non nil error will be set.
	Preheat(preheatingImage *PreheatImage) (*PreheatingStatus, error)

	// Check the progress of the preheating process.
	// If succeed, a non nil status object with preheating status will be returned;
	// otherwise, a non nil error will be set.
	CheckProgress(taskID string) (*PreheatingStatus, error)
}

Driver defines the capabilities one distribution provider should have. Includes:

Self descriptor
Health checking
Preheat related : Preheat means transfer the preheating image to the network of distribution provider in advance.

func DragonflyFactory

func DragonflyFactory(instance *provider.Instance) (Driver, error)

DragonflyFactory creates dragonfly driver

func KrakenFactory

func KrakenFactory(instance *provider.Instance) (Driver, error)

KrakenFactory creates kraken driver

type DriverStatus

type DriverStatus struct {
	Status string `json:"status"`
}

DriverStatus keeps the health status of driver.

type Factory

type Factory func(instance *provider.Instance) (Driver, error)

Factory is responsible to create a new driver based on the metadata.

func GetProvider

func GetProvider(ID string) (Factory, bool)

GetProvider returns the driver factory identified by the ID.

If exists, bool flag will be set to be true and a non-nil reference will be returned.

type KrakenDriver

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

KrakenDriver implements the provider driver interface for Uber kraken. More details, please refer to https://github.com/uber/kraken

func (*KrakenDriver) CheckProgress

func (kd *KrakenDriver) CheckProgress(taskID string) (*PreheatingStatus, error)

CheckProgress implements @Driver.CheckProgress. TODO: This should be improved later

func (*KrakenDriver) GetHealth

func (kd *KrakenDriver) GetHealth() (*DriverStatus, error)

GetHealth implements @Driver.GetHealth.

func (*KrakenDriver) Preheat

func (kd *KrakenDriver) Preheat(preheatingImage *PreheatImage) (*PreheatingStatus, error)

Preheat implements @Driver.Preheat.

func (*KrakenDriver) Self

func (kd *KrakenDriver) Self() *Metadata

Self implements @Driver.Self.

type Metadata

type Metadata struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Icon        string   `json:"icon,omitempty"`
	Maintainers []string `json:"maintainers,omitempty"`
	Version     string   `json:"version"`
	Source      string   `json:"source,omitempty"`
}

Metadata contains the basic information of the provider.

func ListProviders

func ListProviders() ([]*Metadata, error)

ListProviders returns all the registered drivers.

type PreheatImage

type PreheatImage struct {
	// The image content type, only support 'image' now
	Type string `json:"type"`

	// The access URL of the preheating image
	URL string `json:"url"`

	// The headers which will be sent to the above URL of preheating image
	Headers map[string]interface{} `json:"headers"`

	// The image name
	ImageName string `json:"image,omitempty"`

	// The tag
	Tag string `json:"tag,omitempty"`

	// Digest of the preheating image
	Digest string `json:"digest"`

	// Scope indicates the preheat scope.
	Scope string `json:"scope,omitempty"`
}

PreheatImage contains related information which can help providers to get/pull the images.

func (*PreheatImage) FromJSON

func (img *PreheatImage) FromJSON(data string) error

FromJSON build preheating image from the given data.

func (*PreheatImage) ToJSON

func (img *PreheatImage) ToJSON() (string, error)

ToJSON encodes the preheating image to JSON data.

func (*PreheatImage) Validate

func (img *PreheatImage) Validate() error

Validate PreheatImage

type PreheatingStatus

type PreheatingStatus struct {
	TaskID     string `json:"task_id"`
	Status     string `json:"status"`
	Message    string `json:"message,omitempty"`
	Error      string `json:"error,omitempty"`
	StartTime  string `json:"start_time"`
	FinishTime string `json:"finish_time"`
}

PreheatingStatus contains the related results/status of the preheating operation from the provider.

func (*PreheatingStatus) String

func (ps *PreheatingStatus) String() string

String format of PreheatingStatus

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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