Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] vim25 JSON does not support dateTime and binary in OptionValue #3127

Closed
karaatanassov opened this issue May 16, 2023 · 0 comments · Fixed by #3128
Closed

[BUG] vim25 JSON does not support dateTime and binary in OptionValue #3127

karaatanassov opened this issue May 16, 2023 · 0 comments · Fixed by #3128

Comments

@karaatanassov
Copy link
Contributor

Describe the bug
The json serialization code for vim25 does not support binary and dateTime where "any" is used. For example this is the OptionValue in VMs

Expected behavior
dateTime nad binary should be supported like following in JSON

{
    "_typeName": "OptionValue",
    "key": "option1",
    "value": {
        "_typeName": "dateTime",
        "_value": "2022-12-12T11:48:35.473645Z"
    }
}
{
    "_typeName": "OptionValue",
    "key": "option1",
    "value": {
        "_typeName": "binary",
        "_value": "SGVsbG8="
    }
}

Affected version
v.0.30.4

Screenshots/Debug Output
These types are missing in code https://github.com/vmware/govmomi/blob/main/vim25/types/json_encoding.go#L32

karaatanassov added a commit to karaatanassov/govmomi that referenced this issue May 16, 2023
This change adds support for `binary` and `dateTime` in JSON.

For `binary` golang `[]byte` JSON serialization matches the vCenter
format. Thus adding the name ot the maps was enough.

For `dateTime` the format of `time.Time` `Marshaler` and `Unmarshaler`
matches vCenter format. The discriminator code required support for
custom marshaling logic. In addition the name had to be mapped.

Closes: vmware#3127
karaatanassov added a commit to karaatanassov/govmomi that referenced this issue May 24, 2023
This change adds support for `binary` and `dateTime` in JSON.

For `binary` golang `[]byte` JSON serialization matches the vCenter
format. Thus adding the name ot the maps was enough.

For `dateTime` the format of `time.Time` `Marshaler` and `Unmarshaler`
matches vCenter format. The discriminator code required support for
custom marshaling logic. In addition the name had to be mapped.

To support `nil` value fields move `assertEqual` to use
`reflect.DeepEqual`.

Closes: vmware#3127
karaatanassov added a commit to karaatanassov/govmomi that referenced this issue May 26, 2023
This change adds support for `binary` and `dateTime` in JSON.

For `binary` golang `[]byte` JSON serialization matches the vCenter
format. Thus adding the name ot the maps was enough.

For `dateTime` the format of `time.Time` `Marshaler` and `Unmarshaler`
matches vCenter format. The discriminator code required support for
custom marshaling logic. In addition the name had to be mapped.

To support `nil` value fields move `assertEqual` to use
`reflect.DeepEqual`.

Closes: vmware#3127
priyanka19-98 pushed a commit to priyanka19-98/govmomi that referenced this issue Jan 17, 2024
This change adds support for `binary` and `dateTime` in JSON.

For `binary` golang `[]byte` JSON serialization matches the vCenter
format. Thus adding the name ot the maps was enough.

For `dateTime` the format of `time.Time` `Marshaler` and `Unmarshaler`
matches vCenter format. The discriminator code required support for
custom marshaling logic. In addition the name had to be mapped.

To support `nil` value fields move `assertEqual` to use
`reflect.DeepEqual`.

Closes: vmware#3127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant