Skip to content

Commit

Permalink
Rename kind property to avoid conflict with proposed API (#2315)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Golovin [email protected]
  • Loading branch information
dgolovin authored Dec 10, 2021
1 parent 1b90a6f commit b787b09
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
21 changes: 13 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/odo/componentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export interface ImageStreamTag {
}

export function ascDevfileFirst(c1: ComponentType, c2: ComponentType): number {
if(c1.kind !== c2.kind) {
return c1.kind === ComponentKind.DEVFILE? -1: 1;
if(c1.type !== c2.type) {
return c1.type === ComponentKind.DEVFILE? -1: 1;
}
return c1.label.localeCompare(c2.label)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export interface ComponentType {
label: string;
description: string;
name: string;
kind: ComponentKind;
type: ComponentKind;
version: string;
}

Expand All @@ -87,7 +87,7 @@ export interface ComponentTypeDescription {

export class ComponentTypeAdapter implements ComponentType {
constructor(
public readonly kind: ComponentKind,
public readonly type: ComponentKind,
public readonly name: string,
public readonly version: string,
public readonly description: string,
Expand Down
8 changes: 4 additions & 4 deletions src/openshift/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export class Component extends OpenShiftItem {
progressIndicator.show();
const componentTypes = await Component.odo.getComponentTypes();
if (componentTypeName) {
componentTypeCandidates = componentTypes.filter(type => type.name === componentTypeName && type.kind === componentKind && (!version || type.version === version));
componentTypeCandidates = componentTypes.filter(type => type.name === componentTypeName && type.type === componentKind && (!version || type.version === version));
if (componentTypeCandidates?.length === 0) {
componentType = await window.showQuickPick(componentTypes.sort(ascDevfileFirst), { placeHolder: `Cannot find Component type '${componentTypeName}', select one below to use instead`, ignoreFocusOut: true });
} else if (componentTypeCandidates?.length > 1) {
Expand All @@ -668,7 +668,7 @@ export class Component extends OpenShiftItem {

if (!componentType) return createCancelledResult('componentType');

if (componentType.kind === ComponentKind.DEVFILE) {
if (componentType.type === ComponentKind.DEVFILE) {
progressIndicator.placeholder = 'Checking if provided context folder is empty'
progressIndicator.show();
const globbyPath = `${folder.fsPath.replace('\\', '/')}/`;
Expand Down Expand Up @@ -778,13 +778,13 @@ export class Component extends OpenShiftItem {
return result;
}
const components = await Component.odo.getComponentTypes();
const componentBuilder: ComponentTypeAdapter = components.find((comonentType) => comonentType.kind === component.kind? comonentType.name === component.builderImage.name : false);
const componentBuilder: ComponentTypeAdapter = components.find((comonentType) => comonentType.type === component.kind? comonentType.name === component.builderImage.name : false);
let isJava: boolean;
let isNode: boolean;
let isPython: boolean;

// TODO: https://github.com/redhat-developer/vscode-openshift-tools/issues/38
if (componentBuilder && componentBuilder.tags && componentBuilder.kind === ComponentKind.S2I) { // s2i component has been selected for debug
if (componentBuilder && componentBuilder.tags && componentBuilder.type === ComponentKind.S2I) { // s2i component has been selected for debug
isJava = componentBuilder.tags.includes('java');
isNode = componentBuilder.tags.includes('nodejs');
isPython = componentBuilder.tags.includes('python');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ suite('odo commands integration', () => {

test('describeCatalogComponent()', async function () {
const types = await ODO.getComponentTypes();
const devfileCompType = types.find((compType) => compType.kind === ComponentKind.DEVFILE);
const devfileCompType = types.find((compType) => compType.type === ComponentKind.DEVFILE);
if (!devfileCompType) {
this.skip();
} else {
Expand Down

0 comments on commit b787b09

Please sign in to comment.