show imaged creation date in registry

This commit is contained in:
chrisdias 2017-12-02 17:23:58 +01:00
Родитель cecd8a2a14
Коммит 8ef4ff474d
4 изменённых файлов: 47 добавлений и 18 удалений

Просмотреть файл

@ -1,7 +1,7 @@
import * as vscode from 'vscode';
import * as path from 'path';
import request = require('request-promise');
import * as moment from 'moment';
import * as request from 'request-promise';
import { NodeBase } from './nodeBase';
import { SubscriptionClient, ResourceManagementClient, SubscriptionModels } from 'azure-arm-resource';
@ -43,7 +43,7 @@ export class AzureRegistryNode extends NodeBase {
if (!this._azureAccount) {
return [];
}
const session: AzureSession = this._azureAccount.sessions.find((s, i, array) => s.tenantId.toLowerCase() === tenantId.toLowerCase());
const { accessToken, refreshToken } = await acquireToken(session);
@ -139,13 +139,15 @@ export class AzureRepositoryNode extends NodeBase {
async getChildren(element: AzureRepositoryNode): Promise<AzureImageNode[]> {
const imageNodes: AzureImageNode[] = [];
let node: AzureImageNode;
let created: string = '';
let refreshTokenARC;
let accessTokenARC;
let tags;
const { accessToken, refreshToken } = await acquireToken(element.subscription.session);
if (accessToken && refreshToken) {
const tenantId = element.subscription.tenantId;
let refreshTokenARC;
let accessTokenARC;
await request.post('https://' + element.repository + '/oauth2/exchange', {
form: {
@ -185,16 +187,25 @@ export class AzureRepositoryNode extends NodeBase {
}, (err, httpResponse, body) => {
if (err) { return []; }
if (body.length > 0) {
const tags = JSON.parse(body).tags;
for (let i = 0; i < tags.length; i++) {
node = new AzureImageNode(element.label + ':' + tags[i], 'azureImageTag');
node.serverUrl = element.repository;
node.userName = element.userName;
node.password = element.password;
imageNodes.push(node);
}
tags = JSON.parse(body).tags;
}
});
for (let i = 0; i < tags.length; i++) {
created = '';
let manifest = JSON.parse(await request.get('https://' + element.repository + '/v2/' + element.label + '/manifests/latest', {
auth: { bearer: accessTokenARC }
}));
created = moment(new Date(JSON.parse(manifest.history[0].v1Compatibility).created)).fromNow();
node = new AzureImageNode(`${element.label}:${tags[i]} (${created})`, 'azureImageTag');
node.serverUrl = element.repository;
node.userName = element.userName;
node.password = element.password;
imageNodes.push(node);
}
}
return imageNodes;
}

Просмотреть файл

@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import * as path from 'path';
import * as moment from 'moment';
import * as dockerHub from './dockerHubUtils';
import { NodeBase } from './nodeBase';
@ -78,10 +79,12 @@ export class DockerHubRepositoryNode extends NodeBase {
async getChildren(element: DockerHubRepositoryNode): Promise<DockerHubImageNode[]> {
const imageNodes: DockerHubImageNode[] = [];
let node: DockerHubImageNode;
let created: string = '';
const myTags: dockerHub.Tag[] = await dockerHub.getRepositoryTags({namespace: element.repository.namespace, name: element.repository.name});
for (let i = 0; i < myTags.length; i++) {
node = new DockerHubImageNode(`${element.repository.name}:${myTags[i].name}`, 'dockerHubImageTag');
created = moment(new Date(myTags[i].last_updated)).fromNow();
node = new DockerHubImageNode(`${element.repository.name}:${myTags[i].name} (${created})`, 'dockerHubImageTag');
node.password = element.password;
node.userName = element.userName;
node.repository = element.repository;

22
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "vscode-docker",
"version": "0.0.22",
"version": "0.0.23",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1904,9 +1904,9 @@
}
},
"moment": {
"version": "2.18.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz",
"integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8="
"version": "2.19.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.19.3.tgz",
"integrity": "sha1-vbmdJw1tf9p4zA+6zoVeJ/59pp8="
},
"ms": {
"version": "2.0.0",
@ -1929,6 +1929,13 @@
"through": "2.3.8",
"tunnel": "0.0.5",
"uuid": "3.1.0"
},
"dependencies": {
"moment": {
"version": "2.18.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz",
"integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8="
}
}
},
"ms-rest-azure": {
@ -1943,6 +1950,13 @@
"moment": "2.18.1",
"ms-rest": "2.2.7",
"uuid": "3.1.0"
},
"dependencies": {
"moment": {
"version": "2.18.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz",
"integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8="
}
}
},
"multimatch": {

Просмотреть файл

@ -540,6 +540,7 @@
"azure-arm-website": "^1.0.0-preview",
"dockerfile-language-server-nodejs": "^0.0.11",
"dockerode": "^2.5.1",
"moment": "^2.19.3",
"opn": "^5.1.0",
"request-promise": "^4.2.2",
"vscode-extension-telemetry": "^0.0.6",