mirror of
https://github.com/weaveworks/scope.git
synced 2026-04-22 10:27:51 +00:00
Upgraded from 99c19923, branch release-3.0. This required fetching or upgrading the following: * k8s.io/api to kubernetes-1.9.1 * k8s.io/apimachinery to kubernetes-1.9.1 * github.com/juju/ratelimit to 1.0.1 * github.com/spf13/pflag to 4c012f6d Also, update Scope's imports/function calls to be compatible with the new client.
26 lines
642 B
Go
26 lines
642 B
Go
package extra
|
|
|
|
import (
|
|
"github.com/json-iterator/go"
|
|
"unicode"
|
|
)
|
|
|
|
// SupportPrivateFields include private fields when encoding/decoding
|
|
func SupportPrivateFields() {
|
|
jsoniter.RegisterExtension(&privateFieldsExtension{})
|
|
}
|
|
|
|
type privateFieldsExtension struct {
|
|
jsoniter.DummyExtension
|
|
}
|
|
|
|
func (extension *privateFieldsExtension) UpdateStructDescriptor(structDescriptor *jsoniter.StructDescriptor) {
|
|
for _, binding := range structDescriptor.Fields {
|
|
isPrivate := unicode.IsLower(rune(binding.Field.Name[0]))
|
|
if isPrivate {
|
|
binding.FromNames = []string{binding.Field.Name}
|
|
binding.ToNames = []string{binding.Field.Name}
|
|
}
|
|
}
|
|
}
|