plugin

package
v2.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionRead = "READ"
	PermissionFull = "FULL_CONTROL"

	PermissionResourceConfig      = "config"
	PermissionResourceSecret      = "secret"
	PermissionResourceApp         = "app"
	PermissionResourceNode        = "node"
	PermissionResourceBatch       = "batch"
	PermissionResourceDevice      = "device"
	PermissionResourceDeviceModel = "devicemodel"
	PermissionResourceDriver      = "driver"
)
View Source
const (
	QuotaNode  = "maxNodeCount"
	QuotaBatch = "maxBatchCount"
	MenuEnable = "menuEnable"
)

Variables

View Source
var (
	ErrGetAuthorizedUserInfo = errors.New("failed to get authorized user info")
)

Functions

func ClosePlugins

func ClosePlugins()

ClosePlugins ClosePlugins

func RegisterFactory

func RegisterFactory(name string, f Factory)

RegisterFactory adds a supported plugin

Types

type Application

type Application interface {
	GetApplication(tx interface{}, namespace, name, version string) (*v1.Application, error)
	CreateApplication(tx interface{}, namespace string, application *v1.Application) (*v1.Application, error)
	UpdateApplication(tx interface{}, namespace string, application *v1.Application) (*v1.Application, error)
	DeleteApplication(tx interface{}, namespace, name string) error
	ListApplication(tx interface{}, namespace string, listOptions *models.ListOptions) (*models.ApplicationList, error)
	ListApplicationsByNames(tx interface{}, ns string, names []string) ([]models.AppItem, int, error)
}

type Auth

type Auth interface {
	Authenticate(c *common.Context) error
	AuthAndVerify(c *common.Context, pr *PermissionRequest) error
	Verify(c *common.Context, pr *PermissionRequest) error
	io.Closer
}

Auth interfaces of auth

type Cert

type Cert struct {
	CertId      string    `db:"cert_id"`
	ParentId    string    `db:"parent_id"`
	Type        string    `db:"type"`
	CommonName  string    `db:"common_name"`
	Csr         string    `db:"csr"`         // base64
	Content     string    `db:"content"`     // base64
	PrivateKey  string    `db:"private_key"` // base64
	Description string    `db:"description"`
	NotBefore   time.Time `db:"not_before"`
	NotAfter    time.Time `db:"not_after"`
}

type Configuration

type Configuration interface {
	GetConfig(tx interface{}, namespace, name, version string) (*v1.Configuration, error)
	CreateConfig(tx interface{}, namespace string, configModel *v1.Configuration) (*v1.Configuration, error)
	UpdateConfig(tx interface{}, namespace string, configurationModel *v1.Configuration) (*v1.Configuration, error)
	DeleteConfig(tx interface{}, namespace, name string) error
	ListConfig(namespace string, listOptions *models.ListOptions) (*models.ConfigurationList, error)
}

type Cron added in v2.3.0

type Cron interface {
	GetCron(name, namespace string) (*models.Cron, error)
	CreateCron(*models.Cron) error
	UpdateCron(*models.Cron) error
	DeleteCron(name, namespace string) error
	ListExpiredApps() ([]models.Cron, error)
	DeleteExpiredApps([]uint64) error
	io.Closer
}

type CsrfValidator added in v2.3.0

type CsrfValidator interface {
	Verify(c *common.Context) error
	io.Closer
}

type DataCache added in v2.6.1

type DataCache interface {
	SetByte(key string, value []byte) error
	GetByte(key string) ([]byte, error)
	SetString(key string, value string) error
	GetString(key string) (string, error)
	Delete(key string) error
	Exist(key string) (bool, error)
	io.Closer
}

type Decrypt added in v2.3.0

type Decrypt interface {
	Decrypt(cipherText string) (string, error)

	io.Closer
}

type Factory

type Factory func() (Plugin, error)

Factory create engine by given config

type Function

type Function interface {
	List(userID string) ([]models.Function, error)
	ListFunctionVersions(userID, name string) ([]models.Function, error)
	Get(userID, name, version string) (*models.Function, error)
	io.Closer
}

Function interface of Function

type Index added in v2.1.1

type Index interface {
	// index
	CreateIndex(namespace string, keyA, keyB common.Resource, valueA, valueB string) (sql.Result, error)
	ListIndex(namespace string, keyA, byKeyB common.Resource, valueB string) ([]string, error)
	DeleteIndex(namespace string, keyA, byKeyB common.Resource, valueB string) (sql.Result, error)
	CreateIndexTx(tx *sqlx.Tx, namespace string, keyA, keyB common.Resource, valueA, valueB string) (sql.Result, error)
	ListIndexTx(tx *sqlx.Tx, namespace string, keyA, byKeyB common.Resource, valueB string) ([]string, error)
	DeleteIndexTx(tx *sqlx.Tx, namespace string, keyA, byKeyB common.Resource, valueB string) (sql.Result, error)
	RefreshIndex(tx interface{}, namespace string, keyA, keyB common.Resource, valueA string, valueBs []string) error
	io.Closer
}

Index interface of Index

type JWT added in v2.3.0

type JWT interface {
	GetJWT(c *common.Context) (string, error)
	GenerateJWT(c *common.Context) (*JWTInfo, error)
	RefreshJWT(c *common.Context) (*JWTInfo, error)
	CheckAndParseJWT(c *common.Context) (map[string]interface{}, error)
	io.Closer
}

type JWTInfo added in v2.3.0

type JWTInfo struct {
	Token      string    `json:"token"`
	Expire     time.Time `json:"expire"`
	MaxRefresh time.Time `json:"maxRefresh"`
}

type License

type License interface {
	ProtectCode() error
	CheckLicense() error
	io.Closer
}

type Locker added in v2.2.0

type Locker interface {

	// Lock lock the resource, Lock should be paired with Unlock.
	// PARAMS:
	//   - name: the lock's name
	//   - ttl: expire time of lock, if 0, use default time.
	// RETURNS:
	//   error: if has error else nil
	Lock(ctx context.Context, name string, ttl int64) (string, error)

	// Unlock release the lock by name
	// PARAMS:
	//	 - name: the lock's name
	// RETURNS:
	//   error: if has error else nil
	Unlock(ctx context.Context, name, version string)
	io.Closer
}

Locker - the lock manager for baetyl cloud

type Module added in v2.2.0

type Module interface {
	GetModules(name string) ([]models.Module, error)
	GetModuleByVersion(name, version string) (*models.Module, error)
	GetModuleByImage(name, image string) (*models.Module, error)
	GetLatestModule(name string) (*models.Module, error)
	CreateModule(module *models.Module) (*models.Module, error)
	UpdateModuleByVersion(module *models.Module) (*models.Module, error)
	DeleteModules(name string) error
	DeleteModuleByVersion(name, version string) error
	ListModules(filter *models.Filter, tp common.ModuleType) ([]models.Module, error)
	GetLatestModuleImage(name string) (string, error)
	GetLatestModuleProgram(name, platform string) (string, error)

	GetModuleTx(tx *sqlx.Tx, name string) ([]models.Module, error)
	GetModuleByVersionTx(tx *sqlx.Tx, name, version string) (*models.Module, error)
	GetModuleByImageTx(tx *sqlx.Tx, name, image string) (*models.Module, error)
	GetLatestModuleTx(tx *sqlx.Tx, name string) (*models.Module, error)
	CreateModuleTx(tx *sqlx.Tx, module *models.Module) error
	UpdateModuleByVersionTx(tx *sqlx.Tx, module *models.Module) error
	DeleteModulesTx(tx *sqlx.Tx, name string) error
	DeleteModuleByVersionTx(tx *sqlx.Tx, name, version string) error
	ListModulesTx(tx *sqlx.Tx, filter *models.Filter) ([]models.Module, error)
	GetLatestModuleImageTx(tx *sqlx.Tx, name string) (string, error)
	GetLatestModuleProgramTx(tx *sqlx.Tx, name, platform string) (string, error)

	// close
	io.Closer
}

type Namespace

type Namespace interface {
	GetNamespace(namespace string) (*models.Namespace, error)
	CreateNamespace(namespace *models.Namespace) (*models.Namespace, error)
	ListNamespace(listOptions *models.ListOptions) (*models.NamespaceList, error)
	DeleteNamespace(namespace *models.Namespace) error
}

type Node

type Node interface {
	GetNode(tx interface{}, namespace, name string) (*v1.Node, error)
	CreateNode(tx interface{}, namespace string, node *v1.Node) (*v1.Node, error)
	UpdateNode(tx interface{}, namespace string, node []*v1.Node) ([]*v1.Node, error)
	DeleteNode(tx interface{}, namespace, name string) error
	ListNode(tx interface{}, namespace string, listOptions *models.ListOptions) (*models.NodeList, error)
	CountAllNode(tx interface{}) (int, error)
	GetNodeByNames(tx interface{}, namespace string, names []string) ([]v1.Node, error)
}

type Object

type Object interface {
	IsAccountEnabled() bool

	ListInternalBuckets(userID string) ([]models.Bucket, error)
	HeadInternalBucket(userID, bucket string) error
	CreateInternalBucket(userID, bucket, permission string) error
	ListInternalBucketObjects(userID, bucket string, params *models.ObjectParams) (*models.ListObjectsResult, error)
	PutInternalObject(userID, bucket, name string, b []byte) error
	PutInternalObjectFromFile(userID, bucket, name, filename string) error
	PutInternalObjectFromURL(userID, bucket, name, url string) error
	GetInternalObject(userID, bucket, name string) (*models.Object, error)
	HeadInternalObject(userID, bucket, name string) (*models.ObjectMeta, error)
	DeleteInternalObject(userID, bucket, name string) error
	GenInternalObjectURL(userID, bucket, name string) (*models.ObjectURL, error)
	GenInternalPutObjectURL(userID, bucket, name string) (*models.ObjectURL, error)

	ListExternalBuckets(info models.ExternalObjectInfo) ([]models.Bucket, error)
	HeadExternalBucket(info models.ExternalObjectInfo, bucket string) error
	CreateExternalBucket(info models.ExternalObjectInfo, bucket, permission string) error
	ListExternalBucketObjects(info models.ExternalObjectInfo, bucket string, params *models.ObjectParams) (*models.ListObjectsResult, error)
	PutExternalObject(info models.ExternalObjectInfo, bucket, name string, b []byte) error
	PutExternalObjectFromFile(info models.ExternalObjectInfo, bucket, name, filename string) error
	PutExternalObjectFromURL(info models.ExternalObjectInfo, bucket, name, url string) error
	GetExternalObject(info models.ExternalObjectInfo, bucket, name string) (*models.Object, error)
	HeadExternalObject(info models.ExternalObjectInfo, bucket, name string) (*models.ObjectMeta, error)
	DeleteExternalObject(info models.ExternalObjectInfo, bucket, name string) error
	GenExternalObjectURL(info models.ExternalObjectInfo, bucket, name string) (*models.ObjectURL, error)

	io.Closer
}

Object Object TODO: userID doesn't belong to Object, should in the metedata

type PKI

type PKI interface {
	// root cert
	GetRootCertID() string
	// info : 生成根证书的相关信息   parentId : 上一级根证书id,可为空
	CreateRootCert(info *x509.CertificateRequest, parentId string) (string, error)
	GetRootCert(rootId string) ([]byte, error)
	DeleteRootCert(rootId string) error

	// server cert
	CreateServerCert(csr []byte, rootId string) (string, error)
	GetServerCert(certId string) ([]byte, error)
	DeleteServerCert(certId string) error

	// client cert
	CreateClientCert(csr []byte, rootId string) (string, error)
	GetClientCert(certId string) ([]byte, error)
	DeleteClientCert(certId string) error

	// close
	io.Closer
}

type PKIStorage

type PKIStorage interface {
	CreateCert(cert Cert) error
	DeleteCert(certId string) error
	UpdateCert(cert Cert) error
	GetCert(certId string) (*Cert, error)
	CountCertByParentId(parentId string) (int, error)
	io.Closer
}

type PermissionRequest added in v2.2.0

type PermissionRequest struct {
	Region         string         `json:"region"`
	Resource       string         `json:"resource"`
	Permission     []string       `json:"permission"`
	RequestContext RequestContext `json:"request_context"`
}

type Plugin

type Plugin interface {
	io.Closer
}

Plugin interfaces

func GetPlugin

func GetPlugin(name string) (Plugin, error)

GetPlugin GetPlugin

type Property

type Property interface {
	GetProperty(name string) (*models.Property, error)
	CreateProperty(property *models.Property) error
	DeleteProperty(name string) error
	ListProperty(page *models.Filter) ([]models.Property, error) //Pagination
	CountProperty(name string) (int, error)
	UpdateProperty(property *models.Property) error

	GetPropertyValue(name string) (string, error)

	io.Closer
}

type Pubsub

type Pubsub interface {
	pubsub.Pubsub
}

type Quota added in v2.4.3

type Quota interface {
	GetQuota(namespace string) (map[string]int, error)
	GetDefaultQuotas(namespace string) (map[string]int, error)
	CreateQuota(namespace string, quotas map[string]int) error
	UpdateQuota(namespace, quotaName string, quota int) error
	AcquireQuota(namespace, quotaName string, number int) error
	ReleaseQuota(namespace, quotaName string, number int) error
	DeleteQuota(namespace, quotaName string) error
	DeleteQuotaByNamespace(namespace string) error
	io.Closer
}

type QuotaCollector

type QuotaCollector func(namespace string) (map[string]int, error)

type RequestContext added in v2.2.0

type RequestContext struct {
	IpAddress  string                 `json:"ip_address"`
	Referer    string                 `json:"referer"`
	Conditions map[string]interface{} `json:"conditions"`
}

type Resource added in v2.2.0

type Resource interface {
	Node
	Application
	Configuration
	Secret
	Namespace
	io.Closer
}

type Secret

type Secret interface {
	GetSecret(tx interface{}, namespace, name, version string) (*v1.Secret, error)
	CreateSecret(tx interface{}, namespace string, secretModel *v1.Secret) (*v1.Secret, error)
	UpdateSecret(namespace string, secretMapModel *v1.Secret) (*v1.Secret, error)
	DeleteSecret(tx interface{}, namespace, name string) error
	ListSecret(namespace string, listOptions *models.ListOptions) (*models.SecretList, error)
}

type Shadow

type Shadow interface {
	Get(tx interface{}, namespace, name string) (*models.Shadow, error)
	ListShadowByNames(tx interface{}, namespace string, names []string) ([]*models.Shadow, error)
	Create(tx interface{}, shadow *models.Shadow) (*models.Shadow, error)
	BatchCreateShadow(shadows []*models.Shadow) ([]*models.Shadow, error)
	Delete(tx interface{}, namespace, name string) error
	UpdateDesire(tx interface{}, shadow *models.Shadow) error
	UpdateDesires(tx interface{}, shadows []*models.Shadow) error
	UpdateReport(shadow *models.Shadow) (*models.Shadow, error)
	List(namespace string, nodeList *models.NodeList) (*models.ShadowList, error)
	ListAll(namespace string) (*models.ShadowList, error)
	io.Closer
}

Shadow

type Sign added in v2.2.0

type Sign interface {
	Signature(meta []byte) ([]byte, error)
	Verify(meta, sign []byte) bool
	io.Closer
}

Sign interfaces of Sign

type SyncLink interface {
	Start()
	AddMsgRouter(k string, v interface{})
	io.Closer
}

type Task added in v2.1.1

type Task interface {
	task.TaskProducer
	task.TaskWorker

	io.Closer
}

Task interface of Task

type TransactionFactory added in v2.2.0

type TransactionFactory interface {
	BeginTx() (interface{}, error)
	Commit(interface{})
	Rollback(interface{})
	io.Closer
}

Directories

Path Synopsis
cache
localcache
Package localcache freecache implements a local cache for files
Package localcache freecache implements a local cache for files
default
pki
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/cloud/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/cloud/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
link

Jump to

Keyboard shortcuts

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