Skip to content

Commit

Permalink
Improve information if IsStateDirty() fails
Browse files Browse the repository at this point in the history
Before:

    panic: unexpected field type in StoreSnapshot

After:

    panic: unexpected field type in StoreSnapshot: XXX_NoUnkeyedLiteral struct

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Mar 20, 2019
1 parent 92148fa commit 9029a54
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manager/dirty.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package manager

import (
"fmt"
"reflect"

"github.com/docker/swarmkit/api"
Expand Down Expand Up @@ -45,7 +46,7 @@ func (m *Manager) IsStateDirty() (bool, error) {
field := val.Field(i)
structField := val.Type().Field(i)
if structField.Type.Kind() != reflect.Slice {
panic("unexpected field type in StoreSnapshot")
panic(fmt.Sprintf("unexpected field type in StoreSnapshot: %s (type %v)", structField.Name, structField.Type.Kind()))
}
if structField.Name != "Nodes" && structField.Name != "Clusters" && structField.Name != "Networks" && field.Len() != 0 {
// One of the other data types has an entry
Expand Down

0 comments on commit 9029a54

Please sign in to comment.