fix: registry test endpoint accepts empty body for connectivity check
This commit is contained in:
@@ -180,14 +180,12 @@ func (s *Server) testRegistry(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Body is optional — if no image provided, just test connectivity.
|
||||
var req testRegistryRequest
|
||||
if !decodeJSON(w, r, &req) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.Image == "" {
|
||||
respondError(w, http.StatusBadRequest, "image is required for testing")
|
||||
return
|
||||
if r.Body != nil && r.ContentLength > 0 {
|
||||
if !decodeJSON(w, r, &req) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Decrypt the token.
|
||||
@@ -207,6 +205,14 @@ func (s *Server) testRegistry(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// If no image provided, just verify we can create a client (basic connectivity test).
|
||||
if req.Image == "" {
|
||||
respondJSON(w, http.StatusOK, map[string]any{
|
||||
"message": "registry client created successfully",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
tags, err := client.ListTags(r.Context(), req.Image)
|
||||
if err != nil {
|
||||
respondError(w, http.StatusBadGateway, "registry test failed: "+err.Error())
|
||||
|
||||
Reference in New Issue
Block a user