Created
October 2, 2020 02:45
-
-
Save codegold79/a3ec782b0644185fc096349aa6e6c900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func eventVmMOR(req []byte) (*types.ManagedObjectReference, error) { | |
| var ce cloudEvent | |
| var mor types.ManagedObjectReference | |
| err := json.Unmarshal(req, &ce) | |
| if err != nil { | |
| return nil, fmt.Errorf("parse request: %w", err) | |
| } | |
| if ce.Data.Vm == nil || ce.Data.Vm.Vm.Value == "" { | |
| return nil, errors.New("event is not of type VmEvent") | |
| } | |
| // Fill information in the request into a govmomi type. | |
| mor.Type = ce.Data.Vm.Vm.Type | |
| mor.Value = ce.Data.Vm.Vm.Value | |
| if debug { | |
| log.Println("Cloud event parsed and validated.") | |
| } | |
| return &mor, nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment