@@ -49,6 +49,12 @@ export enum ContextType {
4949 COMPONENT_ROUTE = 'component_route'
5050}
5151
52+ export enum ComponentType {
53+ LOCAL = 'local' ,
54+ GIT = 'git' ,
55+ BINARY = 'binary'
56+ }
57+
5258function verbose ( _target : any , key : string , descriptor : any ) {
5359 let fnKey : string | undefined ;
5460 let fn : Function | undefined ;
@@ -321,11 +327,11 @@ export class OpenShiftObjectImpl implements OpenShiftObject {
321327
322328 get iconPath ( ) : Uri {
323329 if ( this . contextValue === ContextType . COMPONENT_PUSHED || this . contextValue === ContextType . COMPONENT || this . contextValue === ContextType . COMPONENT_NO_CONTEXT ) {
324- if ( this . compType === 'git' ) {
330+ if ( this . compType === ComponentType . GIT ) {
325331 return Uri . file ( path . join ( __dirname , "../../images/component" , 'git.png' ) ) ;
326- } else if ( this . compType === 'local' ) {
332+ } else if ( this . compType === ComponentType . LOCAL ) {
327333 return Uri . file ( path . join ( __dirname , "../../images/component" , 'workspace.png' ) ) ;
328- } else if ( this . compType === 'binary' ) {
334+ } else if ( this . compType === ComponentType . BINARY ) {
329335 return Uri . file ( path . join ( __dirname , "../../images/component" , 'binary.png' ) ) ;
330336 }
331337 } else {
@@ -382,6 +388,7 @@ export interface Odo {
382388 getClusters ( ) : Promise < OpenShiftObject [ ] > ;
383389 getProjects ( ) : Promise < OpenShiftObject [ ] > ;
384390 loadWorkspaceComponents ( event : WorkspaceFoldersChangeEvent ) : void ;
391+ addWorkspaceComponent ( WorkspaceFolder : WorkspaceFolder , component : OpenShiftObject ) ;
385392 getApplications ( project : OpenShiftObject ) : Promise < OpenShiftObject [ ] > ;
386393 getApplicationChildren ( application : OpenShiftObject ) : Promise < OpenShiftObject [ ] > ;
387394 getComponents ( application : OpenShiftObject , condition ?: ( value : OpenShiftObject ) => boolean ) : Promise < OpenShiftObject [ ] > ;
@@ -555,8 +562,10 @@ export class OdoImpl implements Odo {
555562 clusters = await this . getClustersWithOc ( ) ;
556563 }
557564 if ( clusters . length > 0 && clusters [ 0 ] . contextValue === ContextType . CLUSTER ) {
558- // kick out migration
559- this . convertObjectsFromPreviousOdoReleases ( ) ;
565+ // kick out migration if enabled
566+ if ( ! workspace . getConfiguration ( "openshiftConnector" ) . get ( "disableCheckForMigration" ) ) {
567+ this . convertObjectsFromPreviousOdoReleases ( ) ;
568+ }
560569 }
561570 return clusters ;
562571 }
@@ -663,16 +672,16 @@ export class OdoImpl implements Odo {
663672 let compSource : string = '' ;
664673 try {
665674 if ( value . source . startsWith ( 'https://' ) ) {
666- compSource = 'git' ;
675+ compSource = ComponentType . GIT ;
667676 } else if ( statSync ( Uri . parse ( value . source ) . fsPath ) . isFile ( ) ) {
668- compSource = 'binary' ;
677+ compSource = ComponentType . BINARY ;
669678 } else if ( statSync ( Uri . parse ( value . source ) . fsPath ) . isDirectory ( ) ) {
670- compSource = 'local' ;
679+ compSource = ComponentType . LOCAL ;
671680 }
672681 } catch ( ignore ) {
673682 // treat component as local in case of error when calling statSync
674683 // for not existing file or folder
675- compSource = 'local' ;
684+ compSource = ComponentType . LOCAL ;
676685 }
677686 return new OpenShiftObjectImpl ( application , value . name , ContextType . COMPONENT_NO_CONTEXT , true , this , Collapsed , undefined , compSource ) ;
678687 } ) ;
@@ -917,7 +926,7 @@ export class OdoImpl implements Odo {
917926 if ( ! targetApplication ) {
918927 await this . insertAndReveal ( application ) ;
919928 }
920- await this . insertAndReveal ( new OpenShiftObjectImpl ( application , name , ContextType . COMPONENT , false , this , Collapsed , context , 'git' ) ) ;
929+ await this . insertAndReveal ( new OpenShiftObjectImpl ( application , name , ContextType . COMPONENT , false , this , Collapsed , context , ComponentType . GIT ) ) ;
921930 }
922931 workspace . updateWorkspaceFolders ( workspace . workspaceFolders ? workspace . workspaceFolders . length : 0 , null , { uri : context } ) ;
923932 return null ;
@@ -930,7 +939,7 @@ export class OdoImpl implements Odo {
930939 if ( ! targetApplication ) {
931940 await this . insertAndReveal ( application ) ;
932941 }
933- this . insertAndReveal ( new OpenShiftObjectImpl ( application , name , ContextType . COMPONENT , false , this , Collapsed , context , 'binary' ) ) ;
942+ this . insertAndReveal ( new OpenShiftObjectImpl ( application , name , ContextType . COMPONENT , false , this , Collapsed , context , ComponentType . BINARY ) ) ;
934943 }
935944 workspace . updateWorkspaceFolders ( workspace . workspaceFolders ? workspace . workspaceFolders . length : 0 , null , { uri : context } ) ;
936945 return null ;
@@ -1017,6 +1026,11 @@ export class OdoImpl implements Odo {
10171026 OdoImpl . data . clearTreeData ( ) ;
10181027 }
10191028
1029+ addWorkspaceComponent ( folder : WorkspaceFolder , component : OpenShiftObject ) {
1030+ OdoImpl . data . addContexts ( [ folder ] ) ;
1031+ this . subject . next ( new OdoEventImpl ( 'changed' , null ) ) ;
1032+ }
1033+
10201034 loadWorkspaceComponents ( event : WorkspaceFoldersChangeEvent ) : void {
10211035 if ( event === null && workspace . workspaceFolders ) {
10221036 OdoImpl . data . addContexts ( workspace . workspaceFolders ) ;
@@ -1089,13 +1103,15 @@ export class OdoImpl implements Odo {
10891103 const result2 = await this . execute ( getPreviosOdoResourceNames ( 'ServiceInstance' ) , __dirname , false ) ;
10901104 const sis = result2 . stdout . split ( '\n' ) ;
10911105 if ( ( result2 . stdout !== '' && sis . length > 0 ) || ( result1 . stdout !== '' && dcs . length > 0 ) ) {
1092- const choice = await window . showWarningMessage ( `Some of resources in cluster must be updated to work with latest release of OpenShift Connector Extension.` , 'Learn more...' , 'Update ' , 'Cancel' ) ;
1093- if ( choice === 'Learn more... ' ) {
1094- open ( 'https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.0.24 ' ) ;
1106+ const choice = await window . showWarningMessage ( `Some of resources in cluster must be updated to work with latest release of OpenShift Connector Extension.` , 'Update' , 'Don\'t show it again' , 'Help ' , 'Cancel' ) ;
1107+ if ( choice === 'Help ' ) {
1108+ open ( 'https://github.com/redhat-developer/vscode-openshift-tools/wiki/Migration-to-v0.1.0 ' ) ;
10951109 this . subject . next ( new OdoEventImpl ( 'changed' , this . getClusters ( ) [ 0 ] ) ) ;
1110+ } else if ( choice === 'Don\'t show it again' ) {
1111+ workspace . getConfiguration ( "openshiftConnector" ) . update ( "disableCheckForMigration" , true , true ) ;
10961112 } else if ( choice === 'Update' ) {
10971113 const errors = [ ] ;
1098- Progress . execFunctionWithProgress ( 'Updating cluster resources to work with latest OpenShift Connector release' , async ( progress ) => {
1114+ await Progress . execFunctionWithProgress ( 'Updating cluster resources to work with latest OpenShift Connector release' , async ( progress ) => {
10991115 for ( const resourceId of [ 'DeploymentConfig' , 'Route' , 'BuildConfig' , 'ImageStream' , 'Service' , 'pvc' , 'Secret' , 'ServiceInstance' ] ) {
11001116 progress . report ( { increment : 100 / 8 , message : resourceId } ) ;
11011117 const cmd = getPreviosOdoResourceNames ( resourceId ) ;
@@ -1113,8 +1129,12 @@ export class OdoImpl implements Odo {
11131129 if ( labels [ 'app.kubernetes.io/component-version' ] ) {
11141130 command = command + ` app.openshift.io/runtime-version=${ labels [ 'app.kubernetes.io/component-version' ] } ` ;
11151131 }
1132+ if ( labels [ 'app.kubernetes.io/url-name' ] ) {
1133+ command = command + ` odo.openshift.io/url-name=${ labels [ 'app.kubernetes.io/url-name' ] } ` ;
1134+ }
11161135 await this . execute ( command ) ;
11171136 await this . execute ( `oc label ${ resourceId } ${ resourceName } app.kubernetes.io/component-name-` ) ;
1137+ await this . execute ( `oc label ${ resourceId } ${ resourceName } odo.openshift.io/migrated=true` ) ;
11181138 } catch ( err ) {
11191139 errors . push ( err ) ;
11201140 }
@@ -1123,7 +1143,7 @@ export class OdoImpl implements Odo {
11231143 this . subject . next ( new OdoEventImpl ( 'changed' , this . getClusters ( ) [ 0 ] ) ) ;
11241144 } ) ;
11251145 if ( errors . length ) {
1126- window . showErrorMessage ( 'Not all resources were updates, please see log for details.' ) ;
1146+ window . showErrorMessage ( 'Not all resources were updates, please see OpenShift output channel for details.' ) ;
11271147 } else {
11281148 window . showInformationMessage ( 'Cluster resources have been successfuly updated.' ) ;
11291149 }
0 commit comments