feat: improve workflow node configuration

This commit is contained in:
Fu Diwei
2025-01-06 23:46:14 +08:00
parent 155371cdd0
commit 84c36a4eec
70 changed files with 1799 additions and 875 deletions

View File

@@ -47,9 +47,10 @@ func NewWithApplyNode(node *domain.WorkflowNode) (Applicant, error) {
}
accessRepo := repository.NewAccessRepository()
access, err := accessRepo.GetById(context.Background(), node.GetConfigString("providerAccessId"))
accessId := node.GetConfigString("providerAccessId")
access, err := accessRepo.GetById(context.Background(), accessId)
if err != nil {
return nil, fmt.Errorf("access record not found: %w", err)
return nil, fmt.Errorf("failed to get access #%s record: %w", accessId, err)
}
applyConfig := &applyConfig{

View File

@@ -19,17 +19,20 @@ func NewWithDeployNode(node *domain.WorkflowNode, certdata struct {
PrivateKey string
},
) (Deployer, error) {
if node.Type != domain.WorkflowNodeTypeApply {
if node.Type != domain.WorkflowNodeTypeDeploy {
return nil, fmt.Errorf("node type is not deploy")
}
accessRepo := repository.NewAccessRepository()
access, err := accessRepo.GetById(context.Background(), node.GetConfigString("providerAccessId"))
accessId := node.GetConfigString("providerAccessId")
access, err := accessRepo.GetById(context.Background(), accessId)
if err != nil {
return nil, fmt.Errorf("access record not found: %w", err)
return nil, fmt.Errorf("failed to get access #%s record: %w", accessId, err)
}
deployer, logger, err := createDeployer(domain.DeployProviderType(node.GetConfigString("provider")), access.Config, node.Config)
deployProvider := node.GetConfigString("provider")
deployConfig := node.GetConfigMap("providerConfig")
deployer, logger, err := createDeployer(domain.DeployProviderType(deployProvider), access.Config, deployConfig)
if err != nil {
return nil, err
}

View File

@@ -45,7 +45,7 @@ type WorkflowNode struct {
Type WorkflowNodeType `json:"type"`
Name string `json:"name"`
Config map[string]any `json:"data"`
Config map[string]any `json:"config"`
Inputs []WorkflowNodeIO `json:"inputs"`
Outputs []WorkflowNodeIO `json:"outputs"`
@@ -71,6 +71,16 @@ func (n *WorkflowNode) GetConfigInt64(key string) int64 {
return maps.GetValueAsInt64(n.Config, key)
}
func (n *WorkflowNode) GetConfigMap(key string) map[string]any {
if val, ok := n.Config[key]; ok {
if result, ok := val.(map[string]any); ok {
return result
}
}
return make(map[string]any)
}
type WorkflowNodeIO struct {
Label string `json:"label"`
Name string `json:"name"`