Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/api/data-validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { ValidateSearchData, validationTimeout } = require('../common-lib/validat

// Set list to ignore resources that aren't being collected by Search.
// When using the oc command clusterclaim doesn't include the namespace, therefore, for testing purposes, we will omit that resource object.
const ignoreKindResourceList = ['clusterclaim', 'event', 'networkattachmentdefinition']
const ignoreKindResourceList = ['ClusterClaim', 'Event', 'NetworkAttachmentDefinition']

// Set list of resources that require filtering by api group.
const requireAPIGroup = []
Expand Down
25 changes: 12 additions & 13 deletions tests/common-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,24 @@ function fetchAPIResourcesWithListWatchMethods() {
const resourceList = []

try {
execSync("oc api-resources --namespaced -o wide --sort-by=kind | grep -E 'list.*watch|watch.*list'")
execSync('oc api-resources --namespaced --sort-by=kind --verbs=list,watch --no-headers')
.toString()
.split('\n')
.filter((resources) => resources)
.forEach((res) => {
var obj = { apigroup: '', kind: '' }

// We need to start off with slicing the string before the methods are listed. (i.e [get, list, watch])
// After the string is sliced, we need to split the string and filter out any empty data or whitespace.
const item = res
.slice(0, res.indexOf('['))
.split(' ')
.filter((data) => data)
// split the string and filter out any empty data or whitespace.
const item = res.split(' ').filter((data) => data)

if (item) {
obj.kind = item[item.length - 1].toLowerCase() // Kind is the last item.
obj.apigroup = item.length < 5 ? item[1].split('/')[0] : item[2].split('/')[0]

resourceList.push(obj)
const groupVersion = item.length < 5 ? item[1] : item[2]
// Remove the /version from the apigroup.
const apigroup = groupVersion.includes('/') ? groupVersion.split('/')[0] : ''

resourceList.push({
kind_plural: item[0],
kind: item[item.length - 1], // Kind is the last item.
apigroup: apigroup,
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Empty apigroup breaks queries 🐞 Bug ≡ Correctness

fetchAPIResourcesWithListWatchMethods now sets core (v1) resources' apigroup to an empty string, and
downstream code treats that as a real API group when disambiguating kinds across multiple groups.
This can generate invalid oc get <kind>. commands and add an empty apigroup filter to Search
queries, breaking data-validation for kinds that exist in both core and grouped APIs (e.g., Event).
Agent Prompt
## Issue description
`fetchAPIResourcesWithListWatchMethods()` now maps core `v1` resources to `apigroup: ''`. Downstream code uses `group.name != 'v1'` as the sentinel for “needs group filtering / qualification”, so `''` is treated as a real group, causing invalid `oc get <kind>.` and wrong Search `apigroup` filters.

## Issue Context
Historically, this test harness has treated core resources as `apigroup: 'v1'` (special-cased to mean “no group qualifier needed”). The PR changed this by converting no-slash apiVersions into empty string.

## Fix Focus Areas
- tests/common-lib/index.js[25-33]

## Suggested change
Set `apigroup` to `'v1'` when `groupVersion` has no `/` (or more generally, keep `apigroup = groupVersion.split('/')[0]` so `v1` stays `v1`). Keep the `/version` stripping behavior only for grouped apiVersions like `apps/v1` => `apps`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

}
})
} catch (e) {
Expand Down