#k8s #dsl #expressions

simple-selectors

A simple label selector syntax inspired (and mostly compatible) to k8s

1 unstable release

Uses old Rust 2015

0.1.0 Feb 12, 2018

#59 in #k8s

Unlicense

17KB
375 lines

simple-selectors

Build Status License: Unlicense Crates.io

k8s style selectors for rust.

BNF

  <selector-syntax>         ::= <requirement> | <requirement> "," <selector-syntax>
  <requirement>             ::= [!] KEY [ <set-based-restriction> | <exact-match-restriction> ]
  <set-based-restriction>   ::= "" | <inclusion-exclusion> <value-set>
  <inclusion-exclusion>     ::= <inclusion> | <exclusion>
  <exclusion>               ::= "notin"
  <inclusion>               ::= "in"
  <value-set>               ::= "(" <values> ")"
  <values>                  ::= VALUE | VALUE "," <values>
  <exact-match-restriction> ::= ["="|"=="|"!="] VALUE

*) This section has been copy pasted from https://github.com/blendlabs/go-selector (this is what this library is based upon)

Usage

let mut labels = LabelMap::new();
labels.insert("test", "test");
labels.insert("test1", "test");
let result = parse("test = test, test1 in (test)", &labels);

Feedback and Contributions

Both very welcome. This is my first public crate and I am just starting to learn rust. So non-idiomatic rust and beginner mistakes are to be expected in the code base. Please provide feedback and contributions so I can fix it :).

Dependencies

~465KB