Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions horizon/internal/predator/handler/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (
)

type Payload struct {
ModelName string `json:"model_name"`
ModelSource string `json:"model_source_path,omitempty"`
MetaData MetaData `json:"meta_data"`
ConfigMapping ConfigMapping `json:"config_mapping"`
DiscoveryConfigID uint `json:"discovery_config_id"`
ModelName string `json:"model_name"`
ModelSource string `json:"model_source_path,omitempty"`
MetaData MetaData `json:"meta_data"`
ConfigMapping ConfigMapping `json:"config_mapping"`
DiscoveryConfigID uint `json:"discovery_config_id"`
IsLoadTested bool `json:"is_load_tested,omitempty"`
LoadTestResultsLink string `json:"load_test_results_link,omitempty"`
}

type MetaData struct {
Expand Down Expand Up @@ -44,7 +46,7 @@ type IOField struct {
}

type ConfigMapping struct {
ServiceDeployableID uint `json:"service_deployable_id"`
ServiceDeployableID uint `json:"service_deployable_id"`
SourceModelName string `json:"source_model_name,omitempty"`
}

Expand Down
7 changes: 7 additions & 0 deletions horizon/internal/predator/handler/predator.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ func (p *Predator) HandleModelRequest(req ModelRequest, requestType string) (str
if err := json.Unmarshal(payloadBytes, &payloadObject); err != nil {
return constant.EmptyString, http.StatusInternalServerError, errors.New(errMsgProcessPayload)
}
// Validate load test fields for promote requests
if requestType == PromoteRequestType && payloadObject.IsLoadTested {
if payloadObject.LoadTestResultsLink == constant.EmptyString {
return constant.EmptyString, http.StatusBadRequest, errors.New("load test results link is required when load tested is true for the model requested")
}
}

derivedModelName, err := p.GetDerivedModelName(payloadObject, requestType)
if err != nil {
return constant.EmptyString, http.StatusInternalServerError, fmt.Errorf("failed to fetch derived model name: %w", err)
Expand Down