@@ -62,3 +62,27 @@ func GetLatestVersions(params operations.GetComponentsByLatestReleaseParams, db
62
62
ret := operations.GetComponentsByLatestReleaseOKBodyBody {Data : componentVersions }
63
63
return operations .NewGetComponentsByLatestReleaseOK ().WithPayload (ret )
64
64
}
65
+
66
+ // GetLatestVersionsForV2 is the handler for the POST /v2/versions/latest endpoint
67
+ func GetLatestVersionsForV2 (params operations.GetComponentsByLatestReleaseForV2Params , db * gorm.DB ) middleware.Responder {
68
+ reqStruct := params .Body
69
+ componentAndTrainSlice := make ([]data.ComponentAndTrain , len (reqStruct .Data ))
70
+ for i , d := range reqStruct .Data {
71
+ //this is just to make the existing workflow manager clients out in the beta world to work.
72
+ if d .Version .Train == "" {
73
+ d .Version .Train = "beta"
74
+ }
75
+ componentAndTrainSlice [i ] = data.ComponentAndTrain {
76
+ ComponentName : d .Component .Name ,
77
+ Train : d .Version .Train ,
78
+ }
79
+ }
80
+
81
+ componentVersions , err := data .GetLatestVersions (db , componentAndTrainSlice )
82
+ if err != nil {
83
+ log .Printf ("data.GetLatestVersions error (%s)" , err )
84
+ return operations .NewGetComponentsByLatestReleaseForV2Default (http .StatusInternalServerError ).WithPayload (& models.Error {Code : http .StatusInternalServerError , Message : "database error" })
85
+ }
86
+ ret := operations.GetComponentsByLatestReleaseForV2OKBodyBody {Data : componentVersions }
87
+ return operations .NewGetComponentsByLatestReleaseForV2OK ().WithPayload (ret )
88
+ }
0 commit comments