Skip to content

Commit a676ccb

Browse files
committed
Remove s2i component support and add otherComponents support
This PR fixes redhat-developer#2324. Signed-off-by: Denis Golovin [email protected]
1 parent 64db38b commit a676ccb

File tree

13 files changed

+188
-335
lines changed

13 files changed

+188
-335
lines changed

src/odo.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Platform } from './util/platform';
2020
import * as odo from './odo/config';
2121
import { GlyphChars } from './util/constants';
2222
import { Application } from './odo/application';
23-
import { ComponentType, ComponentTypesJson, ComponentKind, ComponentTypeAdapter, Registry, RegistryList } from './odo/componentType';
23+
import { ComponentType, ComponentTypesJson, ComponentTypeAdapter, Registry, RegistryList } from './odo/componentType';
2424
import { Project } from './odo/project';
2525
import { ComponentsJson, NotAvailable } from './odo/component';
2626
import { Url } from './odo/url';
@@ -65,7 +65,6 @@ export interface OpenShiftObject extends QuickPickItem {
6565
contextPath?: Uri;
6666
path?: string;
6767
iconPath?: Uri;
68-
kind?: ComponentKind;
6968
}
7069

7170
function compareNodes(a: OpenShiftObject, b: OpenShiftObject): number {
@@ -262,14 +261,19 @@ export class OpenShiftLoginRequired extends OpenShiftObjectImpl {
262261
}
263262

264263
export class OpenShiftComponent extends OpenShiftObjectImpl {
264+
265265
constructor(parent: OpenShiftObject,
266266
name: string,
267267
contextValue: ContextType,
268268
contextPath: Uri = undefined,
269-
compType: string = undefined,
270-
public readonly kind: ComponentKind) {
269+
compType: string = undefined) {
271270
super(parent, name, contextValue, '', Collapsed, contextPath, compType);
272271
}
272+
273+
isOdoManaged(): boolean {
274+
return this.compType === NotAvailable;
275+
}
276+
273277
get iconPath(): Uri {
274278
return Uri.file(path.join(__dirname, '../../images/component', 'workspace.png'));
275279
}
@@ -568,25 +572,18 @@ export class OdoImpl implements Odo {
568572
const components = [...componentsJson.otherComponents, ...componentsJson.devfileComponents];
569573

570574
const deployedComponents = components.map<OpenShiftComponent>((value) => {
571-
return new OpenShiftComponent(application, value.metadata.name, value.spec.componentType === NotAvailable ? ContextType.COMPONENT_OTHER : ContextType.COMPONENT_NO_CONTEXT, value.kind);
575+
const defaultContext = value.spec.type === NotAvailable ? ContextType.COMPONENT_OTHER : ContextType.COMPONENT_NO_CONTEXT;
576+
return new OpenShiftComponent(application, value.metadata.name, defaultContext, undefined, value.spec.type);
572577
});
573578
const targetAppName = application.getName();
574579
const targetPrjName = application.getParent().getName();
575580

576581
OdoImpl.data.getSettings().filter((comp) => comp.spec.app === targetAppName && comp.metadata.namespace === targetPrjName).forEach((comp) => {
577-
const jsonItem = components.find((item)=> item.name === comp.metadata.name);
582+
const jsonItem = components.find((item)=> item.metadata.name === comp.metadata.name);
578583
let item: OpenShiftObject;
579584
if (jsonItem) {
580585
item = deployedComponents.find((component) => component.getName() === comp.metadata.name);
581586
}
582-
const builderImage = comp.spec.type.includes(':') ?
583-
{
584-
name: comp.spec.type.split(':')[0],
585-
tag: comp.spec.type.split(':')[1]
586-
} : {
587-
name: comp.spec.type,
588-
tag: 'latest'
589-
};
590587
if (item && item.contextValue === ContextType.COMPONENT_NO_CONTEXT) {
591588
item.contextPath = Uri.file(comp.status.context);
592589
item.contextValue = ContextType.COMPONENT_PUSHED;
@@ -597,8 +594,7 @@ export class OdoImpl implements Odo {
597594
comp.metadata.name,
598595
item ? item.contextValue : ContextType.COMPONENT,
599596
Uri.file(comp.status.context),
600-
comp.spec.type === 'Not available' ? odo.SourceType.UNKNOWN : odo.SourceType.LOCAL,
601-
comp.spec.type === 'Not available' ? ComponentKind.OTHER : ComponentKind.DEVFILE
597+
comp.spec.type
602598
)
603599
);
604600
}
@@ -634,7 +630,7 @@ export class OdoImpl implements Odo {
634630
const devfileItems: ComponentTypeAdapter[] = [];
635631

636632
if (compTypesJson?.items) {
637-
compTypesJson.items.map((item) => devfileItems.push(new ComponentTypeAdapter(ComponentKind.DEVFILE, item.Name, undefined, item.Description, undefined, item.Registry.Name)));
633+
compTypesJson.items.map((item) => devfileItems.push(new ComponentTypeAdapter(item.Name, undefined, item.Description, undefined, item.Registry.Name)));
638634
}
639635

640636
return devfileItems;
@@ -881,7 +877,7 @@ export class OdoImpl implements Odo {
881877
if (!targetApplication) {
882878
await this.insertAndReveal(application);
883879
}
884-
await this.insertAndReveal(new OpenShiftComponent(application, name, ContextType.COMPONENT, location, 'local', ComponentKind.DEVFILE), notification);
880+
await this.insertAndReveal(new OpenShiftComponent(application, name, ContextType.COMPONENT, location, type), notification);
885881
} else {
886882
OdoImpl.data.delete(application);
887883
OdoImpl.data.delete(application.getParent());
@@ -1033,7 +1029,7 @@ export class OdoImpl implements Odo {
10331029
comp.contextValue = ContextType.COMPONENT_PUSHED;
10341030
this.subject.next(new OdoEventImpl('changed', comp));
10351031
} else if (!comp) {
1036-
const newComponent = new OpenShiftComponent(app, added.metadata.name, ContextType.COMPONENT, Uri.file(added.status.context), added.spec.sourceType, added.spec.sourceType ? ComponentKind.S2I : ComponentKind.DEVFILE);
1032+
const newComponent = new OpenShiftComponent(app, added.metadata.name, ContextType.COMPONENT, Uri.file(added.status.context), added.spec.type);
10371033
this.insertAndRefresh(newComponent);
10381034
}
10391035
} else if (!app) {

src/odo/component.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,10 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55

6+
import { Component } from './config';
67

7-
export const NotAvailable = 'Not available';
88

9-
export interface DevfileComponent {
10-
kind: 'DevfileComponent';
11-
apiVersion: string;
12-
metadata: {
13-
name: string;
14-
creationTimestamp: string;
15-
},
16-
spec: {
17-
namespace: string;
18-
application: string;
19-
componentType: string;
20-
},
21-
status: {
22-
state: string;
23-
}
24-
}
9+
export const NotAvailable = 'Not available';
2510

2611
export interface ComponentsJson {
2712
kind: string;
@@ -30,7 +15,7 @@ export interface ComponentsJson {
3015
creationTimestamp: string;
3116
},
3217
// eslint-disable-next-line camelcase
33-
otherComponents: DevfileComponent[];
18+
otherComponents: Component[];
3419
// eslint-disable-next-line camelcase
35-
devfileComponents: DevfileComponent[];
20+
devfileComponents: Component[];
3621
}

src/odo/componentType.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
import { Url } from 'url';
77
import { Data } from './componentTypeDescription';
88

9-
export enum ComponentKind {
10-
S2I = 's2i',
11-
OTHER = 'other',
12-
DEVFILE = 'devfile'
13-
}
14-
159
export interface RegistryList {
1610
registries: Registry[];
1711
}
@@ -35,9 +29,6 @@ export interface ImageStreamTag {
3529
}
3630

3731
export function ascDevfileFirst(c1: ComponentType, c2: ComponentType): number {
38-
if(c1.type !== c2.type) {
39-
return c1.type === ComponentKind.DEVFILE? -1: 1;
40-
}
4132
return c1.label.localeCompare(c2.label)
4233
}
4334

@@ -77,7 +68,6 @@ export interface ComponentType {
7768
label: string;
7869
description: string;
7970
name: string;
80-
type: ComponentKind;
8171
version: string;
8272
}
8373

@@ -88,7 +78,6 @@ export interface ComponentTypeDescription {
8878

8979
export class ComponentTypeAdapter implements ComponentType {
9080
constructor(
91-
public readonly type: ComponentKind,
9281
public readonly name: string,
9382
public readonly version: string,
9483
public readonly description: string,

src/odo/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ export interface Port {
1616
protocol: string;
1717
}
1818

19-
export const enum SourceType {
20-
GIT = 'git',
21-
LOCAL = 'local',
22-
BINARY = 'binary',
23-
UNKNOWN = 'unknown'
24-
}
19+
export const NOT_AVAILABLE = 'NOT_AVAILABLE';
2520

2621
export interface ComponentMetadata {
2722
name: string;
@@ -32,7 +27,6 @@ export interface ComponentMetadata {
3227
export interface ComponentSpec {
3328
app: string;
3429
type: string;
35-
sourceType: SourceType,
3630
ports: string[];
3731
}
3832

0 commit comments

Comments
 (0)