mirror of https://github.com/kubernetes/kops.git
dryrun output: include name instead of id:nil
When we're creating objects, we tend not to have an id. Rather than drop them entirely though, we can print their name (where we have one)
This commit is contained in:
parent
e2c52a99ce
commit
104332108f
|
|
@ -338,7 +338,17 @@ func ValueAsString(value reflect.Value) string {
|
|||
} else if compareWithID, ok := intf.(CompareWithID); ok {
|
||||
id := compareWithID.CompareWithID()
|
||||
if id == nil {
|
||||
fmt.Fprintf(b, "id:<nil>")
|
||||
// Uninformative, but we can often print the name instead
|
||||
name := ""
|
||||
hasName, ok := intf.(HasName)
|
||||
if ok {
|
||||
name = StringValue(hasName.GetName())
|
||||
}
|
||||
if name != "" {
|
||||
fmt.Fprintf(b, "name:%s", name)
|
||||
} else {
|
||||
fmt.Fprintf(b, "id:<nil>")
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintf(b, "id:%s", *id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue