/
runJobStage.js
61 lines (53 loc) · 2.12 KB
/
runJobStage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
import _ from 'lodash';
import { PIPELINE_CONFIG_SERVICE } from '@spinnaker/core';
import { KUBERNETES_IMAGE_ID_FILTER } from 'kubernetes/presentation/imageId.filter';
const angular = require('angular');
module.exports = angular.module('spinnaker.kubernetes.pipeline.stage.runJobStage', [
require('kubernetes/container/commands.component.js').name,
require('kubernetes/container/arguments.component.js').name,
require('kubernetes/container/environmentVariables.component.js').name,
require('kubernetes/container/volumes.component.js').name,
require('kubernetes/image/image.reader.js').name,
require('./runJobExecutionDetails.controller.js').name,
require('./configureJob.controller.js').name,
PIPELINE_CONFIG_SERVICE,
KUBERNETES_IMAGE_ID_FILTER,
])
.config(function(pipelineConfigProvider) {
pipelineConfigProvider.registerStage({
provides: 'runJob',
cloudProvider: 'kubernetes',
templateUrl: require('./runJobStage.html'),
executionDetailsUrl: require('./runJobExecutionDetails.html'),
producesArtifacts: true,
defaultTimeoutMs: 2 * 60 * 60 * 1000, // 2 hours
validators: [
{ type: 'requiredField', fieldName: 'account' },
{ type: 'requiredField', fieldName: 'namespace' },
]
});
}).controller('kubernetesRunJobStageCtrl', function($scope, $uibModal) {
this.stage = $scope.stage;
this.pipeline = $scope.pipeline;
this.stage.cloudProvider = 'kubernetes';
this.stage.application = $scope.application.name;
if (this.stage.container && !this.stage.containers) {
this.stage.containers = [this.stage.container];
delete this.stage.container;
}
this.configureJob = () => {
return $uibModal.open({
templateUrl: require('./configureJob.html'),
controller: 'kubernetesConfigureJobController as ctrl',
size: 'lg',
resolve: {
stage: () => angular.copy(this.stage),
pipeline: () => this.pipeline,
application: () => $scope.application
}
}).result.then((stage) => {
_.extend(this.stage, stage);
}).catch(() => {});
};
});