service

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: Apache-2.0 Imports: 89 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GrantTypeAccess is the grant type for access token
	GrantTypeAccess = "access"
	// GrantTypeRefresh is the grant type for refresh token
	GrantTypeRefresh = "refresh"
)
View Source
const DefinitionHidden = "true"

DefinitionHidden means the definition can not be used in VelaUX

View Source
const (
	// InitAdminPassword the password of first admin user
	InitAdminPassword = "VelaUX12345"
)

Variables

View Source
var ResourceMaps = map[string]resourceMetadata{
	"project": {
		// contains filtered or unexported fields
	},
	"cluster": {
		// contains filtered or unexported fields
	},
	"addon": {
		// contains filtered or unexported fields
	},
	"addonRegistry": {
		// contains filtered or unexported fields
	},
	"target": {
		// contains filtered or unexported fields
	},
	"user": {
		// contains filtered or unexported fields
	},
	"role": {},
	"permission": {
		// contains filtered or unexported fields
	},
	"systemSetting": {},
	"definition": {
		// contains filtered or unexported fields
	},
	"configType": {
		// contains filtered or unexported fields
	},
}

ResourceMaps all resources definition for RBAC

View Source
var WebhookHandlers []string

WebhookHandlers is the webhook handlers

Functions

func AddonImpl2AddonRes

func AddonImpl2AddonRes(impl *pkgaddon.UIData) (*apis.DetailAddonResponse, error)

AddonImpl2AddonRes convert pkgaddon.UIData to the type apiserver need

func CheckAppEnvBindingsContainTarget

func CheckAppEnvBindingsContainTarget(envBindings []*apisv1.EnvBindingBase, targetName string) (bool, error)

CheckAppEnvBindingsContainTarget check envbinding contain target

func ConvertProjectModel2Base

func ConvertProjectModel2Base(project *model.Project, owner *model.User) *apisv1.ProjectBase

ConvertProjectModel2Base convert project model to base struct

func ConvertProjectUserModel2Base

func ConvertProjectUserModel2Base(user *model.ProjectUser) *apisv1.ProjectUserBase

ConvertProjectUserModel2Base convert project user model to base struct

func GeneratePasswordHash

func GeneratePasswordHash(s string) (string, error)

GeneratePasswordHash generate password hash

func InitData

func InitData(ctx context.Context) error

InitData init data

func InitServiceBean

func InitServiceBean(c config.Config) []interface{}

InitServiceBean init all service instance

func ParseToken

func ParseToken(tokenString string) (*model.CustomClaims, error)

ParseToken parses and verifies a token

func SyncConfigs

func SyncConfigs(ctx context.Context, k8sClient client.Client, project string, targets []*model.ClusterTarget) error

SyncConfigs will sync configs to working clusters

func TerminateWorkflow

func TerminateWorkflow(ctx context.Context, kubecli client.Client, app *v1beta1.Application) error

TerminateWorkflow terminate workflow

Types

type AddonService

type AddonService interface {
	GetAddonRegistry(ctx context.Context, name string) (*apis.AddonRegistry, error)
	CreateAddonRegistry(ctx context.Context, req apis.CreateAddonRegistryRequest) (*apis.AddonRegistry, error)
	DeleteAddonRegistry(ctx context.Context, name string) error
	UpdateAddonRegistry(ctx context.Context, name string, req apis.UpdateAddonRegistryRequest) (*apis.AddonRegistry, error)
	ListAddonRegistries(ctx context.Context) ([]*apis.AddonRegistry, error)
	ListAddons(ctx context.Context, registry, query string) ([]*apis.DetailAddonResponse, error)
	StatusAddon(ctx context.Context, name string) (*apis.AddonStatusResponse, error)
	GetAddon(ctx context.Context, name string, registry string, version string) (*apis.DetailAddonResponse, error)
	EnableAddon(ctx context.Context, name string, args apis.EnableAddonRequest) error
	DisableAddon(ctx context.Context, name string, force bool) error
	ListEnabledAddon(ctx context.Context) ([]*apis.AddonBaseStatus, error)
	UpdateAddon(ctx context.Context, name string, args apis.EnableAddonRequest) error
}

AddonService handle CRUD and installation of addons

func NewAddonService

func NewAddonService(cacheTime time.Duration) AddonService

NewAddonService returns an addon service

type ApplicationDeployTarget

type ApplicationDeployTarget struct {
	Namespace string   `json:"namespace"`
	Clusters  []string `json:"clusters"`
}

ApplicationDeployTarget is the struct of application deploy target

type ApplicationService

type ApplicationService interface {
	ListApplications(ctx context.Context, listOptions apisv1.ListApplicationOptions) ([]*apisv1.ApplicationBase, error)
	GetApplication(ctx context.Context, appName string) (*model.Application, error)
	GetApplicationStatus(ctx context.Context, app *model.Application, envName string) (*common.AppStatus, error)
	DetailApplication(ctx context.Context, app *model.Application) (*apisv1.DetailApplicationResponse, error)
	PublishApplicationTemplate(ctx context.Context, app *model.Application) (*apisv1.ApplicationTemplateBase, error)
	CreateApplication(context.Context, apisv1.CreateApplicationRequest) (*apisv1.ApplicationBase, error)
	UpdateApplication(context.Context, *model.Application, apisv1.UpdateApplicationRequest) (*apisv1.ApplicationBase, error)
	DeleteApplication(ctx context.Context, app *model.Application) error
	Deploy(ctx context.Context, app *model.Application, req apisv1.ApplicationDeployRequest) (*apisv1.ApplicationDeployResponse, error)
	GetApplicationComponent(ctx context.Context, app *model.Application, componentName string) (*model.ApplicationComponent, error)
	ListComponents(ctx context.Context, app *model.Application, op apisv1.ListApplicationComponentOptions) ([]*apisv1.ComponentBase, error)
	CreateComponent(ctx context.Context, app *model.Application, com apisv1.CreateComponentRequest) (*apisv1.ComponentBase, error)
	DetailComponent(ctx context.Context, app *model.Application, componentName string) (*apisv1.DetailComponentResponse, error)
	DeleteComponent(ctx context.Context, app *model.Application, component *model.ApplicationComponent) error
	UpdateComponent(ctx context.Context, app *model.Application, component *model.ApplicationComponent, req apisv1.UpdateApplicationComponentRequest) (*apisv1.ComponentBase, error)
	ListPolicies(ctx context.Context, app *model.Application) ([]*apisv1.PolicyBase, error)
	CreatePolicy(ctx context.Context, app *model.Application, policy apisv1.CreatePolicyRequest) (*apisv1.PolicyBase, error)
	DetailPolicy(ctx context.Context, app *model.Application, policyName string) (*apisv1.DetailPolicyResponse, error)
	DeletePolicy(ctx context.Context, app *model.Application, policyName string) error
	UpdatePolicy(ctx context.Context, app *model.Application, policyName string, policy apisv1.UpdatePolicyRequest) (*apisv1.DetailPolicyResponse, error)
	CreateApplicationTrait(ctx context.Context, app *model.Application, component *model.ApplicationComponent, req apisv1.CreateApplicationTraitRequest) (*apisv1.ApplicationTrait, error)
	DeleteApplicationTrait(ctx context.Context, app *model.Application, component *model.ApplicationComponent, traitType string) error
	UpdateApplicationTrait(ctx context.Context, app *model.Application, component *model.ApplicationComponent, traitType string, req apisv1.UpdateApplicationTraitRequest) (*apisv1.ApplicationTrait, error)
	ListRevisions(ctx context.Context, appName, envName, status string, page, pageSize int) (*apisv1.ListRevisionsResponse, error)
	DetailRevision(ctx context.Context, appName, revisionName string) (*apisv1.DetailRevisionResponse, error)
	Statistics(ctx context.Context, app *model.Application) (*apisv1.ApplicationStatisticsResponse, error)
	ListRecords(ctx context.Context, appName string) (*apisv1.ListWorkflowRecordsResponse, error)
	CompareAppWithLatestRevision(ctx context.Context, app *model.Application, compareReq apisv1.AppCompareReq) (*apisv1.AppCompareResponse, error)
	ResetAppToLatestRevision(ctx context.Context, appName string) (*apisv1.AppResetResponse, error)
	DryRunAppOrRevision(ctx context.Context, app *model.Application, dryRunReq apisv1.AppDryRunReq) (*apisv1.AppDryRunResponse, error)
	CreateApplicationTrigger(ctx context.Context, app *model.Application, req apisv1.CreateApplicationTriggerRequest) (*apisv1.ApplicationTriggerBase, error)
	ListApplicationTriggers(ctx context.Context, app *model.Application) ([]*apisv1.ApplicationTriggerBase, error)
	DeleteApplicationTrigger(ctx context.Context, app *model.Application, triggerName string) error
}

