Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAddonName(addonName string) error
- func ClassifyItemByPattern(meta *SourceMeta, r AsyncReader) map[string][]Item
- func DisableAddon(ctx context.Context, cli client.Client, name string, config *rest.Config, ...) error
- func DryRunAddon(installer *Installer)
- func EnableAddon(ctx context.Context, name string, version string, cli client.Client, ...) (string, error)
- func EnableAddonByLocalDir(ctx context.Context, name string, dir string, cli client.Client, ...) (string, error)
- func FetchAddonRelatedApp(ctx context.Context, cli client.Client, addonName string) (*v1beta1.Application, error)
- func FetchArgsFromSecret(sec *v1.Secret) (map[string]interface{}, error)
- func GetAddonLegacyParameters(ctx context.Context, k8sClient client.Client, addonName string) (map[string]interface{}, error)
- func GetHelmRepo(ctx context.Context, c client.Client, repoName string) (*cmhelm.Repo, error)
- func GetPatternFromItem(it Item, r AsyncReader, rootPath string) string
- func IsAddonDir(dirName string) (bool, error)
- func IsVersionRegistry(r Registry) bool
- func MakeChartCompatible(addonDir string, overwrite bool) error
- func MergeAddonInstallArgs(ctx context.Context, k8sClient client.Client, addonName string, ...) (map[string]interface{}, error)
- func NewAddonError(msg string) error
- func OverrideDefinitions(installer *Installer)
- func PackageAddon(addonDictPath string) (string, error)
- func RenderApp(ctx context.Context, addon *InstallPackage, k8sClient client.Client, ...) (*v1beta1.Application, []*unstructured.Unstructured, error)
- func RenderArgsSecret(addon *InstallPackage, args map[string]interface{}) *unstructured.Unstructured
- func RenderConfigTemplates(addon *InstallPackage, cli client.Client) ([]*unstructured.Unstructured, error)
- func RenderDefinitionSchema(addon *InstallPackage) ([]*unstructured.Unstructured, error)
- func RenderDefinitions(addon *InstallPackage, config *rest.Config) ([]*unstructured.Unstructured, error)
- func RenderViews(addon *InstallPackage) ([]*unstructured.Unstructured, error)
- func SkipValidateVersion(installer *Installer)
- func WrapErrRateLimit(err error) error
- type AsyncReader
- type Cache
- type Client
- type Dependency
- type DeployTo
- type ElementFile
- type File
- type GitAddonSource
- type GitLabItem
- type GiteeAddonSource
- type GitlabAddonSource
- type HelmSource
- type InitCmd
- type InstallOption
- type InstallPackage
- type Installer
- type Item
- type ListBucketResult
- type ListOptions
- type MemoryReader
- type Meta
- type OSSAddonSource
- type OSSItem
- type Pattern
- type PushCmd
- type ReaderType
- type Registry
- func (r *Registry) BuildReader() (AsyncReader, error)
- func (r *Registry) GetInstallPackage(meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
- func (r *Registry) GetUIData(meta *SourceMeta, opt ListOptions) (*UIData, error)
- func (r *Registry) ListAddonMeta() (map[string]SourceMeta, error)
- func (r *Registry) ListUIData(registryAddonMeta map[string]SourceMeta, opt ListOptions) ([]*UIData, error)
- type RegistryDataStore
- type SafeCopier
- type Source
- type SourceMeta
- type Status
- type SystemRequirements
- type UIData
- type VersionUnMatchError
- type VersionedRegistry
- type WholeAddonPackage
Constants ¶
const (
// ReadmeFileName is the addon readme file name
ReadmeFileName string = "README.md"
// LegacyReadmeFileName is the addon readme lower case file name
LegacyReadmeFileName string = "readme.md"
// MetadataFileName is the addon meatadata.yaml file name
MetadataFileName string = "metadata.yaml"
// TemplateFileName is the addon template.yaml file name
TemplateFileName string = "template.yaml"
// AppTemplateCueFileName is the addon application template.cue file name
AppTemplateCueFileName string = "template.cue"
// NotesCUEFileName is the addon notes print to end users when installed
NotesCUEFileName string = "NOTES.cue"
// KeyWordNotes is the keyword in NOTES.cue which will render the notes message out.
KeyWordNotes string = "notes"
// GlobalParameterFileName is the addon global parameter.cue file name
GlobalParameterFileName string = "parameter.cue"
// ResourcesDirName is the addon resources/ dir name
ResourcesDirName string = "resources"
// DefinitionsDirName is the addon definitions/ dir name
DefinitionsDirName string = "definitions"
// ConfigTemplateDirName is the addon config-templates/ dir name
ConfigTemplateDirName string = "config-templates"
// DefSchemaName is the addon definition schemas dir name
DefSchemaName string = "schemas"
// ViewDirName is the addon views dir name
ViewDirName string = "views"
// AddonParameterDataKey is the key of parameter in addon args secrets
AddonParameterDataKey string = "addonParameterDataKey"
// DefaultGiteeURL is the addon repository of gitee api
DefaultGiteeURL string = "https://gitee.com/api/v5/"
// InstallerRuntimeOption inject install runtime info into addon options
InstallerRuntimeOption string = "installerRuntimeOption"
)
const (
// LocalAddonRegistryName is the addon-registry name for those installed by local dir
LocalAddonRegistryName = "local"
// ClusterLabelSelector define the key of topology cluster label selector
ClusterLabelSelector = "clusterLabelSelector"
)
const (
// EOFError is error returned by xml parse
EOFError string = "EOF"
// DirType means a directory
DirType = "dir"
// FileType means a file
FileType = "file"
// BlobType means a blob
BlobType = "blob"
// TreeType means a tree
TreeType = "tree"
)
const (
// AddonNameRegex is the regex to validate addon names
AddonNameRegex = `^[a-z\d]+(-[a-z\d]+)*$`
)
Variables ¶
var (
// UIMetaOptions get Addon metadata for UI display
UIMetaOptions = ListOptions{GetDetail: true, GetDefinition: true, GetParameter: true, GetConfigTemplate: true}
// CLIMetaOptions get Addon metadata for CLI display
CLIMetaOptions = ListOptions{}
// UnInstallOptions used for addon uninstalling
UnInstallOptions = ListOptions{GetDefinition: true}
)
var (
// ErrRenderCueTmpl is error when render addon's cue file
ErrRenderCueTmpl = NewAddonError("fail to render cue tmpl")
// ErrRateLimit means exceed GitHub access rate limit
ErrRateLimit = NewAddonError("exceed github access rate limit")
// ErrNotExist means addon not exists
ErrNotExist = NewAddonError("addon not exist")
// ErrRegistryNotExist means registry not exists
ErrRegistryNotExist = NewAddonError("registry does not exist")
// ErrBothCueAndYamlTmpl means yaml and cue app template are exist in addon
ErrBothCueAndYamlTmpl = NewAddonError("yaml and cue app template are exist in addon, should only keep one of them")
// ErrFetch means fetch addon package error(package not exist or parse archive error and so on)
ErrFetch = NewAddonError("cannot fetch addon package")
)
var ParameterFileName = strings.Join([]string{"resources", "parameter.cue"}, "/")
ParameterFileName is the addon resources/parameter.cue file name
var Patterns = []Pattern{
{IsDir: true, Value: ConfigTemplateDirName},
{Value: ReadmeFileName}, {Value: MetadataFileName}, {Value: TemplateFileName},
{Value: ParameterFileName},
{IsDir: true, Value: ResourcesDirName}, {IsDir: true, Value: DefinitionsDirName}, {IsDir: true, Value: DefSchemaName}, {IsDir: true, Value: ViewDirName},
{Value: AppTemplateCueFileName}, {Value: GlobalParameterFileName}, {Value: NotesCUEFileName},
{Value: LegacyReadmeFileName}}
Patterns is the file pattern that the addon should be in
Functions ¶
func CheckAddonName ¶ added in v1.5.0
func CheckAddonName(addonName string) error
CheckAddonName checks if an addon name is valid
func ClassifyItemByPattern ¶
func ClassifyItemByPattern(meta *SourceMeta, r AsyncReader) map[string][]Item
ClassifyItemByPattern will filter and classify addon data, data will be classified by pattern it meets
func DisableAddon ¶
func DisableAddon(ctx context.Context, cli client.Client, name string, config *rest.Config, force bool) error
DisableAddon will disable addon from cluster.
func DryRunAddon ¶ added in v1.6.0
func DryRunAddon(installer *Installer)
DryRunAddon means only generate yaml for addon instead of installing it
func EnableAddon ¶
func EnableAddon(ctx context.Context, name string, version string, cli client.Client, discoveryClient *discovery.DiscoveryClient, apply apply.Applicator, config *rest.Config, r Registry, args map[string]interface{}, cache *Cache, registries []Registry, opts ...InstallOption) (string, error)
EnableAddon will enable addon with dependency check, source is where addon from.
func EnableAddonByLocalDir ¶
func EnableAddonByLocalDir(ctx context.Context, name string, dir string, cli client.Client, dc *discovery.DiscoveryClient, applicator apply.Applicator, config *rest.Config, args map[string]interface{}, opts ...InstallOption) (string, error)
EnableAddonByLocalDir enable an addon from local dir
func FetchAddonRelatedApp ¶
func FetchAddonRelatedApp(ctx context.Context, cli client.Client, addonName string) (*v1beta1.Application, error)
FetchAddonRelatedApp will fetch the addon related app, this func will use NamespacedName(vela-system, addon-addonName) to get app if not find will try to get 1.1 legacy addon related app by using NamespacedName(vela-system, `addonName`)
func FetchArgsFromSecret ¶ added in v1.2.4
func FetchArgsFromSecret(sec *v1.Secret) (map[string]interface{}, error)
FetchArgsFromSecret fetch addon args from secrets
func GetAddonLegacyParameters ¶ added in v1.5.0
func GetAddonLegacyParameters(ctx context.Context, k8sClient client.Client, addonName string) (map[string]interface{}, error)
GetAddonLegacyParameters get addon's legacy parameters, that is stored in Secret
func GetHelmRepo ¶ added in v1.5.0
func GetHelmRepo(ctx context.Context, c client.Client, repoName string) (*cmhelm.Repo, error)
GetHelmRepo searches for a Helm repo by name. By saying name, it can actually be a URL or a name. If a URL is provided, a temp repo object is returned. If a name is provided, we will try to find it in local addon registries (only Helm type).
func GetPatternFromItem ¶
func GetPatternFromItem(it Item, r AsyncReader, rootPath string) string
GetPatternFromItem will check if the file path has a valid pattern, return empty string if it's invalid. AsyncReader is needed to calculate relative path
func IsAddonDir ¶ added in v1.5.0
func IsAddonDir(dirName string) (bool, error)
IsAddonDir validates an addon directory. It checks required files like metadata.yaml and template.yaml
func IsVersionRegistry ¶ added in v1.3.0
func IsVersionRegistry(r Registry) bool
IsVersionRegistry check the repo source if support multi-version addon
func MakeChartCompatible ¶ added in v1.5.0
func MakeChartCompatible(addonDir string, overwrite bool) error
MakeChartCompatible makes an addon directory compatible with Helm Charts. It essentially creates a Chart.yaml file in it (if it doesn't already have one). If overwrite is true, a Chart.yaml will always be created.
func MergeAddonInstallArgs ¶ added in v1.5.0
func MergeAddonInstallArgs(ctx context.Context, k8sClient client.Client, addonName string, args map[string]interface{}) (map[string]interface{}, error)
MergeAddonInstallArgs merge addon's legacy parameter and new input args
func OverrideDefinitions ¶ added in v1.5.0
func OverrideDefinitions(installer *Installer)
OverrideDefinitions means override definitions within this addon if some of them already exist
func PackageAddon ¶ added in v1.4.0
func PackageAddon(addonDictPath string) (string, error)
PackageAddon package vela addon directory into a helm chart compatible archive and return its absolute path
func RenderApp ¶
func RenderApp(ctx context.Context, addon *InstallPackage, k8sClient client.Client, args map[string]interface{}) (*v1beta1.Application, []*unstructured.Unstructured, error)
RenderApp render a K8s application
func RenderArgsSecret ¶
func RenderArgsSecret(addon *InstallPackage, args map[string]interface{}) *unstructured.Unstructured
RenderArgsSecret render addon enable argument to secret to remember when restart or upgrade
func RenderConfigTemplates ¶ added in v1.6.0
func RenderConfigTemplates(addon *InstallPackage, cli client.Client) ([]*unstructured.Unstructured, error)
RenderConfigTemplates render the config template
func RenderDefinitionSchema ¶
func RenderDefinitionSchema(addon *InstallPackage) ([]*unstructured.Unstructured, error)
RenderDefinitionSchema will render definitions' schema in addons.
func RenderDefinitions ¶
func RenderDefinitions(addon *InstallPackage, config *rest.Config) ([]*unstructured.Unstructured, error)
RenderDefinitions render definition objects if needed
func RenderViews ¶ added in v1.5.0
func RenderViews(addon *InstallPackage) ([]*unstructured.Unstructured, error)
RenderViews will render views in addons.
func SkipValidateVersion ¶ added in v1.4.4
func SkipValidateVersion(installer *Installer)
SkipValidateVersion means skip validating system version
func WrapErrRateLimit ¶
func WrapErrRateLimit(err error) error
WrapErrRateLimit return ErrRateLimit if is the situation, or return error directly
Types ¶
type AsyncReader ¶
type AsyncReader interface {
// ListAddonMeta will return directory tree contain addon metadata only
ListAddonMeta() (addonCandidates map[string]SourceMeta, err error)
// ReadFile should accept relative path to github repo/path or OSS bucket, and report the file content
ReadFile(path string) (content string, err error)
// RelativePath return a relative path to GitHub repo/path or OSS bucket/path
RelativePath(item Item) string
}
AsyncReader helps async read files of addon
func NewAsyncReader ¶
func NewAsyncReader(baseURL, bucket, repo, subPath, token string, rdType ReaderType) (AsyncReader, error)
NewAsyncReader create AsyncReader from 1. GitHub url and directory 2. OSS endpoint and bucket
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache package only cache for 1 and 2, we don't cache InstallPackage, and it only read for real installation
func (*Cache) DiscoverAndRefreshLoop ¶
func (u *Cache) DiscoverAndRefreshLoop(ctx context.Context, cacheTime time.Duration)
DiscoverAndRefreshLoop will run a loop to automatically discovery and refresh addons from registry
func (*Cache) GetUIData ¶
func (u *Cache) GetUIData(r Registry, addonName, version string) (*UIData, error)
GetUIData get addon data for UI display from cache, if cache not found, it will find from source
func (*Cache) ListAddonMeta ¶
func (u *Cache) ListAddonMeta(r Registry) (map[string]SourceMeta, error)
ListAddonMeta will list metadata from registry, if cache not found, it will find from source
func (*Cache) ListUIData ¶
func (u *Cache) ListUIData(r Registry) ([]*UIData, error)
ListUIData will always list UIData from cache first, if not exist, read from source.
type Client ¶ added in v1.3.0
type Client struct {
Client *http.Client
BaseURL *url.URL
}
Client manages communication with the Gitee API
func NewGiteeClient ¶ added in v1.3.0
func NewGiteeClient(httpClient *http.Client, baseURL *url.URL) *Client
NewGiteeClient returns a new Gitee API client
func (*Client) GetGiteeContents ¶ added in v1.3.0
func (c *Client) GetGiteeContents(ctx context.Context, owner, repo, path, ref string) (fileContent *github.RepositoryContent, directoryContent []*github.RepositoryContent, err error)
GetGiteeContents can return either the metadata and content of a single file
type Dependency ¶
type Dependency struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
}
Dependency defines the other addons it depends on
type DeployTo ¶
type DeployTo struct {
// This field keep the compatible for older case
LegacyRuntimeCluster bool `json:"runtime_cluster,omitempty"`
DisableControlPlane bool `json:"disableControlPlane"`
RuntimeCluster bool `json:"runtimeCluster"`
}
DeployTo defines where the addon to deploy to
type ElementFile ¶
type ElementFile struct {
Data string
Name string
}
ElementFile can be addon's definition or addon's component
type File ¶
type File struct {
Name string `xml:"Key"`
Size int `xml:"Size"`
LastModified time.Time `xml:"LastModified"`
Type string `xml:"Type"`
StorageClass string `xml:"StorageClass"`
}
File is for oss xml parse
type GitAddonSource ¶
type GitAddonSource struct {
URL string `json:"url,omitempty" validate:"required"`
Path string `json:"path,omitempty"`
Token string `json:"token,omitempty"`
}
GitAddonSource defines the information about the Git as addon source
type GitLabItem ¶ added in v1.4.0
type GitLabItem struct {
// contains filtered or unexported fields
}
GitLabItem addon's sub item
func (GitLabItem) GetName ¶ added in v1.4.0
func (g GitLabItem) GetName() string
GetName get addon's sub item name
type GiteeAddonSource ¶ added in v1.3.0
type GiteeAddonSource struct {
URL string `json:"url,omitempty" validate:"required"`
Path string `json:"path,omitempty"`
Token string `json:"token,omitempty"`
}
GiteeAddonSource defines the information about the Gitee as addon source
type GitlabAddonSource ¶ added in v1.4.0
type GitlabAddonSource struct {
URL string `json:"url,omitempty" validate:"required"`
Repo string `json:"repo,omitempty" validate:"required"`
Path string `json:"path,omitempty"`
Token string `json:"token,omitempty"`
}
GitlabAddonSource defines the information about the Gitlab as addon source
type HelmSource ¶ added in v1.3.0
type HelmSource struct {
URL string `json:"url,omitempty" validate:"required"`
InsecureSkipTLS bool `json:"insecureSkipTLS,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
HelmSource defines the information about the helm repo addon source
type InitCmd ¶ added in v1.5.0
type InitCmd struct {
AddonName string
NoSamples bool
HelmRepoURL string
HelmChartName string
HelmChartVersion string
Path string
Overwrite bool
RefObjURLs []string
// We use string instead of v1beta1.Application is because
// the cue formatter is having some problems: it will keep
// TypeMeta (instead of inlined).
AppTmpl string
Metadata Meta
Readme string
Resources []ElementFile
Schemas []ElementFile
Views []ElementFile
Definitions []ElementFile
}
InitCmd contains the options to initialize an addon scaffold
func (*InitCmd) CreateScaffold ¶ added in v1.5.0
func (cmd *InitCmd) CreateScaffold() error
CreateScaffold creates an addon scaffold
type InstallOption ¶ added in v1.4.4
type InstallOption func(installer *Installer)
InstallOption define additional option for installation
type InstallPackage ¶
type InstallPackage struct {
Meta
// Definitions and CUEDefinitions are converted as OAM X-Definitions, they will only in control plane cluster
Definitions []ElementFile `json:"definitions"`
CUEDefinitions []ElementFile `json:"CUEDefinitions"`
ConfigTemplates []ElementFile `json:"configTemplates"`
// YAMLViews and CUEViews are the instances of velaql, they will only in control plane cluster
YAMLViews []ElementFile `json:"YAMLViews"`
CUEViews []ElementFile `json:"CUEViews"`
// DefSchemas are UI schemas read by VelaUX, it will only be installed in control plane clusters
DefSchemas []ElementFile `json:"defSchemas,omitempty"`
Parameters string `json:"parameters"`
// CUETemplates and YAMLTemplates are resources needed to be installed in managed clusters
CUETemplates []ElementFile `json:"CUETemplates"`
YAMLTemplates []ElementFile `json:"YAMLTemplates,omitempty"`
AppTemplate *v1beta1.Application `json:"appTemplate"`
AppCueTemplate ElementFile `json:"appCueTemplate,omitempty"`
Notes ElementFile `json:"notes,omitempty"`
}
InstallPackage contains all necessary files that can be installed for an addon
func GetInstallPackageFromReader ¶
func GetInstallPackageFromReader(r AsyncReader, meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
GetInstallPackageFromReader get install package of addon from Reader, this is used to enable an addon
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
Installer helps addon enable, dependency-check, dispatch resources
func NewAddonInstaller ¶
func NewAddonInstaller(ctx context.Context, cli client.Client, discoveryClient *discovery.DiscoveryClient, apply apply.Applicator, config *rest.Config, r *Registry, args map[string]interface{}, cache *Cache, registries []Registry, opts ...InstallOption) Installer
NewAddonInstaller will create an installer for addon
type Item ¶
type Item interface {
// GetType return "dir" or "file"
GetType() string
GetPath() string
GetName() string
}
Item is a partial interface for github.RepositoryContent
type ListBucketResult ¶
type ListBucketResult struct {
Files []File `xml:"Contents"`
Count int `xml:"KeyCount"`
}
ListBucketResult describe a file list from OSS
type ListOptions ¶
type ListOptions struct {
GetDetail bool
GetDefinition bool
GetConfigTemplate bool
GetResource bool
GetParameter bool
GetTemplate bool
GetDefSchema bool
}
ListOptions contains flags mark what files should be read in an addon directory
type MemoryReader ¶ added in v1.3.0
type MemoryReader struct {
Name string
Files []*loader.BufferedFile
// contains filtered or unexported fields
}
MemoryReader is async reader for memory data
func (*MemoryReader) ListAddonMeta ¶ added in v1.3.0
func (l *MemoryReader) ListAddonMeta() (map[string]SourceMeta, error)
ListAddonMeta list all metadata of helm repo registry
func (*MemoryReader) ReadFile ¶ added in v1.3.0
func (l *MemoryReader) ReadFile(path string) (string, error)
ReadFile ready file from memory
func (*MemoryReader) RelativePath ¶ added in v1.3.0
func (l *MemoryReader) RelativePath(item Item) string
RelativePath calculate the relative path of one file
type Meta ¶
type Meta struct {
Name string `json:"name" validate:"required"`
Version string `json:"version"`
Description string `json:"description"`
Icon string `json:"icon"`
URL string `json:"url,omitempty"`
Tags []string `json:"tags,omitempty"`
DeployTo *DeployTo `json:"deployTo,omitempty"`
Dependencies []*Dependency `json:"dependencies,omitempty"`
NeedNamespace []string `json:"needNamespace,omitempty"`
Invisible bool `json:"invisible"`
SystemRequirements *SystemRequirements `json:"system,omitempty"`
}
Meta defines the format for a single addon
type OSSAddonSource ¶
type OSSAddonSource struct {
Endpoint string `json:"end_point" validate:"required"`
Bucket string `json:"bucket"`
Path string `json:"path"`
}
OSSAddonSource is UIData source from alibaba cloud OSS style source
type OSSItem ¶
type OSSItem struct {
// contains filtered or unexported fields
}
OSSItem is Item implement for OSS
type Pattern ¶
type Pattern struct {
IsDir bool
Value string
}
Pattern indicates the addon framework file pattern, all files should match at least one of the pattern.
type PushCmd ¶ added in v1.5.0
type PushCmd struct {
ChartName string
AppVersion string
ChartVersion string
RepoName string
Username string
Password string
AccessToken string
AuthHeader string
ContextPath string
ForceUpload bool
UseHTTP bool
CaFile string
CertFile string
KeyFile string
InsecureSkipVerify bool
Out io.Writer
Timeout int64
KeepChartMetadata bool
// We need it to search in addon registries.
// If you use URL, instead of registry names, then it is not needed.
Client client.Client
}
PushCmd is the command object to initiate a push command to ChartMuseum
func (*PushCmd) Push ¶ added in v1.5.0
func (p *PushCmd) Push(ctx context.Context) error
Push pushes addons (i.e. Helm Charts) to ChartMuseum. It will package the addon into a Helm Chart if necessary.
func (*PushCmd) SetFieldsFromEnv ¶ added in v1.5.0
func (p *PushCmd) SetFieldsFromEnv()
SetFieldsFromEnv sets fields in PushCmd from environment variables
type Registry ¶
type Registry struct {
Name string `json:"name"`
Helm *HelmSource `json:"helm,omitempty"`
Git *GitAddonSource `json:"git,omitempty"`
OSS *OSSAddonSource `json:"oss,omitempty"`
Gitee *GiteeAddonSource `json:"gitee,omitempty"`
Gitlab *GitlabAddonSource `json:"gitlab,omitempty"`
}
Registry represent a addon registry model
func FilterDependencyRegistries ¶ added in v1.6.3
func FilterDependencyRegistries(i int, rs []Registry) []Registry
FilterDependencyRegistries will return all registries besides the target registry itself
func (*Registry) BuildReader ¶
func (r *Registry) BuildReader() (AsyncReader, error)
BuildReader will build a AsyncReader from registry, AsyncReader are needed to read addon files
func (*Registry) GetInstallPackage ¶
func (r *Registry) GetInstallPackage(meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
GetInstallPackage get install package which is all needed to enable an addon from addon registry
func (*Registry) GetUIData ¶
func (r *Registry) GetUIData(meta *SourceMeta, opt ListOptions) (*UIData, error)
GetUIData get UIData of an addon
func (*Registry) ListAddonMeta ¶
func (r *Registry) ListAddonMeta() (map[string]SourceMeta, error)
ListAddonMeta list addon file meta(path and name) from a registry
func (*Registry) ListUIData ¶
func (r *Registry) ListUIData(registryAddonMeta map[string]SourceMeta, opt ListOptions) ([]*UIData, error)
ListUIData list UI data from addon registry
type RegistryDataStore ¶
type RegistryDataStore interface {
ListRegistries(context.Context) ([]Registry, error)
AddRegistry(context.Context, Registry) error
DeleteRegistry(context.Context, string) error
UpdateRegistry(context.Context, Registry) error
GetRegistry(context.Context, string) (Registry, error)
}
RegistryDataStore CRUD addon registry data in configmap
func NewRegistryDataStore ¶
func NewRegistryDataStore(cli client.Client) RegistryDataStore
NewRegistryDataStore get RegistryDataStore operation interface
type SafeCopier ¶ added in v1.3.4
type SafeCopier interface {
SafeCopy() interface{}
}
SafeCopier is an interface to copy Struct without sensitive fields, such as Token, Username, Password
type Source ¶
type Source interface {
GetUIData(meta *SourceMeta, opt ListOptions) (*UIData, error)
ListUIData(registryAddonMeta map[string]SourceMeta, opt ListOptions) ([]*UIData, error)
GetInstallPackage(meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
ListAddonMeta() (map[string]SourceMeta, error)
}
Source is where to get addons, Registry implement this interface
type SourceMeta ¶
type SourceMeta struct {
Name string
Items []Item
}
SourceMeta record the whole metadata of an addon
type Status ¶
type Status struct {
AddonPhase string
AppStatus *commontypes.AppStatus
// the status of multiple clusters
Clusters map[string]map[string]interface{} `json:"clusters,omitempty"`
InstalledVersion string
Parameters map[string]interface{}
// Where the addon is from. Can be empty if not installed.
InstalledRegistry string
}
Status contain addon phase and related app status
func GetAddonStatus ¶
func GetAddonStatus(ctx context.Context, cli client.Client, name string) (Status, error)
GetAddonStatus is general func for cli and apiServer get addon status
type SystemRequirements ¶ added in v1.2.4
type SystemRequirements struct {
VelaVersion string `json:"vela,omitempty"`
KubernetesVersion string `json:"kubernetes,omitempty"`
}
SystemRequirements is this addon need version
func LoadSystemRequirements ¶ added in v1.5.0
func LoadSystemRequirements(anno map[string]string) *SystemRequirements
LoadSystemRequirements load the system version requirements from the addon's meta file
type UIData ¶
type UIData struct {
Meta
APISchema *openapi3.Schema `json:"schema"`
UISchema []*utils.UIParameter `json:"uiSchema"`
// Detail is README.md in an addon
Detail string `json:"detail,omitempty"`
Definitions []ElementFile `json:"definitions"`
CUEDefinitions []ElementFile `json:"CUEDefinitions"`
ConfigTemplates []ElementFile `json:"configTemplates"`
Parameters string `json:"parameters"`
GlobalParameters string `json:"globalParameters"`
RegistryName string `json:"registryName"`
AvailableVersions []string `json:"availableVersions"`
}
UIData contains all information represent an addon for UI
func GetUIDataFromReader ¶
func GetUIDataFromReader(r AsyncReader, meta *SourceMeta, opt ListOptions) (*UIData, error)
GetUIDataFromReader read ui metadata of addon from Reader, used to be displayed in UI
func ListAddonUIDataFromReader ¶
func ListAddonUIDataFromReader(r AsyncReader, registryMeta map[string]SourceMeta, registryName string, opt ListOptions) ([]*UIData, error)
ListAddonUIDataFromReader list addons from AsyncReader
type VersionUnMatchError ¶ added in v1.3.1
type VersionUnMatchError struct {
// contains filtered or unexported fields
}
VersionUnMatchError means addon system requirement cannot meet requirement
func (VersionUnMatchError) GetAvailableVersion ¶ added in v1.5.0
func (v VersionUnMatchError) GetAvailableVersion() (string, error)
GetAvailableVersion load addon's available version from the err
type VersionedRegistry ¶ added in v1.3.0
type VersionedRegistry interface {
ListAddon() ([]*UIData, error)
GetAddonUIData(ctx context.Context, addonName, version string) (*UIData, error)
GetAddonInstallPackage(ctx context.Context, addonName, version string) (*InstallPackage, error)
GetDetailedAddon(ctx context.Context, addonName, version string) (*WholeAddonPackage, error)
GetAddonAvailableVersion(addonName string) ([]*repo.ChartVersion, error)
}
VersionedRegistry is the interface of support version registry
func BuildVersionedRegistry ¶ added in v1.3.0
func BuildVersionedRegistry(name, repoURL string, opts *common.HTTPOption) VersionedRegistry
BuildVersionedRegistry is build versioned addon registry
type WholeAddonPackage ¶ added in v1.3.0
type WholeAddonPackage struct {
InstallPackage
APISchema *openapi3.Schema `json:"schema"`
// Detail is README.md in an addon
Detail string `json:"detail,omitempty"`
AvailableVersions []string `json:"availableVersions"`
RegistryName string `json:"registryName"`
}
WholeAddonPackage contains all infos of an addon
func FindAddonPackagesDetailFromRegistry ¶ added in v1.6.5
func FindAddonPackagesDetailFromRegistry(ctx context.Context, k8sClient client.Client, addonNames []string, registryNames []string) ([]*WholeAddonPackage, error)
FindAddonPackagesDetailFromRegistry find addons' WholeInstallPackage from registries, empty registryName indicates matching all