service

package
v2.0.1-rc40 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InfoName      = "n"
	InfoNamespace = "ns"
	InfoExpiry    = "e"
)
View Source
const (
	Certificate = "certificate"
	CertRoot    = "baetyl.ca"
)
View Source
const (
	HookNamePopulateConfig = "populateConfig"
)
View Source
const (
	TemplateKubeInitCommand = `` /* 264-byte string literal not displayed */
)

Variables

View Source
var (
	CmdExpirationInSeconds = int64(60 * 60)
	HookNamePopulateParams = "populateParams"
)

Functions

This section is empty.

Types

type AppCombinedService

type AppCombinedService struct {
	App    ApplicationService
	Config ConfigService
	Secret SecretService
}

AppCombinedService is a combined service contains application, configuration and secret services.

func NewAppCombinedService

func NewAppCombinedService(cfg *config.CloudConfig) (*AppCombinedService, error)

type ApplicationService

type ApplicationService interface {
	Get(namespace, name, version string) (*specV1.Application, error)
	Create(namespace string, app *specV1.Application) (*specV1.Application, error)
	Update(namespace string, app *specV1.Application) (*specV1.Application, error)
	Delete(namespace, name, version string) error
	List(namespace string, listOptions *models.ListOptions) (*models.ApplicationList, error)
	CreateWithBase(namespace string, app, base *specV1.Application) (*specV1.Application, error)
}

ApplicationService ApplicationService

func NewApplicationService

func NewApplicationService(config *config.CloudConfig) (ApplicationService, error)

NewApplicationService NewApplicationService

type AuthService

type AuthService interface {
	Authenticate(c *common.Context) error
	SignToken(meta []byte) ([]byte, error)
	VerifyToken(meta, sign []byte) bool
	GenToken(map[string]interface{}) (string, error)
}

func NewAuthService

func NewAuthService(config *config.CloudConfig) (AuthService, error)

type CacheService

type CacheService interface {
	Get(key string, load func(string) (string, error)) (string, error)
	GetProperty(key string) (string, error)
	GetFileData(file string) (string, error)
}

func NewCacheService

func NewCacheService(cfg *config.CloudConfig) (CacheService, error)

type CacheServiceImpl

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

func (*CacheServiceImpl) Get

func (s *CacheServiceImpl) Get(key string, load func(string) (string, error)) (string, error)

func (*CacheServiceImpl) GetFileData

func (s *CacheServiceImpl) GetFileData(file string) (string, error)

func (*CacheServiceImpl) GetProperty

func (s *CacheServiceImpl) GetProperty(key string) (string, error)

type ConfigService

type ConfigService interface {
	Get(namespace, name, version string) (*specV1.Configuration, error)
	List(namespace string, listOptions *models.ListOptions) (*models.ConfigurationList, error)
	Create(namespace string, config *specV1.Configuration) (*specV1.Configuration, error)
	Update(namespace string, config *specV1.Configuration) (*specV1.Configuration, error)
	Upsert(namespace string, config *specV1.Configuration) (*specV1.Configuration, error)
	Delete(namespace, name string) error
}

ConfigService ConfigService

func NewConfigService

func NewConfigService(config *config.CloudConfig) (ConfigService, error)

NewConfigService NewConfigService

type FunctionService

type FunctionService interface {
	List(userID, source string) ([]models.Function, error)
	ListFunctionVersions(userID, name, source string) ([]models.Function, error)
	ListSources() []models.FunctionSource
	ListRuntimes() (map[string]string, error)
	GetFunction(userID, name, version, source string) (*models.Function, error)
}

func NewFunctionService

func NewFunctionService(cfg *config.CloudConfig) (FunctionService, error)

NewFunctionService NewFunctionService

type GetInitResource

type GetInitResource func(ns, nodeName string, params map[string]interface{}) ([]byte, error)

type HandlerPopulateConfig

type HandlerPopulateConfig func(cfg *specV1.Configuration, metadata map[string]string) error

type HandlerPopulateParams

type HandlerPopulateParams func(ns string, params map[string]interface{}) error

type IndexService

type IndexService interface {
	// comment
	RefreshIndex(namespace string, keyA, keyB common.Resource, valueA string, valueBs []string) error
	ListIndex(namespace string, keyA, byKeyB common.Resource, valueB string) ([]string, error)
	// app and config
	RefreshAppIndexByConfig(namespace, config string, apps []string) error
	RefreshConfigIndexByApp(namespace, app string, configs []string) error
	ListAppIndexByConfig(namespace, config string) ([]string, error)
	ListConfigIndexByApp(namespace, app string) ([]string, error)

	ListNodesByApp(namespace, app string) ([]string, error)
	ListAppsByNode(namespace, node string) ([]string, error)
	ListAppIndexBySecret(namespace, secret string) ([]string, error)

	// app and secret
	RefreshSecretIndexByApp(namespace, app string, secrets []string) error
	RefreshNodesIndexByApp(namespace, appName string, nodes []string) error
	RefreshAppsIndexByNode(namespace, node string, apps []string) error
}

func NewIndexService

func NewIndexService(config *config.CloudConfig) (IndexService, error)

NewIndexService New Index Service

type InitService

type InitService interface {
	GetResource(ns, nodeName, resourceName string, params map[string]interface{}) (interface{}, error)
	GenApps(ns, nodeName string) ([]*specV1.Application, error)
}

InitService

func NewInitService

func NewInitService(config *config.CloudConfig) (InitService, error)

NewSyncService new SyncService

type InitServiceImpl

type InitServiceImpl struct {
	AuthService     AuthService
	NodeService     NodeService
	TemplateService TemplateService
	*AppCombinedService
	PKI             PKIService
	Hooks           map[string]interface{}
	ResourceMapFunc map[string]GetInitResource
	// contains filtered or unexported fields
}

func (*InitServiceImpl) GenApps

func (s *InitServiceImpl) GenApps(ns, nodeName string) ([]*specV1.Application, error)

func (*InitServiceImpl) GetCoreAppFromDesire

func (s *InitServiceImpl) GetCoreAppFromDesire(ns, nodeName string) (*specV1.Application, error)

func (*InitServiceImpl) GetInitCommand

func (s *InitServiceImpl) GetInitCommand(ns, nodeName string, params map[string]interface{}) ([]byte, error)

func (*InitServiceImpl) GetNodeCert

func (s *InitServiceImpl) GetNodeCert(app *specV1.Application) (*specV1.Secret, error)

func (*InitServiceImpl) GetResource

func (s *InitServiceImpl) GetResource(ns, nodeName, resourceName string, params map[string]interface{}) (interface{}, error)

type LicenseService

type LicenseService interface {
	ProtectCode() error
	CheckLicense() error
	CheckQuota(namespace string, collector plugin.QuotaCollector) error
	GetQuota(namespace string) (map[string]int, error)
}

func NewLicenseService

func NewLicenseService(config *config.CloudConfig) (LicenseService, error)

type NamespaceService

type NamespaceService interface {
	Get(namespace string) (*models.Namespace, error)
	Create(namespace *models.Namespace) (*models.Namespace, error)
	Delete(namespace *models.Namespace) error
}

NamespaceService NamespaceService

func NewNamespaceService

func NewNamespaceService(config *config.CloudConfig) (NamespaceService, error)

NewNamespaceService NewNamespaceService

type NodeService

type NodeService interface {
	Get(namespace, name string) (*specV1.Node, error)
	List(namespace string, listOptions *models.ListOptions) (*models.NodeList, error)
	Create(namespace string, node *specV1.Node) (*specV1.Node, error)
	Update(namespace string, node *specV1.Node) (*specV1.Node, error)
	Delete(namespace, name string) error

	UpdateReport(namespace, name string, report specV1.Report) (*models.Shadow, error)
	UpdateDesire(namespace, name string, desire specV1.Desire) (*models.Shadow, error)

	GetDesire(namespace, name string) (*specV1.Desire, error)

	UpdateNodeAppVersion(namespace string, app *specV1.Application) ([]string, error)
	DeleteNodeAppVersion(namespace string, app *specV1.Application) ([]string, error)
}

NodeService NodeService

func NewNodeService

func NewNodeService(config *config.CloudConfig) (NodeService, error)

NewNodeService NewNodeService

type ObjectService

type ObjectService interface {
	ListSources() []models.ObjectStorageSource
	ListBuckets(userID, source string) ([]models.Bucket, error)
	ListBucketObjects(userID, bucket, source string) (*models.ListObjectsResult, error)
	CreateBucketIfNotExist(userID, bucket, permission, source string) (*models.Bucket, error)
	PutObjectFromURLIfNotExist(userID, bucket, name, url, source string) error
	GenObjectURL(userID string, param models.ConfigObjectItem) (*models.ObjectURL, error)
}

