提交 589bd53b 编写于 作者: H higashi

Fix to parse containerImage to get version

上级 b3b7701c
......@@ -347,10 +347,19 @@ export default class DeployFromSettingsController {
*/
getContainerImageVersion_() {
/** @type {number} */
let index = (this.containerImage || '').lastIndexOf(':');
let index = (this.containerImage || '').lastIndexOf('/');
let imagename;
if (index > -1) {
return this.containerImage.substring(index + 1);
imagename = this.containerImage.substring(index + 1);
} else {
imagename = this.containerImage;
}
index = (imagename || '').lastIndexOf(':');
if (index > -1) {
return imagename.substring(index + 1);
}
return '';
......
......@@ -100,6 +100,29 @@ describe('DeployFromSettings controller', () => {
expect(result).toEqual('1');
});
it('should return part of the string after `:` delimiter', () => {
// given
ctrl.containerImage = 'private.registry:5000/test:1';
// when
let result = ctrl.getContainerImageVersion_();
// then
expect(result).toEqual('1');
});
it('should return empty string when containerImage is not empty and does not containe `:`' +
' delimiter after `/` delimiter', () => {
// given
ctrl.containerImage = 'private.registry:5000/test';
// when
let result = ctrl.getContainerImageVersion_();
// then
expect(result).toEqual('');
});
it('should return empty array when labels array is empty', () => {
// given
let labels = [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册