ApplicationService application service

func NewApplicationService

func NewApplicationService() ApplicationService

NewApplicationService new application service

type AuthenticationService

type AuthenticationService interface {
	Login(ctx context.Context, loginReq apisv1.LoginRequest) (*apisv1.LoginResponse, error)
	RefreshToken(ctx context.Context, refreshToken string) (*apisv1.RefreshTokenResponse, error)
	GetDexConfig(ctx context.Context) (*apisv1.DexConfigResponse, error)
	GetLoginType(ctx context.Context) (*apisv1.GetLoginTypeResponse, error)
}

AuthenticationService is the service of authentication

func NewAuthenticationService

func NewAuthenticationService() AuthenticationService

NewAuthenticationService new authentication service

type ClusterService

ClusterService cluster manage

func NewClusterService

func NewClusterService() ClusterService

NewClusterService new cluster service

type ConfigService

type ConfigService interface {
	ListConfigTypes(ctx context.Context, query string) ([]*apis.ConfigType, error)
	GetConfigType(ctx context.Context, configType string) (*apis.ConfigType, error)
	CreateConfig(ctx context.Context, req apis.CreateConfigRequest) error
	GetConfigs(ctx context.Context, configType string) ([]*apis.Config, error)
	GetConfig(ctx context.Context, configType, name string) (*apis.Config, error)
	DeleteConfig(ctx context.Context, configType, name string) error
}

ConfigService handle CRUD of configs

func NewConfigService

func NewConfigService() ConfigService

NewConfigService returns a config use case

type DataInit

type DataInit interface {
	Init(ctx context.Context) error
}

DataInit the service set that needs init data

type DefinitionQueryOption

type DefinitionQueryOption struct {
	Type             string `json:"type"`
	AppliedWorkloads string `json:"appliedWorkloads"`
	QueryAll         bool   `json:"queryAll"`
}

DefinitionQueryOption define a set of query options

func (DefinitionQueryOption) String

func (d DefinitionQueryOption) String() string

String return cache key string

type DefinitionService

type DefinitionService interface {
	// ListDefinitions list definition base info
	ListDefinitions(ctx context.Context, ops DefinitionQueryOption) ([]*apisv1.DefinitionBase, error)
	// DetailDefinition get definition detail
	DetailDefinition(ctx context.Context, name, defType string) (*apisv1.DetailDefinitionResponse, error)
	// AddDefinitionUISchema add or update custom definition ui schema
	AddDefinitionUISchema(ctx context.Context, name, defType string, schema []*utils.UIParameter) ([]*utils.UIParameter, error)
	// UpdateDefinitionStatus update the status of definition
	UpdateDefinitionStatus(ctx context.Context, name string, status apisv1.UpdateDefinitionStatusRequest) (*apisv1.DetailDefinitionResponse, error)
}

DefinitionService definition service, Implement the management of ComponentDefinition、TraitDefinition and WorkflowStepDefinition.

func NewDefinitionService

func NewDefinitionService() DefinitionService

NewDefinitionService new definition service

type EnvBindingService

