fix server creation run binding
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"browser.local/platform/domain"
|
||||
"browser.local/platform/validator"
|
||||
)
|
||||
|
||||
type ServerDeploymentRequest struct {
|
||||
@@ -78,7 +80,7 @@ type ServerLifecycleCreateRequest struct {
|
||||
ID string `json:"id"`
|
||||
PluginID string `json:"pluginId"`
|
||||
DeploymentTargetID string `json:"deploymentTargetId,omitempty"`
|
||||
RunEndpointID string `json:"runEndpointId"`
|
||||
RunEndpointID string `json:"runEndpointId,omitempty"`
|
||||
Name string `json:"name"`
|
||||
OwnerUserID string `json:"ownerUserId,omitempty"`
|
||||
IdempotencyKey string `json:"idempotencyKey"`
|
||||
@@ -87,6 +89,35 @@ type ServerLifecycleCreateRequest struct {
|
||||
Deployment ServerDeploymentRequest `json:"deployment,omitempty"`
|
||||
}
|
||||
|
||||
func (request ServerLifecycleCreateRequest) ValidateCreateOnly() error {
|
||||
var violations []string
|
||||
if strings.TrimSpace(request.DeploymentTargetID) != "" {
|
||||
violations = append(violations, "deploymentTargetId must not be provided during server creation")
|
||||
}
|
||||
if strings.TrimSpace(request.RunEndpointID) != "" {
|
||||
violations = append(violations, "runEndpointId must not be provided during server creation")
|
||||
}
|
||||
if strings.TrimSpace(request.ProfileKey) != "" {
|
||||
violations = append(violations, "profileKey must not be provided during server creation")
|
||||
}
|
||||
if len(request.Bindings) > 0 {
|
||||
violations = append(violations, "bindings must not be provided during server creation")
|
||||
}
|
||||
if strings.TrimSpace(request.Deployment.RunEndpointID) != "" {
|
||||
violations = append(violations, "deployment.runEndpointId must not be provided during server creation")
|
||||
}
|
||||
if strings.TrimSpace(request.Deployment.ProfileKey) != "" {
|
||||
violations = append(violations, "deployment.profileKey must not be provided during server creation")
|
||||
}
|
||||
if len(request.Deployment.RuntimeBindings) > 0 {
|
||||
violations = append(violations, "deployment.runtimeBindings must not be provided during server creation")
|
||||
}
|
||||
if len(violations) > 0 {
|
||||
return validator.ValidationError{Violations: violations}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ServerLifecycleCommandRequest struct {
|
||||
ExpectedConfigVersion int `json:"expectedConfigVersion"`
|
||||
IdempotencyKey string `json:"idempotencyKey"`
|
||||
@@ -103,13 +134,13 @@ func (request ServerLifecycleCreateRequest) ToDomain() domain.ServerLifecycleCre
|
||||
return domain.ServerLifecycleCreate{
|
||||
ID: request.ID,
|
||||
PluginID: request.PluginID,
|
||||
DeploymentTargetID: request.DeploymentTargetID,
|
||||
RunEndpointID: request.RunEndpointID,
|
||||
DeploymentTargetID: "",
|
||||
RunEndpointID: "",
|
||||
Name: request.Name,
|
||||
OwnerUserID: request.OwnerUserID,
|
||||
IdempotencyKey: request.IdempotencyKey,
|
||||
ProfileKey: request.ProfileKey,
|
||||
Bindings: domain.CopyStringMap(request.Bindings),
|
||||
ProfileKey: "",
|
||||
Bindings: nil,
|
||||
Deployment: request.Deployment.deploymentDefinition(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user