mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-05 05:54:53 +00:00
feat: improve workflow node configuration
This commit is contained in:
@@ -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{
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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"`
|
||||
|
Reference in New Issue
Block a user