66import { KubernetesObject } from '@kubernetes/client-node' ;
77import * as path from 'path' ;
88import validator from 'validator' ;
9- import { Disposable , QuickInputButtons , ThemeIcon , TreeItem , window } from 'vscode' ;
9+ import { Disposable , InputBox , QuickInputButtons , ThemeIcon , TreeItem , window } from 'vscode' ;
1010import { CommandText } from './base/command' ;
1111import { DeploymentPodObject , OpenShiftExplorer } from './explorer' ;
1212import { Oc } from './oc/ocWrapper' ;
@@ -164,35 +164,24 @@ export class Deployment {
164164
165165 disposables . push ( inputBox . onDidAccept ( async ( _e ) => {
166166 //check url has image
167- if ( inputBox . validationMessage === undefined && inputBox . value !== undefined ) {
168- inputBox . busy = true ;
169- inputBox . enabled = false ;
170- await Progress . execFunctionWithProgress ( `Fetching Image info ${ inputBox . value } ` , async ( ) => {
171- if ( ! await Oc . Instance . hasImageInfo ( inputBox . value ) ) {
172- inputBox . validationMessage = 'Image referece is not valid'
173- } else {
174- inputBox . validationMessage = undefined ;
175- }
176- } ) ;
177- inputBox . enabled = true ;
178- inputBox . busy = false ;
179- }
180-
167+ await Deployment . validateImageInfo ( inputBox ) ;
181168 if ( inputBox . validationMessage === undefined && inputBox . value !== undefined ) {
182169 resolve ( inputBox . value ) ;
183170 inputBox . hide ( ) ;
184171 disposables . forEach ( disposable => { disposable . dispose ( ) } ) ;
185172 }
186173 } ) ) ;
187174
188- disposables . push ( inputBox . onDidTriggerButton ( ( button ) => {
175+ disposables . push ( inputBox . onDidTriggerButton ( async ( button ) => {
189176 if ( button === QuickInputButtons . Back ) {
190177 inputBox . hide ( ) ;
191178 resolve ( undefined ) ;
192179 } else if ( button === cancelBtn ) {
193180 inputBox . hide ( ) ;
194181 resolve ( null ) ;
195182 } else if ( button === okBtn ) {
183+ //check url has image
184+ await Deployment . validateImageInfo ( inputBox ) ;
196185 if ( inputBox . validationMessage === undefined && inputBox . value !== undefined ) {
197186 inputBox . hide ( ) ;
198187 resolve ( inputBox . value ) ;
@@ -205,6 +194,22 @@ export class Deployment {
205194 } ) ;
206195 }
207196
197+ private static async validateImageInfo ( inputBox : InputBox ) : Promise < void > {
198+ if ( inputBox . validationMessage === undefined && inputBox . value !== undefined ) {
199+ inputBox . busy = true ;
200+ inputBox . enabled = false ;
201+ await Progress . execFunctionWithProgress ( `Fetching Image info ${ inputBox . value } ` , async ( ) => {
202+ if ( ! await Oc . Instance . hasImageInfo ( inputBox . value ) ) {
203+ inputBox . validationMessage = 'Image referece is not valid' ;
204+ } else {
205+ inputBox . validationMessage = undefined ;
206+ }
207+ } ) ;
208+ inputBox . enabled = true ;
209+ inputBox . busy = false ;
210+ }
211+ }
212+
208213 /**
209214 * Prompt the user for the name of the deployment.
210215 *
0 commit comments