chartserver

package
v0.0.0-...-44f477e Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultKey the collection name of redis for cache adapter.
	DefaultKey = "beecacheRedis"
)

Functions

func NewRedisCache

func NewRedisCache() cache.Cache

NewRedisCache create new redis cache with default collection name.

Types

type Cache

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

Cache is Redis cache adapter.

func (*Cache) ClearAll

func (rc *Cache) ClearAll() error

ClearAll clean all cache in redis. delete this redis collection.

func (*Cache) Decr

func (rc *Cache) Decr(key string) error

Decr decrease counter in redis.

func (*Cache) Delete

func (rc *Cache) Delete(key string) error

Delete delete cache in redis.

func (*Cache) Get

func (rc *Cache) Get(key string) interface{}

Get cache from redis.

func (*Cache) GetMulti

func (rc *Cache) GetMulti(keys []string) []interface{}

GetMulti get cache from redis.

func (*Cache) Incr

func (rc *Cache) Incr(key string) error

Incr increase counter in redis.

func (*Cache) IsExist

func (rc *Cache) IsExist(key string) bool

IsExist check cache's existence in redis.

func (*Cache) Put

func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error

Put put cache to redis.

func (*Cache) StartAndGC

func (rc *Cache) StartAndGC(config string) error

StartAndGC start redis cache adapter. config is like {"key":"collection key","conn":"connection info","dbNum":"0","masterName":"mymaster"} the cache item in redis are stored forever, so no gc operation.

type ChartCache

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

ChartCache is designed to cache some processed data for repeated accessing to improve the performance

func NewChartCache

func NewChartCache(config *ChartCacheConfig) *ChartCache

NewChartCache is constructor of ChartCache If return nil, that means no cache is enabled for chart repository server

func (*ChartCache) GetChart

func (chc *ChartCache) GetChart(chartDigest string) *ChartVersionDetails

GetChart trys to retrieve it from the cache If hit, return the cached item; otherwise, nil object is returned

func (*ChartCache) IsEnabled

func (chc *ChartCache) IsEnabled() bool

IsEnabled to indicate if the chart cache is successfully enabled The cache may be disabled if

user does not set
wrong configurations

func (*ChartCache) PutChart

func (chc *ChartCache) PutChart(chart *ChartVersionDetails)

PutChart caches the detailed data of chart version

type ChartCacheConfig

type ChartCacheConfig struct {
	// Only support 'in-memory' and 'redis' now
	DriverType string

	// Align with config
	Config string
}

ChartCacheConfig keeps the configurations of ChartCache

type ChartClient

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

ChartClient is a http client to get the content from the external http server

func NewChartClient

func NewChartClient(credential *Credential) *ChartClient

NewChartClient is constructor of ChartClient credential can be nil

func (*ChartClient) DeleteContent

func (cc *ChartClient) DeleteContent(addr string) error

DeleteContent sends deleting request to the addr to delete content

func (*ChartClient) GetContent

func (cc *ChartClient) GetContent(addr string) ([]byte, error)

GetContent get the bytes from the specified url

type ChartInfo

type ChartInfo struct {
	Name          string    `json:"name"`
	TotalVersions uint32    `json:"total_versions"`
	LatestVersion string    `json:"latest_version"`
	Created       time.Time `json:"created"`
	Updated       time.Time `json:"updated"`
	Icon          string    `json:"icon"`
	Home          string    `json:"home"`
	Deprecated    bool      `json:"deprecated"`
}

ChartInfo keeps the information of the chart

type ChartOperator

type ChartOperator struct{}

ChartOperator is designed to process the contents of the specified chart version to get more details

func (*ChartOperator) GetChartData

func (cho *ChartOperator) GetChartData(content []byte) (*chart.Chart, error)

GetChartData returns raw data of chart

func (*ChartOperator) GetChartDetails

func (cho *ChartOperator) GetChartDetails(content []byte) (*ChartVersionDetails, error)

GetChartDetails parse the details from the provided content bytes

func (*ChartOperator) GetChartList

func (cho *ChartOperator) GetChartList(content []byte) ([]*ChartInfo, error)

GetChartList returns a reorganized chart list

func (*ChartOperator) GetChartVersions

