mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix runsc --debug config output.
For non-string flags, `reflect.Value.String()` returns something like
`<bool Value>` or `<time.Duration value>` rather than the stringified
version of the value. So we convert the `reflect.Value` to an `interface{}`
first so that stringification works as expected.
PiperOrigin-RevId: 614879158
This commit is contained in:
committed by
gVisor bot
parent
6ad1af2b9c
commit
7220bea2b7
@@ -404,9 +404,15 @@ func (c *Config) Log() {
|
||||
st := obj.Type()
|
||||
for i := 0; i < st.NumField(); i++ {
|
||||
f := st.Field(i)
|
||||
val := obj.Field(i).String()
|
||||
if val == "" {
|
||||
var val any
|
||||
if strVal := obj.Field(i).String(); strVal == "" {
|
||||
val = "(empty)"
|
||||
} else if !f.IsExported() {
|
||||
// Cannot convert to `interface{}` for non-exported fields,
|
||||
// so just use `strVal`.
|
||||
val = fmt.Sprintf("%s (unexported)", strVal)
|
||||
} else {
|
||||
val = obj.Field(i).Interface()
|
||||
}
|
||||
if flagName, hasFlag := f.Tag.Lookup("flag"); hasFlag {
|
||||
log.Debugf("Config.%s (--%s): %v", f.Name, flagName, val)
|
||||
|
||||
Reference in New Issue
Block a user