refactor: simplify Node SSR parsing and validation

This commit is contained in:
2026-08-22 15:53:31 +08:00
parent 56e104ccf0
commit d2070c9d5b
2 changed files with 47 additions and 27 deletions
@@ -88,9 +88,17 @@ func validateNodeSsrContainerDeployment(deployment NodeSsrContainerDeployment) e
if deployment.ActivePort != 18910 && deployment.ActivePort != 28910 {
return fmt.Errorf("Node SSR container deployment port must be 18910 or 28910: %d", deployment.ActivePort)
}
for name, value := range map[string]string{"container name": deployment.ContainerName, "image digest": deployment.ImageDigest, "container ID": deployment.ContainerID} {
if value == "" || strings.TrimSpace(value) != value {
return fmt.Errorf("exact Node SSR container %s is required", name)
fields := []struct {
name string
value string
}{
{name: "container name", value: deployment.ContainerName},
{name: "image digest", value: deployment.ImageDigest},
{name: "container ID", value: deployment.ContainerID},
}
for _, field := range fields {
if field.value == "" || strings.TrimSpace(field.value) != field.value {
return fmt.Errorf("exact Node SSR container %s is required", field.name)
}
}
return nil