mirror of
https://github.com/containers/podman.git
synced 2025-06-11 10:25:41 +08:00
Merge pull request #5262 from schubter/signal-decode
APIv2: Fixed syscall.Signal not convertable by decoder
This commit is contained in:
@ -3,8 +3,10 @@ package handlers
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/containers/libpod/pkg/util"
|
||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -17,6 +19,9 @@ func NewAPIDecoder() *schema.Decoder {
|
|||||||
d.IgnoreUnknownKeys(true)
|
d.IgnoreUnknownKeys(true)
|
||||||
d.RegisterConverter(map[string][]string{}, convertUrlValuesString)
|
d.RegisterConverter(map[string][]string{}, convertUrlValuesString)
|
||||||
d.RegisterConverter(time.Time{}, convertTimeString)
|
d.RegisterConverter(time.Time{}, convertTimeString)
|
||||||
|
|
||||||
|
var Signal syscall.Signal
|
||||||
|
d.RegisterConverter(Signal, convertSignal)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,3 +94,11 @@ func convertTimeString(query string) reflect.Value {
|
|||||||
func ParseDateTime(query string) time.Time {
|
func ParseDateTime(query string) time.Time {
|
||||||
return convertTimeString(query).Interface().(time.Time)
|
return convertTimeString(query).Interface().(time.Time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convertSignal(query string) reflect.Value {
|
||||||
|
signal, err := util.ParseSignal(query)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Infof("convertSignal: Failed to parse %s: %s", query, err.Error())
|
||||||
|
}
|
||||||
|
return reflect.ValueOf(signal)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user