core

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewClient = func(repo *api.Repo) (Client, error) {
	switch repo.Kind {
	case api.Kind_HELM:
		return NewClassicHelmClient(repo), nil
	case api.Kind_CHARTMUSEUM:
		return NewChartMuseumClient(repo), nil
	case api.Kind_HARBOR:
		return NewHarborClient(repo), nil
	default:
		return nil, fmt.Errorf("unsupported repo kind %q", repo.Kind)
	}
}

NewClient returns a client implementation for the given repo.

The func is exposed as a var to allow tests to temporarily replace its implementation, e.g. to return a fake.

View Source
var NewClientV2 = func(repo *api.Repo, opts ...types.Option) (ClientV2, error) {
	copts := &types.ClientOpts{}
	for _, o := range opts {
		o(copts)
	}

	cacheDir := copts.GetCache()
	if cacheDir == "" {
		dir, err := ioutil.TempDir("", "client")
		if err != nil {
			return nil, errors.Annotatef(err, "creating temporary dir")
		}
		cacheDir = dir
	}
	c, err := cache.New(cacheDir, repo.GetUrl())
	if err != nil {
		return nil, errors.Annotatef(err, "allocating cache")
	}

	switch repo.Kind {
	case api.Kind_HELM:
		return helmclassic.New(repo, c)
	case api.Kind_CHARTMUSEUM:
		return chartmuseum.New(repo, c)
	case api.Kind_HARBOR:
		return harbor.New(repo, c)
	case api.Kind_OCI:
		return oci.New(repo, c)
	case api.Kind_LOCAL:
		return local.New(repo.Path)
	default:
		return nil, errors.Errorf("unsupported repo kind %q", repo.Kind)
	}
}

NewClientV2 returns a ClientV2 object

The func is exposed as a var to allow tests to temporarily replace its implementation, e.g. to return a fake.

Functions

func ValidateChartTgz

func ValidateChartTgz(filepath string) error

ValidateChartTgz validates if a chart is a valid tgz file

Types

type ChartMuseumClient

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

ChartMuseumClient implements Client for a ChartMuseum implementation.

func NewChartMuseumClient

func NewChartMuseumClient(repo *api.Repo) *ChartMuseumClient

NewChartMuseumClient creates a new `ChartMuseumClient`.

func (*ChartMuseumClient) ChartExists

func (c *ChartMuseumClient) ChartExists(name string, version string, index *helmRepo.IndexFile) (bool, error)

ChartExists checks if a chart exists in the repo.

func (*ChartMuseumClient) Fetch

func (c *ChartMuseumClient) Fetch(filepath string, name string, version string, sourceRepo *api.Repo, index *helmRepo.IndexFile) error

Fetch downloads a packaged chart from ChartsMuseum repository.

func (*ChartMuseumClient) Push

func (c *ChartMuseumClient) Push(filepath string, targetRepo *api.Repo) error

Push publishes a packaged chart to ChartsMuseum repository.

type ClassicHelmClient

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

ClassicHelmClient implements Client for a Helm classic implementation.

func NewClassicHelmClient

func NewClassicHelmClient(repo *api.Repo) *ClassicHelmClient

NewClassicHelmClient creates a new `ClassicHelmClient`.

func (*ClassicHelmClient) ChartExists

func (c *ClassicHelmClient) ChartExists(name string, version string, index *helmRepo.IndexFile) (bool, error)

ChartExists checks if a chart exists in the repo.

func (*ClassicHelmClient) Fetch

func (c *ClassicHelmClient) Fetch(filepath string, name string, version string, sourceRepo *api.Repo, index *helmRepo.IndexFile) error

Fetch downloads a packaged chart from a classic helm repository.

func (*ClassicHelmClient) Push

func (c *ClassicHelmClient) Push(filepath string, targetRepo *api.Repo) error

Push publishes a packaged chart to classic helm repository.

type Client

type Client interface {
	Fetch(filepath string, name string, version string, sourceRepo *api.Repo, index *helmRepo.IndexFile) error
	Push(filepath string, targetRepo *api.Repo) error
	ChartExists(name string, version string, index *helmRepo.IndexFile) (bool, error)
}

Client defines the methods that a chart client should implement.

type ClientV2

type ClientV2 interface {
	Reader
	Writer
}

ClientV2 defines the methods that a chart client should implement.

type HarborClient

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

HarborClient implements Client for a Harbor implementation.

func NewHarborClient

func NewHarborClient(repo *api.Repo) *HarborClient

NewHarborClient creates a new `HarborClient`.

func (*HarborClient) ChartExists

func (c *HarborClient) ChartExists(name string, version string, index *helmRepo.IndexFile) (bool, error)

ChartExists checks if a chart exists in the repo.

func (*HarborClient) Fetch

func (c *HarborClient) Fetch(filepath string, name string, version string, sourceRepo *api.Repo, index *helmRepo.IndexFile) error

Fetch downloads a packaged chart from Harbor repository.

func (*HarborClient) Push

func (c *HarborClient) Push(filepath string, targetRepo *api.Repo) error

Push publishes a packaged chart to Harbor repository.

type Reader

type Reader interface {
	Fetch(name string, version string) (string, error)
	List() ([]string, error)
	ListChartVersions(name string) ([]string, error)
	Has(name string, version string) (bool, error)
	GetChartDetails(name string, version string) (*types.ChartDetails, error)

	// Reload reloads or refresh the client-side data, in case it needs it
	Reload() error
}

Reader defines the methods that a ReadOnly chart client should implement.

type Writer

type Writer interface {
	Upload(filepath string, name string, version string) error
}

Writer defines the methods that a WriteOnly chart client should implement.

Jump to

Keyboard shortcuts

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