4
4
5
5
/* eslint-disable import/no-dynamic-require */
6
6
const config = require ( 'config' ) ;
7
- const server = require ( '../' ) ;
8
7
const hoek = require ( '@hapi/hoek' ) ;
9
8
const { Bookend } = require ( 'screwdriver-build-bookend' ) ;
10
9
const logger = require ( 'screwdriver-logger' ) ;
@@ -53,19 +52,21 @@ const multiBuildClusterEnabled = convertToBool(config.get('multiBuildCluster').e
53
52
54
53
// Default cluster environment variable
55
54
const clusterEnvConfig = config . get ( 'build' ) . environment ; // readonly
56
- const clusterEnv = Object . assign ( { } , clusterEnvConfig ) ;
55
+ const clusterEnv = { ... clusterEnvConfig } ;
57
56
58
- Object . keys ( clusterEnv ) . forEach ( ( k ) => {
57
+ Object . keys ( clusterEnv ) . forEach ( k => {
59
58
clusterEnv [ k ] = String ( clusterEnv [ k ] ) ;
60
59
} ) ;
61
60
62
- const externalJoin = config . get ( 'build' ) . externalJoin ; // flag to allow external join
61
+ const { externalJoin } = config . get ( 'build' ) ; // flag to allow external join
62
+
63
+ const notificationsValidationErr = hoek . reach ( config . get ( 'notifications' ) . options , 'throwValidationErr' ) ; // flag to throw notifications validation err or not
63
64
64
65
// Setup Datastore
65
66
const datastoreConfig = config . get ( 'datastore' ) ;
66
67
const DatastorePlugin = require ( `screwdriver-datastore-${ datastoreConfig . plugin } ` ) ;
67
68
68
- const datastorePluginConfig = Object . assign ( { } , datastoreConfig [ datastoreConfig . plugin ] ) ;
69
+ const datastorePluginConfig = { ... datastoreConfig [ datastoreConfig . plugin ] } ;
69
70
70
71
// Readonly Datastore
71
72
const datastoreROConfig = datastorePluginConfig . readOnly ;
@@ -77,8 +78,7 @@ if (datastoreROConfig && Object.keys(datastoreROConfig).length > 0) {
77
78
delete datastorePluginConfig . readOnly ;
78
79
79
80
// Default datastore
80
- const datastore = new DatastorePlugin ( hoek . applyToDefaults ( { ecosystem } ,
81
- ( datastorePluginConfig || { } ) ) ) ;
81
+ const datastore = new DatastorePlugin ( hoek . applyToDefaults ( { ecosystem } , datastorePluginConfig || { } ) ) ;
82
82
83
83
// Source Code Plugin
84
84
const scmConfig = { scms : config . get ( 'scms' ) } ;
@@ -102,22 +102,25 @@ const coverage = new CoveragePlugin(coverageConfig);
102
102
103
103
// Plugins to run before/after a build
104
104
const bookends = config . get ( 'bookends' ) ;
105
- const bookend = new Bookend ( {
106
- scm,
107
- 'screwdriver-artifact-bookend' : artifact ,
108
- 'screwdriver-coverage-bookend' : coverage ,
109
- 'screwdriver-cache-bookend' : cache
110
- } ,
105
+ const bookend = new Bookend (
106
+ {
107
+ scm,
108
+ 'screwdriver-artifact-bookend' : artifact ,
109
+ 'screwdriver-coverage-bookend' : coverage ,
110
+ 'screwdriver-cache-bookend' : cache
111
+ } ,
111
112
bookends . setup || [ ] , // plugins required for the setup- steps
112
113
bookends . teardown || [ ] // plugins required for the teardown-steps
113
114
) ;
114
115
115
116
// Setup Pipeline Factory for Executor
116
117
const Models = require ( 'screwdriver-models' ) ;
118
+ const server = require ( '..' ) ;
117
119
const pipelineFactory = Models . PipelineFactory . getInstance ( {
118
120
datastore,
119
121
scm,
120
122
externalJoin,
123
+ notificationsValidationErr,
121
124
multiBuildClusterEnabled
122
125
} ) ;
123
126
@@ -126,10 +129,10 @@ const executorConfig = config.get('executor');
126
129
127
130
executorConfig [ executorConfig . plugin ] . options . pipelineFactory = pipelineFactory ;
128
131
const ExecutorPlugin = require ( `screwdriver-executor-${ executorConfig . plugin } ` ) ;
129
- const executor = new ExecutorPlugin ( Object . assign (
130
- { ecosystem : hoek . clone ( ecosystem ) } ,
131
- executorConfig [ executorConfig . plugin ] . options
132
- ) ) ;
132
+ const executor = new ExecutorPlugin ( {
133
+ ecosystem : hoek . clone ( ecosystem ) ,
134
+ ... executorConfig [ executorConfig . plugin ] . options
135
+ } ) ;
133
136
134
137
// Setup Model Factories
135
138
const commandFactory = Models . CommandFactory . getInstance ( {
@@ -210,8 +213,8 @@ const buildClusterFactory = Models.BuildClusterFactory.getInstance({
210
213
211
214
// @TODO run setup for SCM and Executor
212
215
// datastoreConfig.ddlSync => sync datastore schema (ddl) via api (default: true)
213
- datastore . setup ( datastoreConfig . ddlSyncEnabled )
214
- . then ( ( ) => server ( {
216
+ datastore . setup ( datastoreConfig . ddlSyncEnabled ) . then ( ( ) =>
217
+ server ( {
215
218
httpd : httpdConfig ,
216
219
auth : authConfig ,
217
220
webhooks : webhooksConfig ,
@@ -242,12 +245,18 @@ datastore.setup(datastoreConfig.ddlSyncEnabled)
242
245
externalJoin
243
246
} ,
244
247
stats : {
245
- executor, scm
248
+ executor,
249
+ scm
246
250
} ,
247
- release
248
- } ) )
249
- . then ( instance => logger . info ( 'Server running at %s' , instance . info . uri ) )
250
- . catch ( ( err ) => {
251
- logger . error ( err ) ;
252
- process . exit ( 1 ) ;
253
- } ) ;
251
+ release,
252
+ validator : {
253
+ externalJoin,
254
+ notificationsValidationErr
255
+ }
256
+ } )
257
+ . then ( instance => logger . info ( 'Server running at %s' , instance . info . uri ) )
258
+ . catch ( err => {
259
+ logger . error ( err ) ;
260
+ process . exit ( 1 ) ;
261
+ } )
262
+ ) ;
0 commit comments