Skip to content
Closed
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
17 changes: 17 additions & 0 deletions frontend/packages/console-demo-plugin/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,20 @@ export const FooBarModel: K8sKind = {
id: 'foobar',
crd: true,
};

export const MyTemplatesModel: K8sKind = {
label: 'My Specialized Template',
labelPlural: 'My Specialized Templates',
apiVersion: 'v1',
path: 'templates',
apiGroup: 'template.openshift.io',
plural: 'mytemplates',
namespaced: true,
abbr: 'MT',
kind: 'Template',
id: 'mytemplate',
specialized: true,
selector: {
matchLabels: { my: 'yes' },
},
};
6 changes: 3 additions & 3 deletions frontend/public/components/utils/resource-link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FLAGS } from '../../const';
const unknownKinds = new Set();

export const resourcePathFromModel = (model, name, namespace) => {
const {path, namespaced, crd} = model;
const {plural, namespaced, crd} = model;
Copy link
Member Author

Choose a reason for hiding this comment

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

@spadgett Hi, this function is building url for the console ( vs. building for the k8s API ) , shouldn't is use plural instead of path, what am I missing ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Models representing custom resources (having crd: true) will have their resourcePath based on referenceForModel function ([group]~[version]~[kind]), which serves as the key for all CRD-based models.

Models representing core k8s objects (without crd: true) will have their resourcePath based on model's path attribute only.

Model's plural attribute seems to be used for organizing models within Redux and k8s queries, see e.g. connectToPlural in public/kinds.ts.


let url = '/k8s/';

Expand All @@ -26,8 +26,8 @@ export const resourcePathFromModel = (model, name, namespace) => {

if (crd) {
url += referenceForModel(model);
} else if (path) {
url += path;
} else if (plural) {
url += plural;
}

if (name) {
Expand Down
1 change: 1 addition & 0 deletions frontend/public/module/k8s/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ export type K8sKind = {

id?: string;
crd?: boolean;
specialized?: boolean;
apiVersion: string;
apiGroup?: string;
namespaced?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/module/k8s/k8s-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ k8sModels = k8sModels.withMutations(map => {
const baseModelCount = map.size;
const pluginModels = _.flatMap(plugins.registry.getModelDefinitions().map(md => md.properties.models));

const pluginModelsToAdd = pluginModels.filter(model => !hasModel(model));
const pluginModelsToAdd = pluginModels.filter(model => (model.specialized || !hasModel(model)));
map.merge(modelsToMap(pluginModelsToAdd));

_.difference(pluginModels, pluginModelsToAdd).forEach(model => {
Expand Down