mirror of
https://github.com/lxc/incus.git
synced 2026-10-12 02:18:30 +00:00
shared/scriptlet: Don't panic on marshaling uuid.UUID and other non-addressable arrays
Signed-off-by: Max Asnaashari <[email protected]>
This commit is contained in:
@@ -103,7 +103,14 @@ func starlarkMarshal(input any, parent *starlark.Dict) (starlark.Value, error) {
|
||||
case reflect.Array, reflect.Slice:
|
||||
// We treat arrays and slices of bytes as Starlark bytes.
|
||||
if v.Type().Elem().Kind() == reflect.Uint8 {
|
||||
sv = starlark.Bytes(v.Bytes())
|
||||
if v.Type().Kind() == reflect.Slice {
|
||||
sv = starlark.Bytes(v.Bytes())
|
||||
} else {
|
||||
b := make([]byte, v.Len())
|
||||
reflect.Copy(reflect.ValueOf(b), v)
|
||||
sv = starlark.Bytes(b)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user