Documentation
¶
Overview ¶
Package selector 实现 k8s label selector 语法的解析与匹配。 所有 label 值按字符串处理,无序关系;操作符:= != in notin Exists(!)DoesNotExist。
与 k8s 的差异(刻意收敛):in/notin 的操作符前后必须各有一个空格, 即只接受 "key in (a,b)" 这种写法,不接受 "key in(a,b)"。
新增操作符时需同步改三处:常量块、parse 的分支、match 的 switch。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateLabelKey ¶
ValidateLabelKey 校验 label key 的字符集,供生成期(mcpgen)与解析期共用同一套规则。 语法规则的所有权在本包:调用方不要另行实现,否则规则会漂移出「能标注但永远匹配不上」的输入。
func ValidateLabelValue ¶
ValidateLabelValue 校验 label value 的字符集,与 ValidateLabelKey 同理。
Types ¶
type Requirement ¶
Requirement 是一个条件,如 risk in (low,high)。
type Selector ¶
type Selector struct {
// Raw 是解析前的原始表达式,供基座做错误回显与启动日志打印生效规则,勿删。
Raw string
Requirements []Requirement
}
Selector 是若干条件的 AND 组合。 零值非法:必须经 Parse 构造,直接用 Selector{} 会被 Match 判为不匹配。
Click to show internal directories.
Click to hide internal directories.