2018-06-11 13:13:19 +00:00
|
|
|
package registries
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2018-09-10 10:01:38 +00:00
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
|
|
"github.com/portainer/libhttp/response"
|
2019-03-21 01:20:14 +00:00
|
|
|
"github.com/portainer/portainer/api/http/security"
|
2018-06-11 13:13:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
2018-07-31 09:50:04 +00:00
|
|
|
for idx := range filteredRegistries {
|
|
|
|
hideFields(&filteredRegistries[idx])
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|
2018-07-31 09:50:04 +00:00
|
|
|
|
|
|
|
return response.JSON(w, filteredRegistries)
|
2018-06-11 13:13:19 +00:00
|
|
|
}
|