Skip to content

Commit

Permalink
Fix ParseDump with an "empty" table declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
danwinship committed Aug 26, 2024
1 parent f111257 commit 951c79d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func (fake *Fake) ParseDump(data string) (err error) {
}
}()
tx := fake.NewTransaction()
commonRegexp := regexp.MustCompile(fmt.Sprintf(`add %s %s %s (.*)`, noSpaceGroup, fake.family, fake.table))
commonRegexp := regexp.MustCompile(fmt.Sprintf(`add ([^ ]*) %s %s( (.*))?`, fake.family, fake.table))

for i, line = range lines {
line = strings.TrimSpace(line)
Expand Down Expand Up @@ -578,7 +578,7 @@ func (fake *Fake) ParseDump(data string) (err error) {
default:
return fmt.Errorf("unknown object %s", match[1])
}
err = obj.parse(match[2])
err = obj.parse(match[3])
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion fake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func TestFakeParseDump(t *testing.T) {
{
ipFamily: IPv4Family,
dump: `
add table ip kube-proxy { comment "" ; }
add table ip kube-proxy
add chain ip kube-proxy anotherchain
add chain ip kube-proxy chain { comment "foo" ; }
add map ip kube-proxy map1 { type ipv4_addr . inet_proto . inet_service ; }
Expand Down

0 comments on commit 951c79d

Please sign in to comment.