packer-cn/vendor/github.com/yandex-cloud/go-sdk/operation/utils.go

24 lines
546 B
Go
Raw Normal View History

2019-03-26 08:48:37 -04:00
// Copyright (c) 2018 Yandex LLC. All rights reserved.
// Author: Vladimir Skipor <skipor@yandex-team.ru>
package operation
import (
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
)
// Copy from bb.yandex-team.ru/cloud/cloud-go/pkg/protoutil/any.go
func UnmarshalAny(msg *any.Any) (proto.Message, error) {
if msg == nil {
return nil, nil
}
box := &ptypes.DynamicAny{}
err := ptypes.UnmarshalAny(msg, box)
if err != nil {
return nil, err
}
return box.Message, nil
}