usecase

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: Apache-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvBindingPolicy Multiple environment distribution policy
	EnvBindingPolicy PolicyType = "env-binding"

	// EnvBindingPolicyDefaultName default policy name
	EnvBindingPolicyDefaultName string = "env-bindings"
)
View Source
const (
	// Deploy2Env deploy app to target cluster, suitable for common applications
	Deploy2Env string = "deploy2env"
	// DeployCloudResource deploy app to local and copy secret to target cluster, suitable for cloud application.
	DeployCloudResource string = "deploy-cloud-resource"
	// TerraformWorkfloadType cloud application
	TerraformWorkfloadType string = "configurations.terraform.core.oam.dev"
	// TerraformWorkfloadKind terraform workload kind
	TerraformWorkfloadKind string = "Configuration"
)
View Source
const (

	// DefaultInitName is default object name for initialization
	DefaultInitName = "default"
	// DefaultInitNamespace is default namespace name for initialization
	DefaultInitNamespace = "default"

	// DefaultTargetDescription describes default target created
	DefaultTargetDescription = "Default target is created by velaux system automatically."
	// DefaultEnvDescription describes default env created
	DefaultEnvDescription = "Default environment is created by velaux system automatically."
	// DefaultProjectDescription describes the default project created
	DefaultProjectDescription = "Default project is created by velaux system automatically."
)

Variables

View Source
var WebhookHandlers []string

WebhookHandlers is the webhook handlers

Functions

func AddonImpl2AddonRes added in v1.2.0

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

AddonImpl2AddonRes convert pkgaddon.UIData to the type apiserver need

func CheckAppEnvBindingsContainTarget added in v1.2.0

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

CheckAppEnvBindingsContainTarget check envbinding contain target

func ConvertAddonRegistryModel2AddonRegistryMeta added in v1.2.0

func ConvertAddonRegistryModel2AddonRegistryMeta(r pkgaddon.Registry) apis.AddonRegistry

ConvertAddonRegistryModel2AddonRegistryMeta will convert from model to AddonRegistry

func GenEnvWorkflowSteps added in v1.2.0

func GenEnvWorkflowSteps(ctx context.Context, kubeClient client.Client, ds datastore.DataStore, env *model.Env, app *model.Application) []apisv1.WorkflowStep

GenEnvWorkflowSteps will generate workflow steps for an env and application

func GetComponentDefinition added in v1.2.0

func GetComponentDefinition(ctx context.Context, kubeClient client.Client, name string) (*v1beta1.ComponentDefinition, error)

GetComponentDefinition will get componentDefinition by kube client

func GetSuitableDeployWay added in v1.2.0

func GetSuitableDeployWay(ctx context.Context, kubeClient client.Client, ds datastore.DataStore, app *model.Application) string

GetSuitableDeployWay will get a workflow deploy strategy for workflow step

func UpdateEnvWorkflow added in v1.2.0

func UpdateEnvWorkflow(ctx context.Context, kubeClient client.Client, ds datastore.DataStore, app *model.Application, env *model.Env) error

UpdateEnvWorkflow will update env workflow internally

Types

type AddonHandler added in v1.2.0

type AddonHandler 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) (*apis.DetailAddonResponse, error)
	EnableAddon(ctx context.Context, name string, args apis.EnableAddonRequest) error
	DisableAddon(ctx context.Context, name string) error
	ListEnabledAddon(ctx context.Context) ([]*apis.AddonBaseStatus, error)
	UpdateAddon(ctx context.Context, name string, args apis.EnableAddonRequest) error
}

AddonHandler handle CRUD and installation of addons

func NewAddonUsecase added in v1.2.0

func NewAddonUsecase(cacheTime time.Duration) AddonHandler

NewAddonUsecase returns an addon usecase

type ApplicationUsecase added in v1.2.0

type ApplicationUsecase 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)
	AddComponent(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, componentName string) 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)
	AddPolicy(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)
	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
}

ApplicationUsecase application usecase

func NewApplicationUsecase added in v1.2.0

func NewApplicationUsecase(ds datastore.DataStore,
	workflowUsecase WorkflowUsecase,
	envBindingUsecase EnvBindingUsecase,
	envUsecase EnvUsecase,
	targetUsecase TargetUsecase,
	definitionUsecase DefinitionUsecase,
	projectUsecase ProjectUsecase,
) ApplicationUsecase

NewApplicationUsecase new application usecase

type ClusterUsecase

ClusterUsecase cluster manage

func NewClusterUsecase

func NewClusterUsecase(ds datastore.DataStore) ClusterUsecase

NewClusterUsecase new cluster usecase

type DefinitionUsecase added in v1.2.0

type DefinitionUsecase interface {
	// ListDefinitions list definition base info
	ListDefinitions(ctx context.Context, envName, defType, appliedWorkloads string) ([]*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, configRaw string) ([]*utils.UIParameter, error)
}

DefinitionUsecase definition usecase, Implement the management of ComponentDefinition、TraitDefinition and WorkflowStepDefinition.

func NewDefinitionUsecase added in v1.2.0

func NewDefinitionUsecase() DefinitionUsecase

NewDefinitionUsecase new definition usecase

type EnvBindingUsecase added in v1.2.0

type EnvBindingUsecase 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
}

EnvBindingUsecase envbinding usecase

func NewEnvBindingUsecase added in v1.2.0

func NewEnvBindingUsecase(ds datastore.DataStore, workflowUsecase WorkflowUsecase, definitionUsecase DefinitionUsecase, envUsecase EnvUsecase) EnvBindingUsecase

NewEnvBindingUsecase new envBinding usecase

type EnvUsecase added in v1.2.0

type EnvUsecase interface {
	GetEnv(ctx context.Context, envName string) (*model.Env, error)
	ListEnvs(ctx context.Context, page, pageSize int, listOption apisv1.ListEnvOptions) ([]*apisv1.Env, 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)
}

EnvUsecase defines the API of Env.

func NewEnvUsecase added in v1.2.0

func NewEnvUsecase(ds datastore.DataStore) EnvUsecase

NewEnvUsecase new env usecase

type OAMApplicationUsecase added in v1.2.0

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

OAMApplicationUsecase oam_application usecase

func NewOAMApplicationUsecase added in v1.2.0

func NewOAMApplicationUsecase() OAMApplicationUsecase

NewOAMApplicationUsecase new oam_application usecase

type PolicyType added in v1.2.0

type PolicyType string

PolicyType build-in policy type

type ProjectUsecase added in v1.2.0

type ProjectUsecase interface {
	GetProject(ctx context.Context, projectName string) (*model.Project, error)
	ListProjects(ctx context.Context) ([]*apisv1.ProjectBase, error)
	CreateProject(ctx context.Context, req apisv1.CreateProjectRequest) (*apisv1.ProjectBase, error)
}

ProjectUsecase project manage usecase.

func NewProjectUsecase added in v1.2.0

func NewProjectUsecase(ds datastore.DataStore) ProjectUsecase

NewProjectUsecase new project usecase

type SystemInfoUsecase added in v1.2.0

type SystemInfoUsecase interface {
	GetSystemInfo(ctx context.Context) (*v1.SystemInfoResponse, error)
	DeleteSystemInfo(ctx context.Context) error
	UpdateSystemInfo(ctx context.Context, sysInfo v1.SystemInfoRequest) (*v1.SystemInfoResponse, error)
}

SystemInfoUsecase is usecase for systemInfoCollection

func NewSystemInfoUsecase added in v1.2.0

func NewSystemInfoUsecase(ds datastore.DataStore) SystemInfoUsecase

NewSystemInfoUsecase return a systemInfoCollectionUsecase

type TargetUsecase added in v1.2.0

type TargetUsecase 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) (*apisv1.ListTargetResponse, error)
}

TargetUsecase Target manage api

func NewTargetUsecase added in v1.2.0

func NewTargetUsecase(ds datastore.DataStore) TargetUsecase

NewTargetUsecase new Target usecase

type VelaQLUsecase added in v1.2.0

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

VelaQLUsecase velaQL usecase

func NewVelaQLUsecase added in v1.2.0

func NewVelaQLUsecase() VelaQLUsecase

NewVelaQLUsecase new velaQL usecase

type WebhookUsecase added in v1.2.0

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

WebhookUsecase webhook usecase

func NewWebhookUsecase added in v1.2.0

func NewWebhookUsecase(ds datastore.DataStore,
	applicationUsecase ApplicationUsecase,
) WebhookUsecase

NewWebhookUsecase new webhook usecase

type WorkflowUsecase added in v1.2.0

type WorkflowUsecase 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
}

WorkflowUsecase workflow manage api

func NewWorkflowUsecase added in v1.2.0

func NewWorkflowUsecase(ds datastore.DataStore, envUsecase EnvUsecase) WorkflowUsecase

NewWorkflowUsecase new workflow usecase

Jump to

Keyboard shortcuts

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