mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
* feat(storidge): update storidge routes
* feat(storidge): add new fields on profile create/edit
* feat(storidge): add drives list and details view
* feat(storidge): add node details / cordon / uncordon / remove
* feat(storidge): add volume and snapshot details
* feat(storidge): add snapshot creation on volume details
* feat(storidge): add rescan drives button
* refactor(storidge): move add / remove / put in / put ouf maintenance buttons for cluster nodes
* style(storidge): change cluster / node icon color based on status
* feat(storidge): profiles can enable snapshots without interval + interval in minutes
* refactor(storidge): split cluster and node status badge filter
* fix(storidge): error on volume IOPS update
* fix(storidge): snapshot can now be created without comments
* feat(storidge): remove snapshots panels when volume snapshots are disabled
* fix(app): paginatedItemLimit now retrieved for datables extending GenericDatatableController
* fix(storidge): addDrive is called with the good parameters
* fix(storidge): update model and views for Storidge v2695
* refactor(storidge): webpack migration
* fix(storidge): display modifications + fix js errors
* feat(storidge): snapshots, profile and nodes evolution
* fix(storidge): values for InterfaceDriver on profile create/edit
* feat(storidge): v5 update without style (profile / statuses / volume)
* fix(storidge): description tables on the same view have now the same fixed offset
* fix(app): override rdash-ui select style
* Revert "fix(app): override rdash-ui select style"
This reverts commit e724833261
.
* feat(storidge): wip on update 6
* feat(storidge): update 6
* feat(storidge): update 6
* feat(storidge): update 6
* feat(storidge): update 7 - node details + cluster views
* fix(storidge): update 7 - profiles creation + volume details
* fix(storidge): update 7 - profile create/edit interface type
* feat(storidge): update 8 - add drive
* feat(storidge): update 8 - UI refactors + cluster availability
* fix(storidge): update 8 - revert cluster availability
* feat(storidge): update 8 - node availability on swarm overview
* feat(storidge): cluster condition badge
* fix(storidge): update 9 - move add storage button + api profile filesystem kv to obj
* feat(storidge): update 9 - disable add drive button when action is in progress
* fix(storidge): update 9 - add drive button will now change only for the concerned drive
* fix(storidge): update 10 - disable remove drive button when removal in progress
* fix(api): update Storidge proxy creation process
* refactor(api): update version number
* feat(extensions): fix an issue with Storidge API URL
* feat(storidge): force the use of a manager node
75 lines
2.4 KiB
Go
75 lines
2.4 KiB
Go
package endpoints
|
|
|
|
// TODO: legacy extension management
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/asaskevich/govalidator"
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
"github.com/portainer/portainer/api"
|
|
)
|
|
|
|
type endpointExtensionAddPayload struct {
|
|
Type int
|
|
URL string
|
|
}
|
|
|
|
func (payload *endpointExtensionAddPayload) Validate(r *http.Request) error {
|
|
if payload.Type != 1 {
|
|
return portainer.Error("Invalid type value. Value must be one of: 1 (Storidge)")
|
|
}
|
|
if payload.Type == 1 && govalidator.IsNull(payload.URL) {
|
|
return portainer.Error("Invalid extension URL")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// POST request on /api/endpoints/:id/extensions
|
|
func (handler *Handler) endpointExtensionAdd(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
endpointID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid endpoint identifier route variable", err}
|
|
}
|
|
|
|
endpoint, err := handler.EndpointService.Endpoint(portainer.EndpointID(endpointID))
|
|
if err == portainer.ErrObjectNotFound {
|
|
return &httperror.HandlerError{http.StatusNotFound, "Unable to find an endpoint with the specified identifier inside the database", err}
|
|
} else if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find an endpoint with the specified identifier inside the database", err}
|
|
}
|
|
|
|
var payload endpointExtensionAddPayload
|
|
err = request.DecodeAndValidateJSONPayload(r, &payload)
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid request payload", err}
|
|
}
|
|
|
|
extensionType := portainer.EndpointExtensionType(payload.Type)
|
|
|
|
var extension *portainer.EndpointExtension
|
|
for idx := range endpoint.Extensions {
|
|
if endpoint.Extensions[idx].Type == extensionType {
|
|
extension = &endpoint.Extensions[idx]
|
|
}
|
|
}
|
|
|
|
if extension != nil {
|
|
extension.URL = payload.URL
|
|
} else {
|
|
extension = &portainer.EndpointExtension{
|
|
Type: extensionType,
|
|
URL: payload.URL,
|
|
}
|
|
endpoint.Extensions = append(endpoint.Extensions, *extension)
|
|
}
|
|
|
|
err = handler.EndpointService.UpdateEndpoint(endpoint.ID, endpoint)
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to persist endpoint changes inside the database", err}
|
|
}
|
|
|
|
return response.JSON(w, extension)
|
|
}
|