function mapGroupResources (clusterVer, resourcesResp, preferredGroupVer) {
	const groupVer = resourcesResp.groupVersion;
	const extractVerRegex = /^([^/]+\/)?(v[0-9]+([a-z]+[0-9]+)?)$/;
	const ver = extractVerRegex.exec(groupVer)[2];
	const resources = resourcesResp.resources;

	if (!apiMaps[clusterVer]) apiMaps[clusterVer] = {};

	for (const resource of resources) {
		const name = resource.name;

		// Only process the original resource, no sub-routes
		if (name.indexOf('/') !== -1) continue;

		// Get the current mapped group version
		let currGroupVer, currVer;
		if (apiMaps[clusterVer][name]) {
			currGroupVer = apiMaps[clusterVer][name].version;
			currVer = extractVerRegex.exec(currGroupVer)[2];
		}

		// If the current mapped matches the preferred version, just keep that
		if (currGroupVer && preferredGroupVer && currGroupVer === preferredGroupVer) continue;

		// If there isn't any current mapped group version or the new group version is greater
		// than the current one, set the current group version
		else if (!currGroupVer || (currGroupVer && compareAPIVersions(currVer, ver) < 0)) {
			apiMaps[clusterVer][name] = {
				version: groupVer,
				namespaced: resource.namespaced
			};
		}
	}

	return apiMaps[clusterVer];
}
/**
 * Takes the cluster version, an API resources response from the cluster, and the
 * preferred version of the API endpoint whose resources are being mapped.
 *
 * @param {String} clusterVer Version of the Kubernetes cluster, e.g. 1.7 or 1.8
 * @param {Object} resourcesResp Response from the cluster of a /apis/[group]/[version] request
 * @param {String} preferredGroupVer Preferred version of the group, e.g. apps/v1beta1
 */
Takes the cluster version, an API resources response from the cluster, and the
preferred version of the API endpoint whose resources are being mapped.

@param {String} clusterVer Version of the Kubernetes cluster, e.g. 1.7 or 1.8
@param {Object} resourcesResp Response from the cluster of a /apis/[group]/[version] request
@param {String} preferredGroupVer Preferred version of the group, e.g. apps/v1beta1
Takes the cluster version an API resources response from the cluster and the preferred version of the API endpoint whose resources are being mapped . @param { String } clusterVer Version of the Kubernetes cluster e . g . 1 . 7 or 1 . 8 @param { Object } resourcesResp Response from the cluster of a / apis / [ group ] / [ version ] request @param { String } preferredGroupVer Preferred version of the group e . g . apps / v1beta1
function mapGroupResources (clusterVer, resourcesResp, preferredGroupVer) {
	const groupVer = resourcesResp.groupVersion;
	const extractVerRegex = /^([^/]+\/)?(v[0-9]+([a-z]+[0-9]+)?)$/;
	const ver = extractVerRegex.exec(groupVer)[2];
	const resources = resourcesResp.resources;
	if (!apiMaps[clusterVer]) apiMaps[clusterVer] = {};
	for (const resource of resources) {
		const name = resource.name;
		if (name.indexOf('/') !== -1) continue;
		let currGroupVer, currVer;
		if (apiMaps[clusterVer][name]) {
			currGroupVer = apiMaps[clusterVer][name].version;
			currVer = extractVerRegex.exec(currGroupVer)[2];
		}
		if (currGroupVer && preferredGroupVer && currGroupVer === preferredGroupVer) continue;
		else if (!currGroupVer || (currGroupVer && compareAPIVersions(currVer, ver) < 0)) {
			apiMaps[clusterVer][name] = {
				version: groupVer,
				namespaced: resource.namespaced
			};
		}
	}
	return apiMaps[clusterVer];
}
function mapGroupResources ( clusterVer , resourcesResp , preferredGroupVer ) { const groupVer = resourcesResp . groupVersion ; const extractVerRegex = / ^([^/]+\/)?(v[0-9]+([a-z]+[0-9]+)?)$ / ; const ver = extractVerRegex . exec ( groupVer ) [ 2 ] ; const resources = resourcesResp . resources ; if ( ! apiMaps [ clusterVer ] ) apiMaps [ clusterVer ] = { } ; for ( const resource of resources ) { const name = resource . name ; if ( name . indexOf ( '/' ) !== - 1 ) continue ; let currGroupVer , currVer ; if ( apiMaps [ clusterVer ] [ name ] ) { currGroupVer = apiMaps [ clusterVer ] [ name ] . version ; currVer = extractVerRegex . exec ( currGroupVer ) [ 2 ] ; } if ( currGroupVer && preferredGroupVer && currGroupVer === preferredGroupVer ) continue ; else if ( ! currGroupVer || ( currGroupVer && compareAPIVersions ( currVer , ver ) < 0 ) ) { apiMaps [ clusterVer ] [ name ] = { version : groupVer , namespaced : resource . namespaced } ; } } return apiMaps [ clusterVer ] ; }
Takes the cluster version, an API resources response from the cluster, and the
 preferred version of the API endpoint whose resources are being mapped.
Takes the cluster version an API resources response from the cluster and the preferred version of the API endpoint whose resources are being mapped .
// Only process the original resource, no sub-routes // Get the current mapped group version // If the current mapped matches the preferred version, just keep that // If there isn't any current mapped group version or the new group version is greater // than the current one, set the current group version