|
|
|
@ -23,7 +23,7 @@ func (payload *stackMigratePayload) Validate(r *http.Request) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// POST request on /api/stacks/:id/migrate
|
|
|
|
|
// POST request on /api/stacks/:id/migrate?endpointId=<endpointId>
|
|
|
|
|
func (handler *Handler) stackMigrate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
|
|
|
stackID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
|
|
|
if err != nil {
|
|
|
|
@ -59,6 +59,17 @@ func (handler *Handler) stackMigrate(w http.ResponseWriter, r *http.Request) *ht
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: this is a work-around for stacks created with Portainer version >= 1.17.1
|
|
|
|
|
// The EndpointID property is not available for these stacks, this API endpoint
|
|
|
|
|
// can use the optional EndpointID query parameter to associate a valid endpoint identifier to the stack.
|
|
|
|
|
endpointID, err := request.RetrieveNumericQueryParameter(r, "endpointId", true)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid query parameter: endpointId", err}
|
|
|
|
|
}
|
|
|
|
|
if endpointID != int(stack.EndpointID) {
|
|
|
|
|
stack.EndpointID = portainer.EndpointID(endpointID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
endpoint, err := handler.EndpointService.Endpoint(stack.EndpointID)
|
|
|
|
|
if err == portainer.ErrObjectNotFound {
|
|
|
|
|
return &httperror.HandlerError{http.StatusNotFound, "Unable to find the endpoint associated to the stack inside the database", err}
|
|
|
|
|