refactor: simplify Node SSR parsing and validation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user