From bd26dfecb80eb6a790cb125ac8f4797b7e5b886b Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Mon, 9 Jun 2025 10:06:41 +0800 Subject: [PATCH] feat: improve workflow log --- internal/domain/workflow.go | 2 +- internal/workflow/node-processor/apply_node.go | 4 +++- internal/workflow/node-processor/deploy_node.go | 3 ++- internal/workflow/node-processor/monitor_node.go | 4 ++-- internal/workflow/node-processor/notify_node.go | 3 +-- internal/workflow/node-processor/upload_node.go | 4 ++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/domain/workflow.go b/internal/domain/workflow.go index a2e049e2..55fe56ed 100644 --- a/internal/domain/workflow.go +++ b/internal/domain/workflow.go @@ -128,7 +128,7 @@ func (n *WorkflowNode) GetConfigForApply() WorkflowNodeConfigForApply { CAProvider: maputil.GetString(n.Config, "caProvider"), CAProviderAccessId: maputil.GetString(n.Config, "caProviderAccessId"), CAProviderConfig: maputil.GetKVMapAny(n.Config, "caProviderConfig"), - KeyAlgorithm: maputil.GetString(n.Config, "keyAlgorithm"), + KeyAlgorithm: maputil.GetOrDefaultString(n.Config, "keyAlgorithm", string(CertificateKeyAlgorithmTypeRSA2048)), Nameservers: maputil.GetString(n.Config, "nameservers"), DnsPropagationWait: maputil.GetInt32(n.Config, "dnsPropagationWait"), DnsPropagationTimeout: maputil.GetInt32(n.Config, "dnsPropagationTimeout"), diff --git a/internal/workflow/node-processor/apply_node.go b/internal/workflow/node-processor/apply_node.go index 8616fbd9..852d7b9e 100644 --- a/internal/workflow/node-processor/apply_node.go +++ b/internal/workflow/node-processor/apply_node.go @@ -3,6 +3,7 @@ package nodeprocessor import ( "context" "fmt" + "log/slog" "strconv" "time" @@ -35,7 +36,8 @@ func NewApplyNode(node *domain.WorkflowNode) *applyNode { } func (n *applyNode) Process(ctx context.Context) error { - n.logger.Info("ready to obtain certificiate ...") + nodeCfg := n.node.GetConfigForApply() + n.logger.Info("ready to obtain certificiate ...", slog.Any("config", nodeCfg)) // 查询上次执行结果 lastOutput, err := n.outputRepo.GetByNodeId(ctx, n.node.Id) diff --git a/internal/workflow/node-processor/deploy_node.go b/internal/workflow/node-processor/deploy_node.go index f89f4a1f..279893e8 100644 --- a/internal/workflow/node-processor/deploy_node.go +++ b/internal/workflow/node-processor/deploy_node.go @@ -33,7 +33,8 @@ func NewDeployNode(node *domain.WorkflowNode) *deployNode { } func (n *deployNode) Process(ctx context.Context) error { - n.logger.Info("ready to deploy certificate ...") + nodeCfg := n.node.GetConfigForDeploy() + n.logger.Info("ready to deploy certificate ...", slog.Any("config", nodeCfg)) // 查询上次执行结果 lastOutput, err := n.outputRepo.GetByNodeId(ctx, n.node.Id) diff --git a/internal/workflow/node-processor/monitor_node.go b/internal/workflow/node-processor/monitor_node.go index 86714d57..d13e4247 100644 --- a/internal/workflow/node-processor/monitor_node.go +++ b/internal/workflow/node-processor/monitor_node.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "crypto/x509" "fmt" + "log/slog" "math" "net" "net/http" @@ -31,9 +32,8 @@ func NewMonitorNode(node *domain.WorkflowNode) *monitorNode { } func (n *monitorNode) Process(ctx context.Context) error { - n.logger.Info("ready to monitor certificate ...") - nodeCfg := n.node.GetConfigForMonitor() + n.logger.Info("ready to monitor certificate ...", slog.Any("config", nodeCfg)) targetAddr := net.JoinHostPort(nodeCfg.Host, fmt.Sprintf("%d", nodeCfg.Port)) if nodeCfg.Port == 0 { diff --git a/internal/workflow/node-processor/notify_node.go b/internal/workflow/node-processor/notify_node.go index dabfd034..9d259c0a 100644 --- a/internal/workflow/node-processor/notify_node.go +++ b/internal/workflow/node-processor/notify_node.go @@ -28,9 +28,8 @@ func NewNotifyNode(node *domain.WorkflowNode) *notifyNode { } func (n *notifyNode) Process(ctx context.Context) error { - n.logger.Info("ready to send notification ...") - nodeCfg := n.node.GetConfigForNotify() + n.logger.Info("ready to send notification ...", slog.Any("config", nodeCfg)) if nodeCfg.Provider == "" { // Deprecated: v0.4.x 将废弃 diff --git a/internal/workflow/node-processor/upload_node.go b/internal/workflow/node-processor/upload_node.go index 9431d31a..adbf46dd 100644 --- a/internal/workflow/node-processor/upload_node.go +++ b/internal/workflow/node-processor/upload_node.go @@ -3,6 +3,7 @@ package nodeprocessor import ( "context" "fmt" + "log/slog" "strconv" "strings" "time" @@ -32,9 +33,8 @@ func NewUploadNode(node *domain.WorkflowNode) *uploadNode { } func (n *uploadNode) Process(ctx context.Context) error { - n.logger.Info("ready to upload certiticate ...") - nodeCfg := n.node.GetConfigForUpload() + n.logger.Info("ready to upload certiticate ...", slog.Any("config", nodeCfg)) // 查询上次执行结果 lastOutput, err := n.outputRepo.GetByNodeId(ctx, n.node.Id)