proxy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseImageReference added in v0.2.0

func ParseImageReference(ref name.Reference, defaultRegistry string) (imageName, identifier string)

Types

type ApiResponse added in v0.2.0

type ApiResponse struct {
	Status string `json:"status"`
	Code   int    `json:"code"`

	// Common Response
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`

	// Responses Information
	Extractor *Extractor `json:"extractor,omitempty"`
}

type Builder added in v0.2.0

type Builder struct {
	send.DeltaBundle
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(server *Server, src, dst, plt string) (b *Builder, err error)

func (*Builder) Load added in v0.2.0

func (b *Builder) Load() error

func (*Builder) String added in v0.2.0

func (b *Builder) String() string

func (*Builder) WriteBody added in v0.2.0

func (b *Builder) WriteBody(w http.ResponseWriter, req *http.Request) error

func (*Builder) WriteHeader added in v0.2.0

func (b *Builder) WriteHeader(w http.ResponseWriter, req *http.Request) error

type Configuration added in v0.2.0

type Configuration struct {
	// server
	ListenPort    int    `json:"port"`
	ListenAddress string `json:"address"`
	LogLevel      string `json:"log_level"`

	// database
	PostgresConnectionString string `json:"postgres"`

	// registry
	DefaultRegistry string `json:"default_registry"`

	// goharbor hook
	EnableHarborScanner bool   `json:"harbor"`
	HarborApiKey        string `json:"harbor_apikey"`

	// layer cache timeout (second)
	CacheTimeout int `json:"cache_timeout"`
}

func LoadConfig added in v0.2.0

func LoadConfig(cfgPath string) (c *Configuration, p string, n bool, error error)

func NewConfig added in v0.2.0

func NewConfig() *Configuration

func (*Configuration) SaveConfig added in v0.2.0

func (c *Configuration) SaveConfig() error

type Database added in v0.2.0

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

func NewDatabase added in v0.2.0

func NewDatabase(ctx context.Context, conStr string) (*Database, error)

func (*Database) Close added in v0.2.0

func (d *Database) Close()

func (*Database) GetFilesWithRanks added in v0.2.0

func (d *Database) GetFilesWithRanks(imageSerial int64) ([]*send.RankedFile, error)

func (*Database) GetImage added in v0.2.0

func (d *Database) GetImage(image, identifier, platform string) (serial int64, err error)

func (*Database) GetImageByDigest added in v0.2.0

func (d *Database) GetImageByDigest(image, digest string) (serial int64, err error)

func (*Database) GetLayers added in v0.2.0

func (d *Database) GetLayers(imageSerial int64) ([]*send.ImageLayer, error)

func (*Database) GetManifestAndConfig added in v0.2.0

func (d *Database) GetManifestAndConfig(serial int64) (config, manifest []byte, digest string, err error)

func (*Database) GetRoughDeduplicatedLayers added in v0.2.0

func (d *Database) GetRoughDeduplicatedLayers(fromSerial, toSerial int64) ([]*send.ImageLayer, error)

GetRoughDeduplicatedLayers returns the likely unique files because it would be hard for the database to apply overlayfs correctly, so this deduplication does not consider whiteout files.

func (*Database) GetUniqueFiles added in v0.2.0

func (d *Database) GetUniqueFiles(layers []*send.ImageLayer) ([]*send.File, error)

func (*Database) InitDatabase added in v0.2.0

func (d *Database) InitDatabase() error

func (*Database) InsertFiles added in v0.2.0

func (d *Database) InsertFiles(txn *sql.Tx, fsId int64, entries map[string]*common.TraceableEntry) (err error)

func (*Database) InsertImage added in v0.2.0

func (d *Database) InsertImage(image, hash string,
	config *v1.ConfigFile, manifest *v1.Manifest,
	layerCount int64) (
	serial int64, existing bool,
	err error,
)

func (*Database) InsertLayer added in v0.2.0

func (d *Database) InsertLayer(
	txn *sql.Tx, size int64, imageSerial, stackIndex int64, layerDigest string) (
	fsId int64, existing bool, err error)

func (*Database) SetImageReady added in v0.2.0

func (d *Database) SetImageReady(ready bool, serial int64) error

func (*Database) SetImageTag added in v0.2.0

func (d *Database) SetImageTag(name, tag, platform string, serial int64) error

func (*Database) UpdateFileRanks added in v0.2.0

func (d *Database) UpdateFileRanks(collection *fs.TraceCollection) (fs [][][]int64, err error)

type Extractor added in v0.2.0

type Extractor struct {
	Image string `json:"requested-image"`

	ParsedName string `json:"parsed-image-name"`
	ParsedTag  string `json:"parsed-tag"`
	// contains filtered or unexported fields
}

Extractor extract ToC from starlight-formatted container image and save it to the database

func NewExtractor added in v0.2.0

func NewExtractor(s *Server, image string) (r *Extractor, err error)

func (*Extractor) SaveToC added in v0.2.0

func (ex *Extractor) SaveToC() (res *ApiResponse, err error)

SaveToC save ToC to the backend database and return ApiResponse if success. It does require the container registry is functioning correctly.

type Server added in v0.2.0

type Server struct {
	http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, wg *sync.WaitGroup, cfg *Configuration) (*Server, error)

type StarlightProxy added in v0.2.0

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

func NewStarlightProxy added in v0.2.0

func NewStarlightProxy(ctx context.Context, protocol, server string) *StarlightProxy

func (*StarlightProxy) DeltaImage added in v0.2.0

func (a *StarlightProxy) DeltaImage(from, to, platform string) (
	reader io.ReadCloser,
	manifestSize, configSize, starlightHeaderSize int64,
	digest, slDigest string,
	err error)

func (*StarlightProxy) Notify added in v0.2.0

func (a *StarlightProxy) Notify(ref name.Reference) error

func (*StarlightProxy) Ping added in v0.2.0

func (a *StarlightProxy) Ping() (int64, string, string, error)

func (*StarlightProxy) Report added in v0.2.0

func (a *StarlightProxy) Report(body io.Reader) error

func (*StarlightProxy) SetAuth added in v0.2.0

func (a *StarlightProxy) SetAuth(username, password string)

Jump to

Keyboard shortcuts

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