Skip to content

Add support for exact matching on an element in a delimited label#40166

Merged
rosstimothy merged 1 commit intomasterfrom
tross/tsh_ls_contains
Apr 3, 2024
Merged

Add support for exact matching on an element in a delimited label#40166
rosstimothy merged 1 commit intomasterfrom
tross/tsh_ls_contains

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

@rosstimothy rosstimothy commented Apr 3, 2024

Updates the resource parser with two new functions: contains and split. When used together they provide the ability to search for resources that have labels with multiple values in a delimited list. For example, if a resource has label foo=bar,baz,bang then split(labels[foo], ",") would transform the comma label value from a string into a list: ["bar", "baz", "bang"] The list could then be fed to contains to determine if bar exists in the list: contains(split(labels[foo], ","), bar).

Changelog: Add new resource filtering predicates to allow exact matches on a single item of a delimited list stored in a label value. For example, if given the following label containing a string separated list of values foo=bar,baz,bang, it is now possible to match on any resources with a label foo that contains the element bar via contains(split(labels[foo], ","), bar).

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2024

🤖 Vercel preview here: https://docs-5fhxv19mz-goteleport.vercel.app/docs/ver/preview

@rosstimothy rosstimothy marked this pull request as ready for review April 3, 2024 14:21
@gravitational gravitational deleted a comment from github-actions Bot Apr 3, 2024
Comment thread lib/services/parser.go Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2024

🤖 Vercel preview here: https://docs-kr74pic3s-goteleport.vercel.app/docs/ver/preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2024

🤖 Vercel preview here: https://docs-jkwou3rzq-goteleport.vercel.app/docs/ver/preview

Comment thread lib/services/parser.go Outdated
Updates the resource parser with two new functions: `contains` and
`split`. When used together they provide the ability to
search for resources that have labels with multiple values in a
delimited list. For example, if a resource has label `foo=bar,baz,bang`
then `split(labels[foo], ",")` would transform the
comma label value from a string into a list: ["bar", "baz", "bang"]
The list could then be fed to `contains` to determine if bar exists
in the list: `contains(split(labels[foo], ","), bar)`.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2024

🤖 Vercel preview here: https://docs-78ezbrgvd-goteleport.vercel.app/docs/ver/preview

@rosstimothy rosstimothy added this pull request to the merge queue Apr 3, 2024
Merged via the queue into master with commit 4e1c604 Apr 3, 2024
@rosstimothy rosstimothy deleted the tross/tsh_ls_contains branch April 3, 2024 17:35
@public-teleport-github-review-bot
Copy link
Copy Markdown

@rosstimothy See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Create PR
branch/v15 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants