Skip to content

Instantly share code, notes, and snippets.

@yuanying
Last active June 19, 2020 03:07
Show Gist options
  • Save yuanying/e0d56e98c7bd3914bc27c7baf7cc05ef to your computer and use it in GitHub Desktop.
Save yuanying/e0d56e98c7bd3914bc27c7baf7cc05ef to your computer and use it in GitHub Desktop.
LabelSelectorRequirement
cms := &v1.ConfigMapList{}
requirement, err := labels.NewRequirement(
apis.LabelKey,
selection.Exists,
nil,
)
if err != nil {
return nil, err
}
ls := labels.NewSelector().Add(*requirement)
if err := c.List(context.Background(), cms,
client.InNamespace(cmns),
client.MatchingLabelsSelector{Selector: ls},
); err != nil {
return nil, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment