Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1794754: correctly show schema information for all core resources #4062

Merged
merged 1 commit into from Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/public/components/api-explorer.tsx
Expand Up @@ -382,7 +382,7 @@ const APIResourceDetails: React.FC<APIResourceTabProps> = ({ customData: { kindO
{description && (
<>
<dt>Description</dt>
<dd className="co-break-word co-pre-line">
<dd className="co-break-word co-pre-wrap">
<LinkifyExternal>{description}</LinkifyExternal>
</dd>
</>
Expand Down
4 changes: 2 additions & 2 deletions frontend/public/components/sidebars/explore-type-sidebar.tsx
Expand Up @@ -109,7 +109,7 @@ export const ExploreType: React.FC<ExploreTypeProps> = (props) => {
</Breadcrumb>
)}
{description && (
<p className="co-break-word co-pre-line">
<p className="co-break-word co-pre-wrap">
<LinkifyExternal>{description}</LinkifyExternal>
</p>
)}
Expand All @@ -131,7 +131,7 @@ export const ExploreType: React.FC<ExploreTypeProps> = (props) => {
</small>
</h5>
{definition.description && (
<p className="co-break-word co-pre-line">
<p className="co-break-word co-pre-wrap">
<LinkifyExternal>{definition.description}</LinkifyExternal>
</p>
)}
Expand Down
17 changes: 8 additions & 9 deletions frontend/public/module/k8s/get-resources.ts
Expand Up @@ -106,31 +106,30 @@ const getResources_ = () =>
const safeResources = [];
const adminResources = [];

const defineModels = (list: APIResourceList): K8sKind[] =>
list.resources
const defineModels = (list: APIResourceList): K8sKind[] => {
const groupVersionParts = list.groupVersion.split('/');
const apiGroup = groupVersionParts.length > 1 ? groupVersionParts[0] : null;
const apiVersion = groupVersionParts.length > 1 ? groupVersionParts[1] : list.groupVersion;
return list.resources
.filter(({ name }) => !name.includes('/'))
.map(({ name, singularName, namespaced, kind, verbs, shortNames }) => {
const groupVersion =
list.groupVersion.split('/').length === 2
? list.groupVersion
: `core/${list.groupVersion}`;

return {
kind,
namespaced,
verbs,
shortNames,
label: kind,
plural: name,
apiVersion: groupVersion.split('/')[1],
apiVersion,
abbr: kindToAbbr(kind),
apiGroup: groupVersion.split('/')[0],
...(apiGroup ? { apiGroup } : {}),
labelPlural: `${kind}${kind.endsWith('s') ? 'es' : 's'}`,
path: name,
id: singularName,
crd: true,
};
});
};

const models = _.flatten(data.filter((d) => d.resources).map(defineModels));
allResources.forEach((r) =>
Expand Down
10 changes: 5 additions & 5 deletions frontend/public/module/k8s/resource.js
Expand Up @@ -5,8 +5,8 @@ import { selectorToString } from './selector';
import { WSFactory } from '../ws-factory';

/** @type {(model: K8sKind) => string} */
const getK8sAPIPath = (model) => {
const isLegacy = _.get(model, 'apiGroup', 'core') === 'core' && model.apiVersion === 'v1';
const getK8sAPIPath = ({ apiGroup = 'core', apiVersion }) => {
const isLegacy = apiGroup === 'core' && apiVersion === 'v1';
let p = k8sBasePath;

if (isLegacy) {
Expand All @@ -15,11 +15,11 @@ const getK8sAPIPath = (model) => {
p += '/apis/';
}

if (!isLegacy && model.apiGroup) {
p += `${model.apiGroup}/`;
if (!isLegacy && apiGroup) {
p += `${apiGroup}/`;
}

p += model.apiVersion;
p += apiVersion;
return p;
};

Expand Down