type EnvBindingService interface {
	GetEnvBindings(ctx context.Context, app *model.Application) ([]*apisv1.EnvBindingBase, error)
	GetEnvBinding(ctx context.Context, app *model.Application, envName string) (*model.EnvBinding, error)
	CreateEnvBinding(ctx context.Context, app *model.Application, env apisv1.CreateApplicationEnvbindingRequest) (*apisv1.EnvBinding, error)
	BatchCreateEnvBinding(ctx context.Context, app *model.Application, env apisv1.EnvBindingList) error
	UpdateEnvBinding(ctx context.Context, app *model.Application, envName string, diff apisv1.PutApplicationEnvBindingRequest) (*apisv1.DetailEnvBindingResponse, error)
	DeleteEnvBinding(ctx context.Context, app *model.Application, envName string) error
	BatchDeleteEnvBinding(ctx context.Context, app *model.Application) error
	DetailEnvBinding(ctx context.Context, app *model.Application, envBinding *model.EnvBinding) (*apisv1.DetailEnvBindingResponse, error)
	ApplicationEnvRecycle(ctx context.Context, appModel *model.Application, envBinding *model.EnvBinding) error
}

EnvBindingService envbinding service

func NewEnvBindingService

func NewEnvBindingService() EnvBindingService

NewEnvBindingService new envBinding service

type EnvService

type EnvService interface {
	GetEnv(ctx context.Context, envName string) (*model.Env, error)
	ListEnvs(ctx context.Context, page, pageSize int, listOption apisv1.ListEnvOptions) (*apisv1.ListEnvResponse, error)
	ListEnvCount(ctx context.Context, listOption apisv1.ListEnvOptions) (int64, error)
	DeleteEnv(ctx context.Context, envName string) error
	CreateEnv(ctx context.Context, req apisv1.CreateEnvRequest) (*apisv1.Env, error)
	UpdateEnv(ctx context.Context, envName string, req apisv1.UpdateEnvRequest) (*apisv1.Env, error)
}

EnvService defines the API of Env.

func NewEnvService

func NewEnvService() EnvService

NewEnvService new env service

type HelmService

type HelmService interface {
	ListChartNames(ctx context.Context, url string, secretName string, skipCache bool) ([]string, error)
	ListChartVersions(ctx context.Context, url string, chartName string, secretName string, skipCache bool) (repo.ChartVersions, error)
	GetChartValues(ctx context.Context, url string, chartName string, version string, secretName string, skipCache bool) (map[string]interface{}, error)
	ListChartRepo(ctx context.Context, projectName string) (*v1.ChartRepoResponseList, error)
}

HelmService responsible handle helm related interface

func NewHelmService

func NewHelmService() HelmService

NewHelmService return a helmHandler

type ImageService added in v1.4.3

type ImageService interface {
	ListImageRepos(ctx context.Context, project string) ([]v1.ImageRegistry, error)
	GetImageInfo(ctx context.Context, project, secretName, imageName string) v1.ImageInfo
}

ImageService the image service provide some handler functions about the docker image

func NewImageService added in v1.4.3

func NewImageService() ImageService

NewImageService create a image service instance

type OAMApplicationService

type OAMApplicationService interface {
	CreateOrUpdateOAMApplication(context.Context, apisv1.ApplicationRequest, string, string) error
	GetOAMApplication(context.Context, string, string) (*apisv1.ApplicationResponse, error)
	DeleteOAMApplication(context.Context, string, string) error
}

OAMApplicationService oam_application service

func NewOAMApplicationService

func NewOAMApplicationService() OAMApplicationService

NewOAMApplicationService new oam_application service

type PolicyType

type PolicyType string

PolicyType build-in policy type

type ProjectService

type ProjectService interface {
	GetProject(ctx context.Context, projectName string) (*model.Project, error)
	DetailProject(ctx context.Context, projectName string) (*apisv1.ProjectBase, error)
	ListProjects(ctx context.Context, page, pageSize int) (*apisv1.ListProjectResponse, error)
	ListUserProjects(ctx context.Context, userName string) ([]*apisv1.ProjectBase, error)
	CreateProject(ctx context.Context, req apisv1.CreateProjectRequest) (*apisv1.ProjectBase, error)
	DeleteProject(ctx context.Context, projectName string) error
	UpdateProject(ctx context.Context, projectName string, req apisv1.UpdateProjectRequest) (*apisv1.ProjectBase, error)
	ListProjectUser(ctx context.Context, projectName string, page, pageSize int) (*apisv1.ListProjectUsersResponse, error)
	AddProjectUser(ctx context.Context, projectName string, req apisv1.AddProjectUserRequest) (*apisv1.ProjectUserBase, error)
	DeleteProjectUser(ctx context.Context, projectName string, userName string) error
	UpdateProjectUser(ctx context.Context, projectName string, userName string, req apisv1.UpdateProjectUserRequest) (*apisv1.ProjectUserBase, error)
	Init(ctx context.Context) error
	GetConfigs(ctx context.Context, projectName, configType string) ([]*apisv1.Config, error)
}

