@@ -18,8 +18,6 @@ type ModelRegistryAndCredentialsSettingsEnvelope Envelope[models.ModelRegistryAn
1818type ModelRegistrySettingsPayloadEnvelope Envelope [models.ModelRegistrySettingsPayload , None ]
1919
2020func (app * App ) GetAllModelRegistriesSettingsHandler (w http.ResponseWriter , r * http.Request , _ httprouter.Params ) {
21- ctxLogger := helper .GetContextLoggerFromReq (r )
22- ctxLogger .Info ("This functionality is not implement yet. This is a STUB API to unblock frontend development" )
2321
2422 namespace , ok := r .Context ().Value (constants .NamespaceHeaderParameterKey ).(string )
2523 if ! ok || namespace == "" {
@@ -36,17 +34,17 @@ func (app *App) GetAllModelRegistriesSettingsHandler(w http.ResponseWriter, r *h
3634 Key : "ssl-secret-key" ,
3735 }
3836
39- registries := []models.ModelRegistryKind {createSampleModelRegistry ("model-registry" , namespace , & sslRootCertificateConfigMap , nil ),
37+ registries := []models.ModelRegistryKind {
38+ createSampleModelRegistry ("model-registry" , namespace , & sslRootCertificateConfigMap , nil ),
4039 createSampleModelRegistry ("model-registry-dora" , namespace , nil , & sslRootCertificateSecret ),
41- createSampleModelRegistry ("model-registry-bella" , namespace , nil , nil )}
40+ createSampleModelRegistry ("model-registry-bella" , namespace , nil , nil ),
41+ }
4242
4343 modelRegistryRes := ModelRegistrySettingsListEnvelope {
4444 Data : registries ,
4545 }
4646
47- err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil )
48-
49- if err != nil {
47+ if err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil ); err != nil {
5048 app .serverErrorResponse (w , r , err )
5149 }
5250
@@ -73,9 +71,7 @@ func (app *App) GetModelRegistrySettingsHandler(w http.ResponseWriter, r *http.R
7371 Data : modelRegistryWithCreds ,
7472 }
7573
76- err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil )
77-
78- if err != nil {
74+ if err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil ); err != nil {
7975 app .serverErrorResponse (w , r , err )
8076 }
8177}
@@ -94,31 +90,18 @@ func (app *App) CreateModelRegistrySettingsHandler(w http.ResponseWriter, r *htt
9490 app .serverErrorResponse (w , r , fmt .Errorf ("error decoding JSON:: %v" , err .Error ()))
9591 return
9692 }
97-
98- var modelRegistryName = envelope .Data .ModelRegistry .Metadata .Name
99-
100- if modelRegistryName == "" {
101- app .badRequestResponse (w , r , fmt .Errorf ("model registry name is required" ))
102- return
103- }
104-
105- ctxLogger .Info ("Creating model registry" , "name" , modelRegistryName )
106-
107- // For now, we're using the stub implementation, but we'd use envelope.Data.ModelRegistry
108- // and other fields from the payload in a real implementation
93+ modelRegistryName := envelope .Data .ModelRegistry .Metadata .Name
10994 registry := createSampleModelRegistry (modelRegistryName , namespace , nil , nil )
11095
11196 modelRegistryRes := ModelRegistrySettingsEnvelope {
11297 Data : registry ,
11398 }
11499
115100 w .Header ().Set ("Location" , r .URL .JoinPath (modelRegistryRes .Data .Metadata .Name ).String ())
116- writeErr := app .WriteJSON (w , http .StatusCreated , modelRegistryRes , nil )
117- if writeErr != nil {
101+ if err := app .WriteJSON (w , http .StatusCreated , modelRegistryRes , nil ); err != nil {
118102 app .serverErrorResponse (w , r , fmt .Errorf ("error writing JSON" ))
119103 return
120104 }
121-
122105}
123106
124107func (app * App ) UpdateModelRegistrySettingsHandler (w http.ResponseWriter , r * http.Request , ps httprouter.Params ) {
@@ -137,8 +120,7 @@ func (app *App) UpdateModelRegistrySettingsHandler(w http.ResponseWriter, r *htt
137120 Data : registry ,
138121 }
139122
140- err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil )
141- if err != nil {
123+ if err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil ); err != nil {
142124 app .serverErrorResponse (w , r , fmt .Errorf ("error writing JSON" ))
143125 return
144126 }
@@ -161,9 +143,7 @@ func (app *App) DeleteModelRegistrySettingsHandler(w http.ResponseWriter, r *htt
161143 Data : registry ,
162144 }
163145
164- err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil )
165-
166- if err != nil {
146+ if err := app .WriteJSON (w , http .StatusOK , modelRegistryRes , nil ); err != nil {
167147 app .serverErrorResponse (w , r , err )
168148 }
169149
0 commit comments