Skip to content

Commit

Permalink
fix(image-message): adds error message to job output when image doesn…
Browse files Browse the repository at this point in the history
…'t exists
  • Loading branch information
jkuri committed Oct 20, 2017
1 parent 0626eb1 commit f53abf0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/api/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export function createContainer(
.then(container => container.inspect())
.then(info => observer.next({ type: 'containerInfo', data: info }))
.then(() => observer.complete())
.catch(err => observer.error(err));
.catch(err => {
observer.next({ type: 'containerError', data: err });
observer.error(err);
});
});
}

Expand Down
8 changes: 6 additions & 2 deletions src/api/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface SpawnedProcessOutput {
}

export interface ProcessOutput {
type: 'data' | 'exit' | 'container' | 'exposed ports' | 'containerInfo';
type: 'data' | 'exit' | 'container' | 'exposed ports' | 'containerInfo' | 'containerError';
data: any;
}

Expand Down Expand Up @@ -121,7 +121,11 @@ export function startBuildProcess(
return Observable.throw('job timeout');
}))
.subscribe((event: ProcessOutput) => {
if (event.type === 'containerInfo') {
if (event.type === 'containerError') {
const msg = red(event.data.json.message) || red(event.data);
observer.next({ type: 'exit', data: msg });
observer.error(msg);
} else if (event.type === 'containerInfo') {
observer.next({
type: 'exposed ports',
data: { type: 'ports', info: event.data.NetworkSettings.Ports }
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/app-job/app-job.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AppJobComponent implements OnInit, OnDestroy {

this.termSub = this.socketService.outputEvents
.subscribe(event => {
if (event.type === 'data' || event.type === 'exit') {
if (event.type === 'data' || event.type === 'exit' || event.type === 'container') {
if (typeof event.data === 'string') {
this.ngZone.run(() => this.terminalInput = event.data);
}
Expand Down
14 changes: 9 additions & 5 deletions src/app/components/app-terminal/app-terminal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ export class AppTerminalComponent implements OnInit {
}
}

this.commands = this.commands.map((cmd, i) => {
const v = i === this.commands.length - 1 || cmd.visible;
cmd.visible = v ? true : false;
return cmd;
});
if (this.commands && this.commands.length) {
this.commands = this.commands.map((cmd, i) => {
const v = i === this.commands.length - 1 || cmd.visible;
cmd.visible = v ? true : false;
return cmd;
});
} else {
this.commands.push({ command: output, visible: true, time: '.', output: '' });
}
}

setTimeout(() => {
Expand Down

0 comments on commit f53abf0

Please sign in to comment.