ProjectService project manage service.

func NewProjectService

func NewProjectService() ProjectService

NewProjectService new project service

type RBACService

type RBACService interface {
	CheckPerm(resource string, actions ...string) func(req *restful.Request, res *restful.Response, chain *restful.FilterChain)
	GetUserPermissions(ctx context.Context, user *model.User, projectName string, withPlatform bool) ([]*model.Permission, error)
	CreateRole(ctx context.Context, projectName string, req apisv1.CreateRoleRequest) (*apisv1.RoleBase, error)
	DeleteRole(ctx context.Context, projectName, roleName string) error
	UpdateRole(ctx context.Context, projectName, roleName string, req apisv1.UpdateRoleRequest) (*apisv1.RoleBase, error)
	ListRole(ctx context.Context, projectName string, page, pageSize int) (*apisv1.ListRolesResponse, error)
	ListPermissionTemplate(ctx context.Context, projectName string) ([]apisv1.PermissionTemplateBase, error)
	ListPermissions(ctx context.Context, projectName string) ([]apisv1.PermissionBase, error)
	CreatePermission(ctx context.Context, projectName string, req apisv1.CreatePermissionRequest) (*apisv1.PermissionBase, error)
	DeletePermission(ctx context.Context, projectName, permName string) error
	InitDefaultRoleAndUsersForProject(ctx context.Context, project *model.Project) error
	Init(ctx context.Context) error
}

RBACService implement RBAC-related business logic.

func NewRBACService

func NewRBACService() RBACService

NewRBACService is the service service of RBAC

type RequestResourceAction

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

RequestResourceAction resource permission boundary

func (*RequestResourceAction) GetResource

func (r *RequestResourceAction) GetResource() *ResourceName

GetResource return the resource after be formated

func (*RequestResourceAction) Match

func (r *RequestResourceAction) Match(policies []*model.Permission) bool

Match determines whether the request resources and actions matches the user permission set.

func (*RequestResourceAction) SetActions

func (r *RequestResourceAction) SetActions(actions []string)

SetActions set request actions

func (*RequestResourceAction) SetResourceWithName

func (r *RequestResourceAction) SetResourceWithName(resource string, pathParameter func(name string) string)

SetResourceWithName format resource and assign a value from path parameter

type ResourceName

type ResourceName struct {
	Type  string
	Value string
	Next  *ResourceName
}

ResourceName it is similar to ARNs <type>:<value>/<type>:<value>

func ParseResourceName

func ParseResourceName(resource string) *ResourceName

ParseResourceName parse string to ResourceName

func (*ResourceName) Match

func (r *ResourceName) Match(target *ResourceName) bool

Match the resource types same with target and resource value include target resource means request resources

func (*ResourceName) String

func (r *ResourceName) String() string

type SystemInfoService

type SystemInfoService interface {
	Get(ctx context.Context) (*model.SystemInfo, error)
	GetSystemInfo(ctx context.Context) (*v1.SystemInfoResponse, error)
	UpdateSystemInfo(ctx context.Context, sysInfo v1.SystemInfoRequest) (*v1.SystemInfoResponse, error)
	Init(ctx context.Context) error
}

SystemInfoService is service for systemInfoCollection

func NewSystemInfoService

func NewSystemInfoService() SystemInfoService

NewSystemInfoService return a systemInfoCollectionService

type TargetService

type TargetService interface {
	GetTarget(ctx context.Context, TargetName string) (*model.Target, error)
	DetailTarget(ctx context.Context, Target *model.Target) (*apisv1.DetailTargetResponse, error)
	DeleteTarget(ctx context.Context, TargetName string) error
	CreateTarget(ctx context.Context, req apisv1.CreateTargetRequest) (*apisv1.DetailTargetResponse, error)
	UpdateTarget(ctx context.Context, Target *model.Target, req apisv1.UpdateTargetRequest) (*apisv1.DetailTargetResponse, error)
	ListTargets(ctx context.Context, page, pageSize int, projectName string) (*apisv1.ListTargetResponse, error)
	ListTargetCount(ctx context.Context, projectName string) (int64, error)
	Init(ctx context.Context) error
}

