From 951c79d71ba99d6be62bda17242e5215a2d7cd57 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 26 Aug 2024 10:05:25 -0400 Subject: [PATCH] Fix ParseDump with an "empty" table declaration --- fake.go | 4 ++-- fake_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fake.go b/fake.go index 584c27a..77c27e8 100644 --- a/fake.go +++ b/fake.go @@ -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) @@ -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 } diff --git a/fake_test.go b/fake_test.go index 59543b3..c9a44e2 100644 --- a/fake_test.go +++ b/fake_test.go @@ -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 ; }