Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAddonName(addonName string) error
- func CheckGoDefName(name string) error
- func ClassifyItemByPattern(meta *SourceMeta, r AsyncReader) map[string][]Item
- func DetectDefinitionConflicts(cueDefinitions, goDefinitions []ElementFile) []string
- 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 HasGoDefFolder(addonPath string) bool
- func IsAddonDir(dirName string) (bool, error)
- func IsDirectAddonPushTarget(target string) bool
- func IsLocalRegistry(r Registry) bool
- func IsVersionRegistry(r Registry) bool
- func ListAddonInfo(r *Registry) (map[string]ItemInfo, error)
- 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(ctx context.Context, 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 RenderInlineModuleComponents(addon *InstallPackage, existingComponents []common2.ApplicationComponent, ...) ([]common2.ApplicationComponent, error)
- func RenderModuleComponents(addon *InstallPackage, existingComponents []common2.ApplicationComponent, ...) ([]common2.ApplicationComponent, error)
- func RenderResources(addon *InstallPackage, args map[string]interface{}) ([]common2.ApplicationComponent, error)
- func RenderViews(ctx context.Context, addon *InstallPackage) ([]*unstructured.Unstructured, error)
- func ResetAddonCache()
- func ResetInstallPackageCache()
- func SkipValidateVersion(installer *Installer)
- func ValidateGoDefModule(godefPath string) error
- func ValidateSystemRequirements(ctx context.Context, require *SystemRequirements, k8sClient client.Client, ...) error
- func WrapErrRateLimit(err error) error
- type AllowGoDefOverride
- type AsyncReader
- type Cache
- type Client
- type Dependency
- type DeployTo
- type ElementFile
- type File
- type GitAddonSource
- type GitLabItem
- type GiteeAddonSource
- type GitlabAddonSource
- type GoDefModule
- type HelmSource
- type InitCmd
- type InstallOption
- type InstallPackage
- func GetAddonInstallPackageFromRegistry(ctx context.Context, cli client.Client, ...) (*InstallPackage, error)
- func GetInstallPackage(r *Registry, meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
- func GetInstallPackageFromReader(r AsyncReader, meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
- func LoadLocalInstallPackage(name string, dir string) (*InstallPackage, error)
- func PrepareLocalInstallPackage(ctx context.Context, name string, dir string, allowGoDefOverride bool) (*InstallPackage, error)
- type Installer
- type Item
- type ItemInfo
- type ItemInfoLister
- type ListBucketResult
- type ListOptions
- type MemoryReader
- type Meta
- type ModuleImport
- type OCIAddonCatalog
- type OCIAddonCatalogEntry
- type OSSAddonSource
- type OSSItem
- type Pattern
- type PushCmd
- type ReaderOption
- type ReaderType
- type Registry
- type RegistryDataStore
- type SafeCopier
- type SourceMeta
- type Status
- type SystemRequirements
- type TokenSource
- type UIData
- func GetUIData(r *Registry, meta *SourceMeta, opt ListOptions) (*UIData, error)
- func GetUIDataFromReader(r AsyncReader, meta *SourceMeta, opt ListOptions) (*UIData, error)
- func ListAddonUIDataFromReader(r AsyncReader, registryMeta map[string]SourceMeta, registryName string, ...) ([]*UIData, error)
- func ListUIData(r *Registry, registryAddonMeta map[string]SourceMeta, opt ListOptions) ([]*UIData, error)
- 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" // 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" // GoDefDirName is the addon godef/ dir name for Go-based definitions GoDefDirName string = "godef" // GoDefModuleFileName is the module.yaml file name in godef/ GoDefModuleFileName string = "module.yaml" // ModulesDirName is the addon's modules/ directory. Everything under it // except ModulesImportsFileName (claimed by its own, more specific // pattern) is a candidate inline module, read by readInlineModulesDir. ModulesDirName string = "modules" // ModulesImportsFileName is the addon's modules/_imports.cue file name: // the external-module-import declaration read by GetInstallPackageFromReader. ModulesImportsFileName string = ModulesDirName + "/_imports.cue" // AddonParameterDataKey is the key of parameter in addon args secrets AddonParameterDataKey string = "addonParameterDataKey" // InstallerRuntimeOption inject install runtime info into addon options InstallerRuntimeOption string = "installerRuntimeOption" // CUEExtension with the expected extension for CUE files CUEExtension = ".cue" )
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 ( // DirType means a directory. DirType = component.DirType // FileType means a file. FileType = component.FileType // BlobType means a blob. BlobType = component.BlobType // TreeType means a tree. TreeType = component.TreeType // EOFError is the error returned by an xml parse hitting EOF. EOFError = component.EOFError // MetadataFileName is the package metadata.yaml file name. MetadataFileName = component.MetadataFileName )
Constants and functions re-exported from pkg/registry/component.
const ( // AddonNameRegex is the regex to validate addon names AddonNameRegex = `^[a-z\d]+(-[a-z\d]+)*$` // GoDefNameRegex validates Go definition names (valid Go identifiers: letters, digits, underscores) GoDefNameRegex = `^[a-zA-Z_][a-zA-Z0-9_]*$` )
const DefaultGiteeURL string = "https://gitee.com/api/v5/"
DefaultGiteeURL is the Gitee API endpoint reads default to.
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 ( // NewRegistryDataStore builds the addon registry store. NewRegistryDataStore = component.NewRegistryDataStore // NewRegistryDataStoreFor builds a registry store over the given ConfigMap. NewRegistryDataStoreFor = component.NewRegistryDataStoreFor // NewAsyncReader builds a reader for a source. NewAsyncReader = component.NewAsyncReader // WithRef reads at a specific branch, tag or commit. WithRef = component.WithRef // IsOCIURL reports whether a URL names an OCI registry. IsOCIURL = component.IsOCIURL // OCIChartRef returns the full reference a chart publishes to. OCIChartRef = component.OCIChartRef // PushOCIChart pushes a chart archive. PushOCIChart = component.PushOCIChart // OCIChartTagExists reports whether a tag is already published. OCIChartTagExists = component.OCIChartTagExists // PullOCIChartFiles pulls a chart artifact's files. PullOCIChartFiles = component.PullOCIChartFiles // IsOCIRepositoryNotFound classifies a missing-repository error. IsOCIRepositoryNotFound = component.IsOCIRepositoryNotFound // IsOCITagImmutable classifies an immutable-tag error. IsOCITagImmutable = component.IsOCITagImmutable )
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 = component.ErrRateLimit // ErrNotExist means addon not exists ErrNotExist = NewAddonError("addon not exist") // ErrRegistryNotExist means registry not exists ErrRegistryNotExist = component.ErrRegistryNotExist // 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") // ErrOCICatalogAbsent means an OCI registry has no addon catalog to read yet: // the portable catalog chart has never been pushed and the registry does not // implement /v2/_catalog enumeration (ECR, for one). It is distinct from a // catalog that exists but could not be read, so a push can bootstrap a fresh // catalog without a transient read failure silently discarding the real one. ErrOCICatalogAbsent = NewAddonError("OCI addon catalog does not exist") // ErrVersionMismatch means the addon's SystemRequirements were positively // evaluated and NOT met. It is deliberately distinct from the operational // errors checkAddonVersionMeetRequired can also return (reading the vela-core // image tag, querying the discovery API, parsing a malformed constraint), so // callers such as the addon admission webhook can deny on a real mismatch and // fail open on a lookup failure. ErrVersionMismatch = NewAddonError("addon system requirement not met") )
var ErrFileNotFound = velaerrors.ErrFileNotFound
ErrFileNotFound is the shared sentinel, re-exported for addon callers.
var ErrUnsupportedGitEndpoint = errors.New("addon registry invalid")
ErrUnsupportedGitEndpoint is returned when a git registry endpoint is not a GitHub URL the git reader can parse.
var ErrUnsupportedGiteeEndpoint = errors.New("addon registry invalid")
ErrUnsupportedGiteeEndpoint is returned when a gitee registry endpoint is not a Gitee URL the gitee reader can parse.
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}, {Value: ModulesImportsFileName}, {IsDir: true, Value: ModulesDirName}, {IsDir: true, Value: ResourcesDirName}, {IsDir: true, Value: DefinitionsDirName}, {IsDir: true, Value: DefSchemaName}, {IsDir: true, Value: ViewDirName}, {IsDir: true, Value: GoDefDirName}, {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
CheckAddonName checks if an addon name is valid
func CheckGoDefName ¶ added in v1.11.0
CheckGoDefName checks if a Go definition name is valid. Names must be valid Go identifiers to prevent path traversal attacks and ensure they can be used as Go type/function names.
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 DetectDefinitionConflicts ¶ added in v1.11.0
func DetectDefinitionConflicts(cueDefinitions, goDefinitions []ElementFile) []string
DetectDefinitionConflicts checks for conflicting definition names between CUE and Go definitions Returns a list of conflicting definition names
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{}, allowGoDefOverride bool, opts ...InstallOption) (string, error)
EnableAddonByLocalDir enable an addon from local dir The allowGoDefOverride parameter allows Go definitions to override CUE definitions when conflicts are detected
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
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
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 HasGoDefFolder ¶ added in v1.11.0
HasGoDefFolder checks if an addon directory has a godef/ folder
func IsAddonDir ¶ added in v1.5.0
IsAddonDir validates an addon directory. It checks required files like metadata.yaml and template.yaml
func IsDirectAddonPushTarget ¶
IsDirectAddonPushTarget reports whether target can be used without resolving a configured addon registry from Kubernetes.
func IsLocalRegistry ¶ added in v1.9.0
IsLocalRegistry checks if the registry is local
func IsVersionRegistry ¶ added in v1.3.0
IsVersionRegistry check the repo source if support multi-version addon. Both an indexed HTTP Helm repository and an OCI registry are Helm sources; the URL scheme decides which transport reads it.
func ListAddonInfo ¶
ListAddonInfo lists addon info (name, versions, etc.) from a registry
func MakeChartCompatible ¶ added in v1.5.0
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
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(ctx context.Context, 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 RenderInlineModuleComponents ¶
func RenderInlineModuleComponents(addon *InstallPackage, existingComponents []common2.ApplicationComponent, resourceComponentNames []string, namespace string) ([]common2.ApplicationComponent, error)
RenderInlineModuleComponents builds one type: k8s-objects ApplicationComponent per inline module bundled in the addon (modules/<name>/_module.cue), each wrapping the already-rendered owned Application as its single literal object. There is no registry to defer to for an inline module, so it is parsed and rendered once, here, in Go, rather than lazily inside a type: module component's own CueX render -- the same RenderApplication call the external path eventually reaches, just invoked eagerly instead of through the CueX provider. Every emitted component depends on every name in resourceComponentNames, so a module's XRD/Compositions never apply before the addon's own operators and CRDs are healthy, the same ordering rule RenderModuleComponents already applies to external imports.
namespace is the namespace of the Application that installs the addon, where the modules' definitions install; empty means vela-system.
func RenderModuleComponents ¶
func RenderModuleComponents(addon *InstallPackage, existingComponents []common2.ApplicationComponent, resourceComponentNames []string) ([]common2.ApplicationComponent, error)
RenderModuleComponents builds one type: module ApplicationComponent per enabled modules/_imports.cue entry. A module name claimed anywhere else in the addon too -- a hand-written type: module component in template.cue, or an inline modules/<name>/ -- fails the whole render; see checkModuleNameCollisions. Each emitted component depends on every name in resourceComponentNames, so the module's resources never apply before the addon's own operators and CRDs are healthy.
func RenderResources ¶
func RenderResources(addon *InstallPackage, args map[string]interface{}) ([]common2.ApplicationComponent, error)
RenderResources renders the addon's resources/ tier: the YAML-based k8s-objects component (when the addon has YAMLTemplates) and one component per non-main CUE template. It is exported so callers assembling the addon Application from outside this package (see pkg/addon/service/renderer.go) can derive the resulting component names without re-implementing this rendering.
func RenderViews ¶ added in v1.5.0
func RenderViews(ctx context.Context, addon *InstallPackage) ([]*unstructured.Unstructured, error)
RenderViews will render views in addons.
func ResetAddonCache ¶
func ResetAddonCache()
ResetAddonCache empties the addon package cache. It exists for tests, which would otherwise carry a package from one case into the next.
func ResetInstallPackageCache ¶
func ResetInstallPackageCache()
ResetInstallPackageCache empties the install package cache, for tests.
func SkipValidateVersion ¶ added in v1.4.4
func SkipValidateVersion(installer *Installer)
SkipValidateVersion means skip validating system version
func ValidateGoDefModule ¶ added in v1.11.0
ValidateGoDefModule validates the Go definition module structure
func ValidateSystemRequirements ¶
func ValidateSystemRequirements(ctx context.Context, require *SystemRequirements, k8sClient client.Client, dc *discovery.DiscoveryClient) error
ValidateSystemRequirements checks an addon's SystemRequirements (vela and kubernetes versions) against the running environment. nil require passes.
func WrapErrRateLimit ¶
WrapErrRateLimit return ErrRateLimit if is the situation, or return error directly
Types ¶
type AllowGoDefOverride ¶ added in v1.11.0
type AllowGoDefOverride struct{}
AllowGoDefOverride is a marker option indicating that Go definitions can override CUE definitions within the same addon. This is used when enabling local addons that have both definitions/ and godef/ folders.
func OverrideGoDefConflicts ¶ added in v1.11.0
func OverrideGoDefConflicts() AllowGoDefOverride
OverrideGoDefConflicts allows Go definitions to override CUE definitions when conflicts are detected within the same addon. Use this when you have intentionally defined the same definition in both definitions/ (CUE) and godef/ (Go) folders.
type AsyncReader ¶
type AsyncReader = component.AsyncReader
AsyncReader reads package files from a source.
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 ¶
DiscoverAndRefreshLoop will run a loop to automatically discovery and refresh addons from registry
func (*Cache) GetUIData ¶
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
type Client ¶ added in v1.3.0
Client manages communication with the Gitee API
func NewGiteeClient ¶ added in v1.3.0
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 ¶
ElementFile can be addon's definition or addon's component
func CompileGoDefinitions ¶ added in v1.11.0
func CompileGoDefinitions(ctx context.Context, godefPath string) ([]ElementFile, error)
CompileGoDefinitions compiles Go-based definitions from a godef/ folder and returns the compiled CUE definitions. Returns an error if any definition fails to compile or if no definitions are found.
func CompileGoDefinitionsFromAddon ¶ added in v1.11.0
func CompileGoDefinitionsFromAddon(ctx context.Context, addonPath string) ([]ElementFile, error)
CompileGoDefinitionsFromAddon compiles Go-based definitions from an addon directory This is a convenience function that validates and compiles in one step
type GitAddonSource ¶
type GitAddonSource = component.GitAddonSource
GitAddonSource is a git-backed 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
func (GitLabItem) GetPath ¶ added in v1.4.0
func (g GitLabItem) GetPath() string
GetPath get addon's sub item path
func (GitLabItem) GetType ¶ added in v1.4.0
func (g GitLabItem) GetType() string
GetType get addon's sub item type
type GiteeAddonSource ¶ added in v1.3.0
type GiteeAddonSource = component.GiteeAddonSource
GiteeAddonSource is a Gitee-backed source.
type GitlabAddonSource ¶ added in v1.4.0
type GitlabAddonSource = component.GitlabAddonSource
GitlabAddonSource is a GitLab-backed source.
type GoDefModule ¶ added in v1.11.0
type GoDefModule struct {
// Path is the path to the godef/ directory
Path string `json:"path"`
// ModuleYAML is the contents of the module.yaml file
ModuleYAML string `json:"moduleYAML,omitempty"`
// GoFiles contains the Go source files
GoFiles []ElementFile `json:"goFiles,omitempty"`
// GoMod is the go.mod file content
GoMod string `json:"goMod,omitempty"`
// GoSum is the go.sum file content
GoSum string `json:"goSum,omitempty"`
// CompiledDefinitions contains the compiled CUE definitions from Go sources
CompiledDefinitions []ElementFile `json:"compiledDefinitions,omitempty"`
}
GoDefModule contains information about a Go-based definition module in an addon
func ReadGoDefFolder ¶ added in v1.11.0
func ReadGoDefFolder(addonPath string) (*GoDefModule, error)
ReadGoDefFolder reads the godef/ folder from an addon directory and returns GoDefModule info
type HelmSource ¶ added in v1.3.0
type HelmSource = component.HelmSource
HelmSource is a Helm-repo or OCI-backed 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
// EnableGoDef enables Go-based definition scaffolding in godef/ folder
EnableGoDef bool
// GoDefComponents is a comma-separated list of component names to scaffold
GoDefComponents string
// GoDefTraits is a comma-separated list of trait names to scaffold
GoDefTraits string
// GoDefPolicies is a comma-separated list of policy names to scaffold
GoDefPolicies string
// GoDefWorkflowSteps is a comma-separated list of workflow step names to scaffold
GoDefWorkflowSteps 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
// GoDefFiles contains Go definition scaffolding files
GoDefFiles []ElementFile
}
InitCmd contains the options to initialize an addon scaffold
func (*InitCmd) CreateScaffold ¶ added in v1.5.0
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"`
// GoDefModule contains Go-based definition module info when godef/ folder exists
GoDefModule *GoDefModule `json:"goDefModule,omitempty"`
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"`
// Imports are the addon's modules/_imports.cue entries: external modules
// the addon references, each installed as a type: module component in
// the rendered addon Application. Empty when the addon has no
// modules/_imports.cue file.
Imports []ModuleImport `json:"imports,omitempty"`
// InlineModules are modules developed directly inside the addon's own
// modules/<name>/ directories and parsed from the addon's own
// bundled files -- no registry, no fetch.
// Empty when the addon has no inline modules.
InlineModules []*module.Module `json:"inlineModules,omitempty"`
}
InstallPackage contains all necessary files that can be installed for an addon
func GetAddonInstallPackageFromRegistry ¶
func GetAddonInstallPackageFromRegistry(ctx context.Context, cli client.Client, registryName, addonName, version string) (*InstallPackage, error)
GetAddonInstallPackageFromRegistry resolves a specific addon version's InstallPackage from the named registry. An empty version resolves the latest. It is the shared version-pinning helper used by both the render-only addon service and the Application validating webhook.
func GetInstallPackage ¶
func GetInstallPackage(r *Registry, meta *SourceMeta, uiData *UIData) (*InstallPackage, error)
GetInstallPackage get install package which is all needed to enable an addon from addon registry
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
func LoadLocalInstallPackage ¶
func LoadLocalInstallPackage(name string, dir string) (*InstallPackage, error)
LoadLocalInstallPackage reads the addon in dir, as enabling it from there does, without installing anything.
func PrepareLocalInstallPackage ¶
func PrepareLocalInstallPackage(ctx context.Context, name string, dir string, allowGoDefOverride bool) (*InstallPackage, error)
PrepareLocalInstallPackage is a local addon's package as enabling it installs it: loaded, with its godef/ Go definitions compiled and merged in, and validated. A Go definition named as a CUE one is refused unless allowGoDefOverride, when it replaces the CUE one.
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 ItemInfoLister ¶ added in v1.9.0
ItemInfoLister is an interface for Registry.ListAddonInfo() to enable easier testing with mocks.
type ListBucketResult ¶
type ListBucketResult = component.ListBucketResult
ListBucketResult is an OSS bucket listing response.
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 = component.MemoryReader
MemoryReader serves files from memory.
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"`
// UXPlugins used for velaux plugins download/install with the use of addon registry.
UXPlugins map[string]string `json:"uxPlugins,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"`
// Annotations used for addon maintainers to add their own description or extensions to metadata.
Annotations map[string]string `json:"annotations,omitempty"`
}
Meta defines the format for a single addon
type ModuleImport ¶
type ModuleImport struct {
// Module is the module name; also the emitted component's name.
Module string
// Enabled gates whether this import is installed. Absent in the source
// file defaults to true.
Enabled bool
// Registry is the named module registry to resolve Module from; empty
// means search every configured registry.
Registry string
// Version is the exact module package version to install; empty means
// latest. addon:build/addon:publish already reject a semver range here,
// so this value is trusted as an exact pin by the time it reaches render time.
Version string
}
ModuleImport is one modules/_imports.cue entry: an external module the addon references by name, resolved from a module registry when the addon's rendered type: module component reconciles.
type OCIAddonCatalog ¶
type OCIAddonCatalog struct {
APIVersion string `json:"apiVersion"`
Addons []OCIAddonCatalogEntry `json:"addons"`
}
OCIAddonCatalog is the portable addon index stored as a Helm chart at the well-known <registry-prefix>/kubevela-addon-catalog repository.
type OCIAddonCatalogEntry ¶
type OCIAddonCatalogEntry struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Versions []string `json:"versions"`
}
OCIAddonCatalogEntry describes one addon in a portable OCI catalog.
type OSSAddonSource ¶
type OSSAddonSource = component.OSSAddonSource
OSSAddonSource is an OSS-backed source.
type Pattern ¶
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
PasswordStdin bool
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
// contains filtered or unexported fields
}
PushCmd is the command object to initiate a push command to ChartMuseum or an OCI registry.
func (*PushCmd) Push ¶ added in v1.5.0
Push pushes addons (i.e. Helm Charts) to ChartMuseum or an OCI registry. 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 ReaderOption ¶
type ReaderOption = component.ReaderOption
ReaderOption adjusts how a reader resolves content.
type ReaderType ¶
type ReaderType = component.ReaderType
ReaderType marks which transport a reader speaks.
type Registry ¶
Registry is the addon registry model.
func FilterDependencyRegistries ¶ added in v1.6.3
FilterDependencyRegistries will return all registries besides the target registry itself
type RegistryDataStore ¶
type RegistryDataStore = component.RegistryDataStore
RegistryDataStore reads and writes registries.
type SafeCopier ¶ added in v1.3.4
type SafeCopier = component.SafeCopier
SafeCopier copies a source without its credentials.
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
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 TokenSource ¶ added in v1.11.0
type TokenSource = component.TokenSource
TokenSource names the source holding a registry token.
type UIData ¶
type UIData struct {
Meta
APISchema *openapi3.Schema `json:"schema"`
UISchema []*schema.UIParameter `json:"uiSchema"`
// DefaultUISchema is the form generated from the addon's parameter, or
// nil where it could not be generated.
DefaultUISchema []*schema.UIParameter `json:"defaultUISchema,omitempty"`
// 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 GetUIData ¶
func GetUIData(r *Registry, meta *SourceMeta, opt ListOptions) (*UIData, error)
GetUIData get UIData of an addon from a registry
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
func ListUIData ¶
func ListUIData(r *Registry, registryAddonMeta map[string]SourceMeta, opt ListOptions) ([]*UIData, error)
ListUIData list UI data from addon registry
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) Error ¶ added in v1.3.1
func (v VersionUnMatchError) Error() string
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 returns the addon's versions, newest first.
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 builds a versioned addon registry backed by an indexed HTTP Helm repository.
func NewVersionedRegistry ¶
func NewVersionedRegistry(name string, source *HelmSource) (VersionedRegistry, error)
NewVersionedRegistry builds a chart-backed addon registry from a Helm source, selecting the transport from the URL scheme.
Only oci:// is dispatched specially. Everything else keeps the indexed HTTP path, because the scheme is not a reliable allowlist here: registries are stored with cm:// as well as http(s)://, and rejecting an unrecognised scheme would break records that work today.
func ToVersionedRegistry ¶ added in v1.9.0
func ToVersionedRegistry(registry Registry) (VersionedRegistry, error)
ToVersionedRegistry converts registry to versioned registry
type WholeAddonPackage ¶ added in v1.3.0
type WholeAddonPackage struct {
InstallPackage
APISchema *openapi3.Schema `json:"schema"`
// DefaultUISchema is the form generated from the addon's parameter, or
// nil where it could not be generated.
DefaultUISchema []*schema.UIParameter `json:"defaultUISchema,omitempty"`
// 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
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package service provides a render-only addon service: it resolves an addon from the registry and renders its Application plus auxiliaries, without dispatching anything to the cluster.
|
Package service provides a render-only addon service: it resolves an addon from the registry and renders its Application plus auxiliaries, without dispatching anything to the cluster. |
|
api
Package api holds the leaf types and injection seam shared between the render-only addon service and the CueX addon provider.
|
Package api holds the leaf types and injection seam shared between the render-only addon service and the CueX addon provider. |