TargetService Target manage api

func NewTargetService

func NewTargetService() TargetService

NewTargetService new Target service

type UserService

type UserService interface {
	GetUser(ctx context.Context, username string) (*model.User, error)
	DetailUser(ctx context.Context, user *model.User) (*apisv1.DetailUserResponse, error)
	DeleteUser(ctx context.Context, username string) error
	CreateUser(ctx context.Context, req apisv1.CreateUserRequest) (*apisv1.UserBase, error)
	UpdateUser(ctx context.Context, user *model.User, req apisv1.UpdateUserRequest) (*apisv1.UserBase, error)
	ListUsers(ctx context.Context, page, pageSize int, listOptions apisv1.ListUserOptions) (*apisv1.ListUserResponse, error)
	DisableUser(ctx context.Context, user *model.User) error
	EnableUser(ctx context.Context, user *model.User) error
	DetailLoginUserInfo(ctx context.Context) (*apisv1.LoginUserInfoResponse, error)
	UpdateUserLoginTime(ctx context.Context, user *model.User) error
	Init(ctx context.Context) error
}

UserService User manage api

func NewUserService

func NewUserService() UserService

NewUserService new User service

type VelaQLService

type VelaQLService interface {
	QueryView(context.Context, string) (*apis.VelaQLViewResponse, error)
}

VelaQLService velaQL service

func NewVelaQLService

func NewVelaQLService() VelaQLService

NewVelaQLService new velaQL service

type WebhookService

type WebhookService interface {
	HandleApplicationWebhook(ctx context.Context, token string, req *restful.Request) (interface{}, error)
}

WebhookService webhook service

func NewWebhookService

func NewWebhookService() WebhookService

NewWebhookService new webhook service

type WorkflowService

type WorkflowService interface {
	ListApplicationWorkflow(ctx context.Context, app *model.Application) ([]*apisv1.WorkflowBase, error)
	GetWorkflow(ctx context.Context, app *model.Application, workflowName string) (*model.Workflow, error)
	DetailWorkflow(ctx context.Context, workflow *model.Workflow) (*apisv1.DetailWorkflowResponse, error)
	GetApplicationDefaultWorkflow(ctx context.Context, app *model.Application) (*model.Workflow, error)
	DeleteWorkflow(ctx context.Context, app *model.Application, workflowName string) error
	DeleteWorkflowByApp(ctx context.Context, app *model.Application) error
	CreateOrUpdateWorkflow(ctx context.Context, app *model.Application, req apisv1.CreateWorkflowRequest) (*apisv1.DetailWorkflowResponse, error)
	UpdateWorkflow(ctx context.Context, workflow *model.Workflow, req apisv1.UpdateWorkflowRequest) (*apisv1.DetailWorkflowResponse, error)
	CreateWorkflowRecord(ctx context.Context, appModel *model.Application, app *v1beta1.Application, workflow *model.Workflow) error
	ListWorkflowRecords(ctx context.Context, workflow *model.Workflow, page, pageSize int) (*apisv1.ListWorkflowRecordsResponse, error)
	DetailWorkflowRecord(ctx context.Context, workflow *model.Workflow, recordName string) (*apisv1.DetailWorkflowRecordResponse, error)
	SyncWorkflowRecord(ctx context.Context) error
	ResumeRecord(ctx context.Context, appModel *model.Application, workflow *model.Workflow, recordName string) error
	TerminateRecord(ctx context.Context, appModel *model.Application, workflow *model.Workflow, recordName string) error
	RollbackRecord(ctx context.Context, appModel *model.Application, workflow *model.Workflow, recordName, revisionName string) error
	CountWorkflow(ctx context.Context, app *model.Application) int64
}

WorkflowService workflow manage api

func NewWorkflowService

func NewWorkflowService() WorkflowService

NewWorkflowService new workflow service

Jump to

Keyboard shortcuts

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