From 8fdecbcd8d180058d6f9f49158836854562f1270 Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sun, 26 Apr 2026 15:59:53 +0500 Subject: [PATCH] Add table implementation with Add, Delete, and Clear methods --- internal/batch/table/table.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 internal/batch/table/table.go diff --git a/internal/batch/table/table.go b/internal/batch/table/table.go new file mode 100644 index 0000000..a24a686 --- /dev/null +++ b/internal/batch/table/table.go @@ -0,0 +1,33 @@ +package table + +import ( + "git.kor-elf.net/kor-elf-shield/go-nftables-client/contract" + "git.kor-elf.net/kor-elf-shield/go-nftables-client/contract/nft" + "git.kor-elf.net/kor-elf-shield/go-nftables-client/family" + nftCommand "git.kor-elf.net/kor-elf-shield/go-nftables-client/internal/pkg/nft" +) + +type table struct { + command contract.CommandRun +} + +func New(command contract.CommandRun) nft.Table { + return &table{ + command: command, + } +} + +func (t *table) Add(family family.Type, tableName string) error { + args := nftCommand.TableAdd(family, tableName) + return t.command.Run(args...) +} + +func (t *table) Delete(family family.Type, tableName string) error { + args := nftCommand.TableDelete(family, tableName) + return t.command.Run(args...) +} + +func (t *table) Clear(family family.Type, tableName string) error { + args := nftCommand.TableClear(family, tableName) + return t.command.Run(args...) +}