Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 13 additions & 16 deletions tests/common-lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,23 @@ 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)

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)
}
// Split the string and filter out any empty data or whitespace.
const item = res.split(' ').filter((data) => data)

// Remove the /version from the apigroup.
const groupVersion = item.length < 5 ? item[1] : item[2]
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,
})
})
} catch (e) {
console.error(e)
Expand Down