Skip to content

feat: add ListById function and test#96

Merged
squeed merged 1 commit intocoreos:mainfrom
alegrey91:main
Sep 1, 2022
Merged

feat: add ListById function and test#96
squeed merged 1 commit intocoreos:mainfrom
alegrey91:main

Conversation

@alegrey91
Copy link
Contributor

Fix #95

Copy link
Contributor

@squeed squeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruleId should be one-indexed to match the iptables binary.

@alegrey91
Copy link
Contributor Author

Hi @squeed, thanks for your reply.
So, you mean something like this?

// List rules in specified table/chain
func (ipt *IPTables) ListById(table, chain string, Id int) (string, error) {
	args := []string{"-t", table, "-S", chain, strconv.Itoa(Id)}
	rule, err := ipt.executeList(args)
	if err != nil {
		return "", err
	}
	return rule[0], nil
}

@alegrey91
Copy link
Contributor Author

I think could be more appropriate the name ListById() for this function, right?

@alegrey91 alegrey91 requested a review from squeed August 16, 2022 14:50
@alegrey91 alegrey91 changed the title feat: add GetRuleById function and test feat: add ListById function and test Aug 16, 2022
}

// List rules in specified table/chain
func (ipt *IPTables) ListById(table, chain string, Id int) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. One minor nit: Id should be lower-cased. Once that's fixed we can merge :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@squeed squeed merged commit d2b8608 into coreos:main Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GetRuleById() function

2 participants