import { BuildService } from './build.service';
import { Injectable } from 'ng-metadata/core';
@Injectable(BuildService.name)
export class BuildServiceImpl implements BuildService {
private inactivePhases: string[] = ['complete', 'error', 'expired', 'cancelled'];
public isActive(build: {phase: string}): boolean {
return this.inactivePhases.indexOf(build.phase) == -1;
}
public getBuildMessage(phase: string): string {
var message: string;
switch (phase) {
case null:
case undefined:
message = '';
break;
case 'cannot_load':
message = 'Cannot load build status';
case 'starting':
case 'initializing':
message = 'Starting Dockerfile build';
case 'waiting':
message = 'Waiting for available build worker';
case 'unpacking':
message = 'Unpacking build package';
case 'pulling':
message = 'Pulling base image';
case 'building':
message = 'Building image from Dockerfile';
case 'checking-cache':
message = 'Looking up cached images';
case 'priming-cache':
message = 'Priming cache for build';
case 'build-scheduled':
message = 'Preparing build node';
case 'pushing':
message = 'Pushing image built from Dockerfile';
case 'complete':
message = 'Dockerfile build completed and pushed';
case 'error':
message = 'Dockerfile build failed';
case 'expired':
message = 'Build did not complete after 3 attempts. Re-submit this build to try again.';
case 'internalerror':
message = 'An internal system error occurred while building; the build will be retried in the next few minutes.';
case 'cancelled':
message = 'This build was previously cancelled.';
default:
throw new Error(`Invalid build phase: ${phase.toString()}`);
return message;