vscode-docker/commands/push-image.ts

52 строки
1.7 KiB
TypeScript
Исходник Обычный вид История

2016-09-16 00:49:32 +03:00
import vscode = require('vscode');
2017-03-02 04:49:54 +03:00
import { ImageItem, quickPickImage } from './utils/quick-pick-image';
import { reporter } from '../telemetry/telemetry';
import { ImageNode } from '../explorer/models/imageNode';
import { createTerminal } from './utils/create-terminal';
2017-03-04 04:13:14 +03:00
const teleCmdId: string = 'vscode-docker.image.push';
2018-03-20 08:23:37 +03:00
const teleAzureId: string = 'vscode-docker.image.push.azureContainerRegistry';
2016-09-16 00:49:32 +03:00
export async function pushImage(context?: ImageNode) {
let imageToPush: Docker.ImageDesc;
let imageName: string = "";
2017-06-06 03:55:05 +03:00
if (context && context.imageDesc) {
imageToPush = context.imageDesc;
imageName = context.label;
} else {
const selectedItem: ImageItem = await quickPickImage();
if (selectedItem) {
imageToPush = selectedItem.imageDesc;
imageName = selectedItem.label;
}
}
if (imageToPush) {
const terminal = createTerminal(imageName);
terminal.sendText(`docker push ${imageName}`);
2017-06-06 03:55:05 +03:00
terminal.show();
if (reporter) {
/* __GDPR__
"command" : {
"command" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
2017-06-06 03:55:05 +03:00
reporter.sendTelemetryEvent('command', {
command: teleCmdId
});
2018-03-20 08:23:37 +03:00
if (imageName.toLowerCase().indexOf('azurecr.io')) {
/* __GDPR__
"command" : {
"command" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
reporter.sendTelemetryEvent('command', {
2018-03-20 08:23:37 +03:00
command: teleAzureId
});
}
2017-06-06 03:55:05 +03:00
}
}
2018-07-07 02:49:46 +03:00
}