func NewObjectService

func NewObjectService(config *config.CloudConfig) (ObjectService, error)

NewObjectService NewObjectService

type PKIService

type PKIService interface {
	// GetCA get ca
	GetCA() ([]byte, error)
	// SignServerCertificate sign a certificate which can be used to connect to cloud
	SignServerCertificate(cn string, altNames models.AltNames) (*models.PEMCredential, error)
	// SignNodeCertificate sign a certificate which can be used to connect to cloud
	SignClientCertificate(cn string, altNames models.AltNames) (*models.PEMCredential, error)
	// DeleteServerCertificate delete a server certificate by certId
	DeleteServerCertificate(certId string) error
	// DeleteClientCertificate delete a server certificate by certId
	DeleteClientCertificate(certId string) error
}

func NewPKIService

func NewPKIService(config *config.CloudConfig) (PKIService, error)

NewPKIService create a certificate service

type PropertyService

type PropertyService 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)
}

func NewPropertyService

func NewPropertyService(config *config.CloudConfig) (PropertyService, error)

NewPropertyService

type SecretService

type SecretService interface {
	Get(namespace, name, version string) (*specV1.Secret, error)
	List(namespace string, listOptions *models.ListOptions) (*models.SecretList, error)
	Create(namespace string, secret *specV1.Secret) (*specV1.Secret, error)
	Update(namespace string, secret *specV1.Secret) (*specV1.Secret, error)
	Delete(namespace, name string) error
}

SecretService SecretService

func NewSecretService

func NewSecretService(config *config.CloudConfig) (SecretService, error)

NewSecretService NewSecretService

type SyncService

type SyncService interface {
	Report(namespace, name string, report specV1.Report) (specV1.Desire, error)
	Desire(namespace string, infos []specV1.ResourceInfo, metadata map[string]string) ([]specV1.ResourceValue, error)
}

SyncService sync service

func NewSyncService

func NewSyncService(config *config.CloudConfig) (SyncService, error)

NewSyncService new SyncService

type SyncServiceImpl

type SyncServiceImpl struct {
	plugin.ModelStorage
	plugin.DBStorage

	ConfigService ConfigService
	NodeService   NodeService
	AppService    ApplicationService
	SecretService SecretService
	ObjectService ObjectService
	Hooks         map[string]interface{}
}

func (*SyncServiceImpl) Desire

func (t *SyncServiceImpl) Desire(namespace string, crdInfos []specV1.ResourceInfo, metadata map[string]string) ([]specV1.ResourceValue, error)

func (*SyncServiceImpl) PopulateConfig

func (t *SyncServiceImpl) PopulateConfig(cfg *specV1.Configuration, metadata map[string]string) error

func (*SyncServiceImpl) PopulateConfigObject

func (t *SyncServiceImpl) PopulateConfigObject(k, v string, cfg *specV1.Configuration) error

func (*SyncServiceImpl) Report

func (t *SyncServiceImpl) Report(namespace, name string, report specV1.Report) (specV1.Desire, error)

type TemplateService

type TemplateService interface {
	Execute(name, text string, params map[string]interface{}) ([]byte, error)
	GetTemplate(filename string) (string, error)
	ParseTemplate(filename string, params map[string]interface{}) ([]byte, error)
	UnmarshalTemplate(filename string, params map[string]interface{}, out interface{}) error
}

func NewTemplateService

func NewTemplateService(cfg *config.CloudConfig, funcs map[string]interface{}) (TemplateService, error)

type TemplateServiceImpl

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

TemplateServiceImpl is a service to read and parse template files.

func (*TemplateServiceImpl) Execute

func (s *TemplateServiceImpl) Execute(name, text string, params map[string]interface{}) ([]byte, error)

func (*TemplateServiceImpl) GetTemplate

func (s *TemplateServiceImpl) GetTemplate(filename string) (string, error)

func (*TemplateServiceImpl) ParseTemplate

func (s *TemplateServiceImpl) ParseTemplate(filename string, params map[string]interface{}) ([]byte, error)

func (*TemplateServiceImpl) UnmarshalTemplate

func (s *TemplateServiceImpl) UnmarshalTemplate(filename string, params map[string]interface{}, out interface{}) error

Jump to

Keyboard shortcuts

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