Documentation
¶
Index ¶
- Constants
- Variables
- func Convert2AppName(name string) string
- func Convert2SecName(name string) string
- func DisableAddon(ctx context.Context, cli client.Client, name string) error
- func EnableAddon(ctx context.Context, addon *types.Addon, cli client.Client, ...) error
- func GetAddonsFromReader(r AsyncReader, opt ListOptions) ([]*types.Addon, error)
- func GetSingleAddonFromReader(r AsyncReader, addonName string, opt ListOptions) (*types.Addon, error)
- func NewAddonError(msg string) error
- func RenderAppAndResources(addon *types.Addon, args map[string]interface{}) (*v1beta1.Application, []*unstructured.Unstructured, ...)
- func RenderArgsSecret(addon *types.Addon, args map[string]interface{}) *unstructured.Unstructured
- func WrapErrRateLimit(err error) error
- type AsyncReader
- type File
- type GitAddonSource
- type Handler
- type Item
- type ListBucketResult
- type ListOptions
- type OSSAddonSource
- type OssItem
- type ReaderType
- type Registry
- type RegistryDataStore
- type Source
Constants ¶
const ( // ReadmeFileName is the addon readme file name ReadmeFileName string = "readme.md" // MetadataFileName is the addon meatadata.yaml file name MetadataFileName string = "metadata.yaml" // TemplateFileName is the addon template.yaml dir name TemplateFileName string = "template.yaml" // ResourcesDirName is the addon resources/ dir name ResourcesDirName string = "resources" // DefinitionsDirName is the addon definitions/ dir name DefinitionsDirName string = "definitions" // DefSchemaName is the addon definition schemas dir name DefSchemaName string = "schemas" )
const ( // EOFError is error returned by xml parse EOFError string = "EOF" // DirType means a directory DirType = "dir" // FileType means a file FileType = "file" )
Variables ¶
var ( // GetLevelOptions used when get or list addons GetLevelOptions = ListOptions{GetDetail: true, GetDefinition: true, GetParameter: true} // EnableLevelOptions used when enable addon EnableLevelOptions = ListOptions{GetDetail: true, GetDefinition: true, GetResource: true, GetTemplate: true, GetParameter: true, GetDefSchema: 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") )
Functions ¶
func Convert2SecName ¶
Convert2SecName generate addon argument secret name
func DisableAddon ¶
DisableAddon will disable addon from cluster.
func EnableAddon ¶
func EnableAddon(ctx context.Context, addon *types.Addon, cli client.Client, apply apply.Applicator, source Source, args map[string]interface{}) error
EnableAddon will enable addon with dependency check, source is where addon from.
func GetAddonsFromReader ¶
func GetAddonsFromReader(r AsyncReader, opt ListOptions) ([]*types.Addon, error)
GetAddonsFromReader list addons from AsyncReader
func GetSingleAddonFromReader ¶
func GetSingleAddonFromReader(r AsyncReader, addonName string, opt ListOptions) (*types.Addon, error)
GetSingleAddonFromReader read single addon from Reader
func RenderAppAndResources ¶
func RenderAppAndResources(addon *types.Addon, args map[string]interface{}) (*v1beta1.Application, []*unstructured.Unstructured, []*unstructured.Unstructured, error)
RenderAppAndResources render a K8s application
func RenderArgsSecret ¶
func RenderArgsSecret(addon *types.Addon, args map[string]interface{}) *unstructured.Unstructured
RenderArgsSecret render addon enable argument to secret
func WrapErrRateLimit ¶
WrapErrRateLimit return ErrRateLimit if is the situation, or return error directly
Types ¶
type AsyncReader ¶
type AsyncReader interface {
// Read will return either file content or directory sub-paths
// Read should accept relative path to github repo/path or OSS bucket
Read(path string) (content string, subItem []Item, err error)
// Addon returns a addon to be readed
Addon() *types.Addon
// SendErr to outside and quit
SendErr(err error)
// ErrCh will get the reader's channel to send error
ErrCh() chan error
// Mutex return an mutex for slice insert
Mutex() *sync.Mutex
// RelativePath return a relative path to GitHub repo/path or OSS bucket
RelativePath(item Item) string
// WithNewAddonAndMutex is mainly for copy the whole reader to read a new addon
WithNewAddonAndMutex() AsyncReader
}
AsyncReader helps async read files of addon
func NewAsyncReader ¶
func NewAsyncReader(baseURL, dirOrBucket, token string, rdType ReaderType) (AsyncReader, error)
NewAsyncReader create AsyncReader from 1. GitHub url and directory 2. OSS endpoint and bucket
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
func (*GitAddonSource) GetAddon ¶
func (git *GitAddonSource) GetAddon(name string, opt ListOptions) (*types.Addon, error)
GetAddon get an addon info from GitAddonSource, can be used for get or enable
func (*GitAddonSource) ListAddons ¶
func (git *GitAddonSource) ListAddons(opt ListOptions) ([]*types.Addon, error)
ListAddons list addons' info from GitAddonSource
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler helps addon enable, dependency-check, dispatch resources
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 ¶
ListBucketResult describe a file list from OSS
type ListOptions ¶
type ListOptions struct {
GetDetail bool
GetDefinition bool
GetResource bool
GetParameter bool
GetTemplate bool
GetDefSchema bool
}
ListOptions contains flags mark what files should be read in an addon directory
type OSSAddonSource ¶
type OSSAddonSource struct {
EndPoint string `json:"end_point" validate:"required"`
Bucket string `json:"bucket"`
}
OSSAddonSource is Addon source from alicloud OSS
func (*OSSAddonSource) GetAddon ¶
func (o *OSSAddonSource) GetAddon(name string, opt ListOptions) (*types.Addon, error)
GetAddon from OSSAddonSource
func (*OSSAddonSource) ListAddons ¶
func (o *OSSAddonSource) ListAddons(opt ListOptions) ([]*types.Addon, error)
ListAddons from OSSAddonSource
type OssItem ¶
type OssItem struct {
// contains filtered or unexported fields
}
OssItem is Item implement for OSS
type Registry ¶
type Registry struct {
Name string `json:"name"`
Git *GitAddonSource `json:"git,omitempty"`
Oss *OSSAddonSource `json:"oss,omitempty"`
}
Registry represent a addon registry model
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