catalog

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatHub

func FormatHub(hub string) string

FormatHub formats the message about selected Hub for the user.

func List

func List(lister Lister, all bool, format constants.Format) error

List uses the provided lister to obtain a list of application and cluster images and displays them in the specified format.

func SetRemoteFunc

func SetRemoteFunc(f NewRemoteFunc)

SetRemoteFunc sets the function that creates remote application catalog.

This allows external implementations to override the default behavior of returning default distribution portal.

Types

type Catalog

type Catalog interface {
	// Search searches the application catalog.
	//
	// The provided pattern is treated as an application name substring. If
	// the pattern is empty, all applications are returned.
	Search(pattern string) ([]app.Application, error)
	// Download downloads an application from the catalog.
	Download(name, version string) (io.ReadCloser, error)
	// GetName returns the catalog name.
	GetName() string
}

Catalog defines an interface for an application catalog.

func New

func New(config Config) (Catalog, error)

New returns a new application catalog instance.

func NewLocal

func NewLocal() (Catalog, error)

NewLocal returns application catalog for the local cluster.

func NewRemote

func NewRemote() (Catalog, error)

NewRemote returns application catalog for the default distribution Ops Center.

func NewRemoteFor

func NewRemoteFor(name string) (Catalog, error)

NewRemoteFor returns client for the specified application catalog.

type Config

type Config struct {
	// Name is the catalog name.
	Name string
	// Operator is the cluster or Ops Center operator.
	Operator ops.Operator
	// Apps is the cluster or Ops Center application service.
	Apps app.Applications
}

Config is the application catalog configuration.

func (Config) Check

func (c Config) Check() error

Check validates the application catalog config.

type DownloadRequest

type DownloadRequest struct {
	// Application specifies application to download.
	Application loc.Locator
}

DownloadRequest describes a request to download an application tarball.

type DownloadResult

type DownloadResult struct {
	// Path is the path to the downloaded tarball.
	Path string
}

DownloadResult is an application download result.

func Download

func Download(req DownloadRequest) (*DownloadResult, error)

Download downloads the specified application and returns its path.

func (*DownloadResult) Close

func (r *DownloadResult) Close() error

Close removes the downloaded tarball.

Implements io.Closer.

type HubLister

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

HubLister lists applications on the hub

func NewLister

func NewLister() (*HubLister, error)

NewLister returns a lister with S3 hub backend.

func (*HubLister) Hub

func (l *HubLister) Hub() string

Hub returns the name of the open-source Hub.

func (*HubLister) List

func (l *HubLister) List(all bool) (result ListItems, err error)

List returns application and cluster images from the hub.

type ListItem

type ListItem interface {
	// GetName returns the image name.
	GetName() string
	// GetVersion returns the image version.
	GetVersion() semver.Version
	// GetType returns the image type (application or cluster).
	GetType() string
	// GetCreated returns the image creation time.
	GetCreated() time.Time
	// GetDescription returns the image description.
	GetDescription() string
}

ListItem defines interface for a single list item.

func NewListItemFromApp

func NewListItemFromApp(app app.Application) (ListItem, error)

NewListItemFromApp makes a list item from the app service application.

func NewListItemFromHubApp

func NewListItemFromHubApp(app hub.App) (ListItem, error)

NewListItemFromHubApp makes a list item from the hub application item.

type ListItems

type ListItems []ListItem

ListItems is a collection of application and cluster images.

func (ListItems) Latest

func (l ListItems) Latest() (result ListItems, err error)

Latest returns a list of items containing latest stable versions of application and cluster images from this list.

func (ListItems) Len

func (l ListItems) Len() int

Len implements sort.Interface.

func (ListItems) Less

func (l ListItems) Less(i, j int) bool

Less implements sort.Interace.

The items are sorted first by type (cluster images appear before application images), then by name (lexicographically) and finally by semantic version.

func (ListItems) Swap

func (l ListItems) Swap(i, j int)

Swap implements sort.Interface.

type Lister

type Lister interface {
	// List retrieves application and cluster images.
	List(all bool) (ListItems, error)
	// Hub returns the name of the Hub this lister talks to.
	Hub() string
}

Lister defines common interface for listing application and cluster images.

type NewRemoteFunc

type NewRemoteFunc func() (Catalog, error)

NewRemoteFunc defines a function that returns a new instance of a remote catalog.

type SearchRequest

type SearchRequest struct {
	// Pattern is an optional application name pattern (a substring).
	Pattern string
	// Local is whether to search local cluster catalog.
	Local bool
	// Remote is whether to search remote Ops Center catalog.
	Remote bool
}

SearchRequest describes an application search request.

type SearchResult

type SearchResult struct {
	// Apps maps the catalog name (such as 'get.gravitational.io' or local
	// cluster name) to a list of applications found in it.
	Apps map[string][]app.Application
}

SearchResult is an application search result.

func Search(req SearchRequest) (*SearchResult, error)

Search searches local and/or remote catalogs for the specified application.

Jump to

Keyboard shortcuts

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