-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove gogo from cmd/containerd-shim-runhcs-v1/stats/stats.proto
Signed-off-by: Kazuyoshi Kato <[email protected]>
- Loading branch information
Showing
8 changed files
with
896 additions
and
2,584 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
version = "2" | ||
generators = ["go"] | ||
plugins = ["grpc", "fieldpath"] | ||
|
||
# Control protoc include paths. Below are usually some good defaults, but feel | ||
# free to try it without them if it works for your project. | ||
[includes] | ||
# Include paths that will be added before all others. Typically, you want to | ||
# treat the root of the project as an include, but this may not be necessary. | ||
before = ["./protobuf"] | ||
|
||
# Paths that should be treated as include roots in relation to the vendor | ||
# directory. These will be calculated with the vendor directory nearest the | ||
# target package. | ||
packages = ["github.com/gogo/protobuf"] | ||
|
||
# This section maps protobuf imports to Go packages. These will become | ||
# `-M` directives in the call to the go protobuf generator. | ||
[packages] | ||
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto" | ||
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types" | ||
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types" | ||
"google/protobuf/struct.proto" = "github.com/gogo/protobuf/types" | ||
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" | ||
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types" | ||
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types" | ||
"github/containerd/cgroups/stats/v1/metrics.proto" = "github.com/containerd/cgroups/stats/v1" | ||
|
||
[[overrides]] | ||
prefixes = ["github.com/Microsoft/hcsshim/internal/shimdiag"] | ||
plugins = ["ttrpc"] | ||
|
||
[[overrides]] | ||
prefixes = ["github.com/Microsoft/hcsshim/internal/extendedtask"] | ||
plugins = ["ttrpc"] | ||
|
||
[[overrides]] | ||
prefixes = ["github.com/Microsoft/hcsshim/internal/computeagent"] | ||
plugins = ["ttrpc"] | ||
|
||
[[overrides]] | ||
prefixes = ["github.com/Microsoft/hcsshim/internal/ncproxyttrpc"] | ||
plugins = ["ttrpc"] | ||
|
||
[[overrides]] | ||
prefixes = ["github.com/Microsoft/hcsshim/internal/vmservice"] | ||
plugins = ["ttrpc"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gogo/protobuf/types" | ||
"google.golang.org/protobuf/proto" | ||
"google.golang.org/protobuf/reflect/protoregistry" | ||
) | ||
|
||
func marshalAny(in interface{}) (*types.Any, error) { | ||
switch t := in.(type) { | ||
case proto.Message: | ||
data, err := proto.Marshal(t) | ||
if err != nil { | ||
return nil, err | ||
} | ||
url := string(t.ProtoReflect().Descriptor().FullName()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &types.Any{Value: data, TypeUrl: url}, nil | ||
default: | ||
return nil, fmt.Errorf("failed to marshal %+v", in) | ||
} | ||
} | ||
|
||
func unmarshalAny(in *types.Any) (interface{}, error) { | ||
mt, err := protoregistry.GlobalTypes.FindMessageByURL(in.TypeUrl) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to unmarshal %+v: %w", in, err) | ||
} | ||
|
||
empty := mt.New().Interface() | ||
|
||
switch t := empty.(type) { | ||
case proto.Message: | ||
err := proto.Unmarshal(in.Value, t) | ||
if err != nil { | ||
return nil, err | ||
} | ||
default: | ||
return nil, fmt.Errorf("failed to unmarshal %+v", in) | ||
} | ||
|
||
return empty, nil | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.