2018-08-06 14:52:56 +00:00
|
|
|
import {Component, Inject} from 'ng-metadata/core';
|
|
|
|
const templateUrl = require('./kube-deploy-modal.component.html');
|
2018-08-09 20:43:11 +00:00
|
|
|
const styleUrl = require('./kube-deploy-modal.css');
|
2018-08-06 14:52:56 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'kube-deploy-modal',
|
|
|
|
templateUrl,
|
2018-08-09 20:43:11 +00:00
|
|
|
styleUrls: [ styleUrl ],
|
2018-08-06 14:52:56 +00:00
|
|
|
})
|
|
|
|
export class KubeDeployModalComponent {
|
2018-08-09 20:43:11 +00:00
|
|
|
private state
|
|
|
|
: 'loadingDeployments'
|
|
|
|
| 'readyToDeploy'
|
|
|
|
| 'deployingConfiguration'
|
|
|
|
| 'cyclingDeployments'
|
|
|
|
| 'deployed'
|
|
|
|
| 'error';
|
|
|
|
|
|
|
|
private errorMessage: string;
|
|
|
|
|
|
|
|
private deploymentsStatus: { name: string, numPods: number }[] = [];
|
2018-08-06 14:52:56 +00:00
|
|
|
|
|
|
|
constructor(@Inject('ApiService') private ApiService) {
|
2018-08-09 20:43:11 +00:00
|
|
|
this.state = 'loadingDeployments';
|
|
|
|
|
2018-08-06 14:52:56 +00:00
|
|
|
ApiService.scGetNumDeployments().then(resp => {
|
2018-08-09 20:43:11 +00:00
|
|
|
this.deploymentsStatus = resp.items.map(dep => ({ name: dep.metadata.name, numPods: dep.status.replicas }));
|
|
|
|
this.state = 'readyToDeploy';
|
2018-08-06 14:52:56 +00:00
|
|
|
}).catch(err => {
|
2018-08-09 20:43:11 +00:00
|
|
|
this.state = 'error';
|
|
|
|
this.errorMessage = `There are no Quay deployments active in this namespace. \
|
|
|
|
Please check that you are running this \
|
|
|
|
tool in the same namespace as the Quay Enterprise application\
|
|
|
|
Associated error message: ${err.toString()}`;
|
2018-08-06 14:52:56 +00:00
|
|
|
})
|
|
|
|
}
|
2018-08-08 18:22:28 +00:00
|
|
|
|
|
|
|
deployConfiguration(): void {
|
2018-08-09 20:43:11 +00:00
|
|
|
this.ApiService.scDeployConfiguration().then(() => {
|
|
|
|
const deploymentNames: string[]= this.deploymentsStatus.map(dep => dep.name);
|
|
|
|
|
|
|
|
this.ApiService.scCycleQEDeployments({ deploymentNames }).then(() => {
|
|
|
|
this.state = 'deployed'
|
2018-08-08 18:22:28 +00:00
|
|
|
}).catch(err => {
|
2018-08-09 20:43:11 +00:00
|
|
|
this.state = 'error';
|
|
|
|
this.errorMessage = `Could cycle the deployments with the new configuration. Error: ${err.toString()}`;
|
2018-08-08 18:22:28 +00:00
|
|
|
})
|
|
|
|
}).catch(err => {
|
2018-08-09 20:43:11 +00:00
|
|
|
this.state = 'error';
|
|
|
|
this.errorMessage = `Could not deploy the configuration. Error: ${err.toString()}`;
|
2018-08-08 18:22:28 +00:00
|
|
|
})
|
|
|
|
}
|
2018-08-06 14:52:56 +00:00
|
|
|
}
|