Skip to content

Commit

Permalink
Chrisdias/201 (#208)
Browse files Browse the repository at this point in the history
* fixes #201, #207
  • Loading branch information
chrisdias authored Feb 2, 2018
1 parent 0be65aa commit 0b3fb8f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
15 changes: 9 additions & 6 deletions commands/docker-compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ function computeItems(folder: vscode.WorkspaceFolder, uris: vscode.Uri[]): vscod

async function compose(command: string, message: string, dockerComposeFileUri?: vscode.Uri) {
let folder: vscode.WorkspaceFolder;
if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length === 1) {

if (!vscode.workspace.workspaceFolders) {
vscode.window.showErrorMessage('Docker compose can only run if VS Code is opened on a folder.');
return;
}

if (vscode.workspace.workspaceFolders.length === 1) {
folder = vscode.workspace.workspaceFolders[0];
} else {
folder = await (<any>vscode).window.showWorkspaceFolderPick();
}

if (!folder) {
if (!vscode.workspace.workspaceFolders) {
vscode.window.showErrorMessage('Docker compose can only run if VS Code is opened on a folder.');
} else {
vscode.window.showErrorMessage('Docker compose can only run if a workspace folder is picked in VS Code.');
}
return;
}

Expand All @@ -69,6 +70,8 @@ async function compose(command: string, message: string, dockerComposeFileUri?:
const build: string = configOptions.get('dockerComposeBuild', true) ? '--build': '';
const detached: string = configOptions.get('dockerComposeDetached', true) ? '-d' : '';


terminal.sendText(`cd ${folder.uri.fsPath}`);
terminal.sendText(command.toLowerCase() === 'up' ? `docker-compose -f ${selectedItem.file} ${command} ${detached} ${build}` : `docker-compose -f ${selectedItem.file} ${command}`);
terminal.show();
if (reporter) {
Expand Down
17 changes: 11 additions & 6 deletions explorer/models/azureRegistryNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,19 @@ export class AzureRepositoryNode extends NodeBase {
});

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})`, 'azureImageNode');
node = new AzureImageNode(`${element.label}:${tags[i]}`, 'azureImageNode');
node.azureAccount = element.azureAccount;
node.password = element.password;
node.registry = element.registry;
node.serverUrl = element.repository;
node.subscription = element.subscription;
node.userName = element.userName;
node.created = moment(new Date(JSON.parse(manifest.history[0].v1Compatibility).created)).fromNow();
imageNodes.push(node);

}
Expand All @@ -230,17 +230,22 @@ export class AzureImageNode extends NodeBase {
) {
super(label);
}

public azureAccount: AzureAccount
public created: string;
public password: string;
public registry: ContainerModels.Registry;
public serverUrl: string;
public subscription: SubscriptionModels.Subscription;
public userName: string;

getTreeItem(): vscode.TreeItem {
let displayName: string = this.label;

displayName = `${displayName} (${this.created})`;

return {
label: this.label,
label: `${displayName}`,
collapsibleState: vscode.TreeItemCollapsibleState.None,
contextValue: this.contextValue
}
Expand All @@ -249,7 +254,7 @@ export class AzureImageNode extends NodeBase {

export class AzureNotSignedInNode extends NodeBase {
constructor() {
super('Sign in to Azure...');
super('Click here to sign in to Azure...');
}

getTreeItem(): vscode.TreeItem {
Expand Down
12 changes: 8 additions & 4 deletions explorer/models/dockerHubNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ 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++) {
created = moment(new Date(myTags[i].last_updated)).fromNow();
node = new DockerHubImageNode(`${element.repository.name}:${myTags[i].name} (${created})`, 'dockerHubImageTag');
node = new DockerHubImageNode(`${element.repository.name}:${myTags[i].name}`, 'dockerHubImageTag');
node.password = element.password;
node.userName = element.userName;
node.repository = element.repository;
node.created = moment(new Date(myTags[i].last_updated)).fromNow();;
imageNodes.push(node);
}

Expand All @@ -109,10 +108,15 @@ export class DockerHubImageNode extends NodeBase {
public userName: string;
public password: string;
public repository: any;
public created: string;

getTreeItem(): vscode.TreeItem {
let displayName: string = this.label;

displayName = `${displayName} (${this.created})`;

return {
label: this.label,
label: `${displayName}`,
collapsibleState: vscode.TreeItemCollapsibleState.None,
contextValue: this.contextValue
}
Expand Down

0 comments on commit 0b3fb8f

Please sign in to comment.