mirror of https://github.com/portainer/portainer
31 lines
949 B
Go
31 lines
949 B
Go
package registries
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/portainer/http/error"
|
|
"github.com/portainer/portainer/http/response"
|
|
"github.com/portainer/portainer/http/security"
|
|
)
|
|
|
|
// GET request on /api/registries
|
|
func (handler *Handler) registryList(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
registries, err := handler.RegistryService.Registries()
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve registries from the database", err}
|
|
}
|
|
|
|
securityContext, err := security.RetrieveRestrictedRequestContext(r)
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to retrieve info from request context", err}
|
|
}
|
|
|
|
filteredRegistries := security.FilterRegistries(registries, securityContext)
|
|
|
|
for idx := range filteredRegistries {
|
|
hideFields(&filteredRegistries[idx])
|
|
}
|
|
|
|
return response.JSON(w, filteredRegistries)
|
|
}
|