MCPcopy
hub / github.com/ahmetb/kubectl-tree / matchResources

Function matchResources

cmd/kubectl-tree/apis.go:93–113  ·  view source on GitHub ↗
(patterns []string, apiRes metav1.APIResource)

Source from the content-addressed store, hash-verified

91}
92
93func matchResources(patterns []string, apiRes metav1.APIResource) bool {
94 if apiRes.SingularName == "" {
95 apiRes.SingularName = strings.ToLower(apiRes.Kind)
96 }
97 names := []string{apiRes.Name, apiRes.SingularName, apiRes.Kind}
98 names = append(names, apiRes.ShortNames...)
99
100 return matchAny(patterns, func(pattern string) (bool, error) {
101 for _, name := range names {
102 ok, err := filepath.Match(pattern, name)
103 if err != nil {
104 return false, err
105 }
106 if ok {
107 return true, nil
108 }
109 }
110
111 return false, nil
112 })
113}
114
115func findAPIs(client discovery.DiscoveryInterface, apiGroups, resources []string) (*resourceMap, error) {
116 start := time.Now()

Callers 2

TestMatchResourcesFunction · 0.85
findAPIsFunction · 0.85

Calls 1

matchAnyFunction · 0.85

Tested by 1

TestMatchResourcesFunction · 0.68