mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	pin dependency github.com/beorn7/perks from v1.0.0 to v1.0.1 pin dependency github.com/golang/protobuf from v1.3.3 to v1.4.2 pin denpendency github.com/json-iterator/go from v1.1.8 to v1.1.9 pin dependency github.com/prometheus/common from v0.4.1 to v0.9.1 pin dependency github.com/prometheus/procfs from v0.0.5 to v0.0.11 pin dependency github.com/alecthomas/template from v0.0.0-20160405071501-a0175ee3bccc to v0.0.0-20190718012654-fb15b899a751 pin dependency github.com/alecthomas/units from v0.0.0-20151022065526-2efee857e7cf to v0.0.0-20190717042225-c3de453c63f4 pin dependency github.com/go-kit/kit from v0.8.0 to v0.9.0 pin dependency github.com/go-logfmt/logfmt from v0.3.0 to v0.4.0 Co-Authored-By: Jordan Liggitt <jordan@liggitt.net>
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2015 The Go Authors. All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| // Package jsonpb provides functionality to marshal and unmarshal between a
 | |
| // protocol buffer message and JSON. It follows the specification at
 | |
| // https://developers.google.com/protocol-buffers/docs/proto3#json.
 | |
| //
 | |
| // Do not rely on the default behavior of the standard encoding/json package
 | |
| // when called on generated message types as it does not operate correctly.
 | |
| //
 | |
| // Deprecated: Use the "google.golang.org/protobuf/encoding/protojson"
 | |
| // package instead.
 | |
| package jsonpb
 | |
| 
 | |
| import (
 | |
| 	"github.com/golang/protobuf/proto"
 | |
| 	"google.golang.org/protobuf/reflect/protoreflect"
 | |
| 	"google.golang.org/protobuf/reflect/protoregistry"
 | |
| 	"google.golang.org/protobuf/runtime/protoimpl"
 | |
| )
 | |
| 
 | |
| // AnyResolver takes a type URL, present in an Any message,
 | |
| // and resolves it into an instance of the associated message.
 | |
| type AnyResolver interface {
 | |
| 	Resolve(typeURL string) (proto.Message, error)
 | |
| }
 | |
| 
 | |
| type anyResolver struct{ AnyResolver }
 | |
| 
 | |
| func (r anyResolver) FindMessageByName(message protoreflect.FullName) (protoreflect.MessageType, error) {
 | |
| 	return r.FindMessageByURL(string(message))
 | |
| }
 | |
| 
 | |
| func (r anyResolver) FindMessageByURL(url string) (protoreflect.MessageType, error) {
 | |
| 	m, err := r.Resolve(url)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return protoimpl.X.MessageTypeOf(m), nil
 | |
| }
 | |
| 
 | |
| func (r anyResolver) FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error) {
 | |
| 	return protoregistry.GlobalTypes.FindExtensionByName(field)
 | |
| }
 | |
| 
 | |
| func (r anyResolver) FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error) {
 | |
| 	return protoregistry.GlobalTypes.FindExtensionByNumber(message, field)
 | |
| }
 | |
| 
 | |
| func wellKnownType(s protoreflect.FullName) string {
 | |
| 	if s.Parent() == "google.protobuf" {
 | |
| 		switch s.Name() {
 | |
| 		case "Empty", "Any",
 | |
| 			"BoolValue", "BytesValue", "StringValue",
 | |
| 			"Int32Value", "UInt32Value", "FloatValue",
 | |
| 			"Int64Value", "UInt64Value", "DoubleValue",
 | |
| 			"Duration", "Timestamp",
 | |
| 			"NullValue", "Struct", "Value", "ListValue":
 | |
| 			return string(s.Name())
 | |
| 		}
 | |
| 	}
 | |
| 	return ""
 | |
| }
 | |
| 
 | |
| func isMessageSet(md protoreflect.MessageDescriptor) bool {
 | |
| 	ms, ok := md.(interface{ IsMessageSet() bool })
 | |
| 	return ok && ms.IsMessageSet()
 | |
| }
 |