feat(netdev): support regex DeviceList matching#238
Open
jasen11 wants to merge 1 commit into
Open
Conversation
Signed-off-by: jasen11 <1449435446@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题背景
DeviceList 用于配置需要关注的网卡设备列表,但当前多个 netdev 相关实现只支持精确字符串匹配。
例如配置 DeviceList = ["eth[0-9]+"] 在修改前无法匹配 eth0,因为旧逻辑等价于 slices.Contains([]string{"eth[0-9]+"}, "eth0")。
这会导致用户很难一次性配置一组同类网卡,例如 eth0、eth1、bond0 等。
修改内容
本 PR 在 internal/matcher 中新增通用的 ListMatcher,并应用到以下配置项:
匹配规则如下:
同时更新了示例配置和中英文配置文档,说明 DeviceList 的匹配行为。
测试