mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Generate gogo stringer instead of proto stringer
Similar to %#v.
This commit is contained in:
parent
bea382c124
commit
8c17b48824
@ -53,6 +53,8 @@ func (g *genProtoIDL) PackageVars(c *generator.Context) []string {
|
|||||||
return []string{
|
return []string{
|
||||||
"option (gogoproto.marshaler_all) = true;",
|
"option (gogoproto.marshaler_all) = true;",
|
||||||
"option (gogoproto.sizer_all) = true;",
|
"option (gogoproto.sizer_all) = true;",
|
||||||
|
"option (gogoproto.goproto_stringer_all) = false;",
|
||||||
|
"option (gogoproto.stringer_all) = true;",
|
||||||
"option (gogoproto.unmarshaler_all) = true;",
|
"option (gogoproto.unmarshaler_all) = true;",
|
||||||
"option (gogoproto.goproto_unrecognized_all) = false;",
|
"option (gogoproto.goproto_unrecognized_all) = false;",
|
||||||
"option (gogoproto.goproto_enum_prefix_all) = false;",
|
"option (gogoproto.goproto_enum_prefix_all) = false;",
|
||||||
@ -316,6 +318,9 @@ func (b bodyGen) doStruct(sw *generator.SnippetWriter) error {
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if !b.omitGogo || !strings.HasPrefix(key, "(gogoproto.") {
|
if !b.omitGogo || !strings.HasPrefix(key, "(gogoproto.") {
|
||||||
|
if key == "(gogoproto.goproto_stringer)" && v[0] == "false" {
|
||||||
|
options = append(options, "(gogoproto.stringer) = false")
|
||||||
|
}
|
||||||
options = append(options, fmt.Sprintf("%s = %s", key, v[0]))
|
options = append(options, fmt.Sprintf("%s = %s", key, v[0]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
//
|
//
|
||||||
// +protobuf.options.marshal=false
|
// +protobuf.options.marshal=false
|
||||||
// +protobuf.as=Timestamp
|
// +protobuf.as=Timestamp
|
||||||
|
// +protobuf.options.(gogoproto.goproto_stringer)=false
|
||||||
type Time struct {
|
type Time struct {
|
||||||
time.Time `protobuf:"-"`
|
time.Time `protobuf:"-"`
|
||||||
}
|
}
|
||||||
@ -40,6 +41,11 @@ func (t Time) DeepCopy() Time {
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns the representation of the time.
|
||||||
|
func (t Time) String() string {
|
||||||
|
return t.Time.String()
|
||||||
|
}
|
||||||
|
|
||||||
// NewTime returns a wrapped instance of the provided time
|
// NewTime returns a wrapped instance of the provided time
|
||||||
func NewTime(time time.Time) Time {
|
func NewTime(time time.Time) Time {
|
||||||
return Time{time}
|
return Time{time}
|
||||||
|
Loading…
Reference in New Issue
Block a user