func (cho *ChartOperator) GetChartVersions(content []byte) (ChartVersions, error)

GetChartVersions returns the chart versions

type ChartVersion

type ChartVersion struct {
	helm_repo.ChartVersion
	Labels []*model.Label `json:"labels"`
}

ChartVersion extends the helm ChartVersion with additional labels

type ChartVersionDetails

type ChartVersionDetails struct {
	Metadata     *helm_repo.ChartVersion `json:"metadata"`
	Dependencies []*chart.Dependency     `json:"dependencies"`
	Values       map[string]interface{}  `json:"values"`
	Files        map[string]string       `json:"files"`
	Security     *SecurityReport         `json:"security"`
	Labels       []*model.Label          `json:"labels"`
}

ChartVersionDetails keeps the detailed data info of the chart version

type ChartVersions

type ChartVersions []*ChartVersion

ChartVersions is an array of extended ChartVersion

type Controller

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

Controller is used to handle flows of related requests based on the corresponding handlers A reverse proxy will be created and managed to proxy the related traffics between API and backend chart server

func NewController

func NewController(backendServer *url.URL, middlewares ...func(http.Handler) http.Handler) (*Controller, error)

NewController is constructor of the chartserver.Controller

func (*Controller) APIPrefix

func (c *Controller) APIPrefix(namespace string) string

APIPrefix returns the API prefix path of calling backend chart service.

func (*Controller) DeleteChart

func (c *Controller) DeleteChart(namespace, chartName string) error

DeleteChart deletes all the chart versions of the specified chart under the namespace. See @ServiceHandler.DeleteChart

func (*Controller) DeleteChartVersion

func (c *Controller) DeleteChartVersion(namespace, chartName, version string) error

DeleteChartVersion will delete the specified version of the chart See @ServiceHandler.DeleteChartVersion

func (*Controller) GetChart

func (c *Controller) GetChart(namespace, chartName string) (ChartVersions, error)

GetChart returns all the chart versions under the specified chart See @ServiceHandler.GetChart

func (*Controller) GetChartVersion

func (c *Controller) GetChartVersion(namespace, name, version string) (*helm_repo.ChartVersion, error)

GetChartVersion returns the summary of the specified chart version. See @ServiceHandler.GetChartVersion

func (*Controller) GetChartVersionDetails

func (c *Controller) GetChartVersionDetails(namespace, chartName, version string) (*ChartVersionDetails, error)

GetChartVersionDetails get the specified version for one chart This handler should return the details of the chart version, maybe including metadata,dependencies and values etc. See @ServiceHandler.GetChartVersionDetails

func (*Controller) GetCountOfCharts

func (c *Controller) GetCountOfCharts(namespaces []string) (uint64, error)

GetCountOfCharts calculates and returns the total count of charts under the specified namespaces. See @ServiceHandler.GetCountOfCharts

func (*Controller) GetIndexFile

func (c *Controller) GetIndexFile(namespaces []string) (*helm_repo.IndexFile, error)

GetIndexFile will read the index.yaml under all namespaces and merge them as a single one Please be aware that, to support this function, the backend chart repository server should enable multi-tenancies

See @ServiceHandler.GetIndexFile

func (*Controller) ListCharts

func (c *Controller) ListCharts(namespace string) ([]*ChartInfo, error)

ListCharts gets the chart list under the namespace See @ServiceHandler.ListCharts

func (*Controller) ProxyTraffic

func (c *Controller) ProxyTraffic(w http.ResponseWriter, req *http.Request)

ProxyTraffic implements the interface method.

func (*Controller) SearchChart

func (c *Controller) SearchChart(q string, namespaces []string) ([]*search.Result, error)

SearchChart search charts in the specified namespaces with the keyword q. RegExp mode is enabled as default. For each chart, only the latest version will shown in the result list if matched to avoid duplicated entries. Keep consistent with `helm search` command.

type Credential

type Credential struct {
	Username string
	Password string
}

Credential keeps the username and password for the basic auth

type DigitalSignature

type DigitalSignature struct {
	Signed     bool   `json:"signed"`
	Provenance string `json:"prov_file"`
}

DigitalSignature used to indicate if the chart has been signed

type ProxyEngine

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

ProxyEngine is used to proxy the related traffics

func NewProxyEngine

func NewProxyEngine(target *url.URL, cred *Credential, middlewares ...func(http.Handler) http.Handler) *ProxyEngine

NewProxyEngine is constructor of NewProxyEngine

func (*ProxyEngine) ServeHTTP

func (pe *ProxyEngine) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP serves the incoming http requests

type ProxyTrafficHandler

type ProxyTrafficHandler interface {
	// Proxy the traffic to the backended server
	//
	// Req *http.Request     : The incoming http request
	// w http.ResponseWriter : The response writer reference
	ProxyTraffic(w http.ResponseWriter, req *http.Request)
}

ProxyTrafficHandler defines the handler methods to handle the proxy traffic.

type SecurityReport

type SecurityReport struct {
	Signature *DigitalSignature `json:"signature"`
}

SecurityReport keeps the info related with security e.g.: digital signature, vulnerability scanning etc.

type ServiceHandler

type ServiceHandler interface {
	// ListCharts lists all the charts under the specified namespace.
	//
	//  namespace string: the chart namespace.
	//
	//  If succeed, a chart info list with nil error will be returned;
	//  otherwise, a non-nil error will be got.
	ListCharts(namespace string) ([]*ChartInfo, error)

	// Get all the chart versions of the specified chart under the namespace.
	//
	// namespace string: the chart namespace.
	// chartName string: the name of the chart, e.g: "harbor"
	//
	// If succeed, a chart version list with nil error will be returned;
	// otherwise, a non-nil error will be got.
	GetChart(namespace, chartName string) (helm_repo.ChartVersions, error)

	// Get the detailed info of the specified chart version under the namespace.
	// The detailed info includes chart summary, dependencies, values and signature status etc.
	//
	// namespace string: the chart namespace.
	// chartName string: the name of the chart, e.g: "harbor"
	// version string: the SemVer version of the chart, e.g: "0.2.0"
	//
	// If succeed, chart version details with nil error will be returned;
	// otherwise, a non-nil error will be got.
	GetChartVersionDetails(namespace, chartName, version string) (*ChartVersionDetails, error)

	// SearchChart search charts in the specified namespaces with the keyword q.
	// RegExp mode is enabled as default.
	// For each chart, only the latest version will shown in the result list if matched to avoid duplicated entries.
	// Keep consistent with `helm search` command.
	//
	// q string            : the searching keyword
	// namespaces []string : the search namespace scope
	//
	// If succeed, a search result list with nil error will be returned;
	// otherwise, a non-nil error will be got.
	SearchChart(q string, namespaces []string) ([]*search.Result, error)

	// GetIndexFile will read the index.yaml under all namespaces and merge them as a single one
	// Please be aware that, to support this function, the backend chart repository server should
	// enable multi-tenancies
	//
	// namespaces []string : all the namespaces with accessing permissions
	//
	// If succeed, a unified merged index file with nil error will be returned;
	// otherwise, a non-nil error will be got.
	GetIndexFile(namespaces []string) (*helm_repo.IndexFile, error)

	// Get the chart summary of the specified chart version.
	//
	// namespace string: the chart namespace.
	// chartName string: the name of the chart, e.g: "harbor"
	// version string: the SemVer version of the chart, e.g: "0.2.0"
	//
	// If succeed, chart version summary with nil error will be returned;
	// otherwise, a non-nil error will be got.
	GetChartVersion(namespace, name, version string) (*helm_repo.ChartVersion, error)

	// DeleteChart deletes all the chart versions of the specified chart under the namespace.
	//
	// namespace string: the chart namespace.
	// chartName string: the name of the chart, e.g: "harbor"
	//
	// If succeed, a nil error will be returned;
	// otherwise, a non-nil error will be got.
	DeleteChart(namespace, chartName string) error

	// GetCountOfCharts calculates and returns the total count of charts under the specified namespaces.
	//
	// namespaces []string : the namespaces to count charts
	//
	// If succeed, a unsigned integer with nil error will be returned;
	// otherwise, a non-nil error will be got.
	GetCountOfCharts(namespaces []string) (uint64, error)
}

ServiceHandler defines the related methods to handle kinds of chart service requests.

Jump to

Keyboard shortcuts

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