Skip to content

Commit 5917478

Browse files
msivasubramaniaanvrubezhny
authored andcommitted
added --show-multiarch=true param and latest tag
1 parent 351abd5 commit 5917478

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/deployment.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { KubernetesObject } from '@kubernetes/client-node';
77
import * as path from 'path';
88
import validator from 'validator';
9-
import { Disposable, QuickInputButtons, ThemeIcon, TreeItem, window } from 'vscode';
9+
import { Disposable, InputBox, QuickInputButtons, ThemeIcon, TreeItem, window } from 'vscode';
1010
import { CommandText } from './base/command';
1111
import { DeploymentPodObject, OpenShiftExplorer } from './explorer';
1212
import { 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
*

src/oc/ocWrapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,9 @@ export class Oc {
676676
}
677677

678678
public async hasImageInfo(url: string): Promise<boolean> {
679+
const imageURL = url.lastIndexOf(':') < 0 ? `${url}:latest` : url;
679680
const result = await CliChannel.getInstance().executeTool(
680-
new CommandText('oc', `image info ${url}`), undefined, false
681+
new CommandText('oc', `image info ${imageURL} --show-multiarch=true`), undefined, false
681682
);
682683
return result.error && result.stderr.length > 0 ? false : true;
683684
}

0 commit comments

Comments
 (0)