@@ -55,7 +55,8 @@ angular.module('openshiftConsole')
55
55
"title" : "Inline"
56
56
} ] ;
57
57
$scope . view = {
58
- advancedOptions : false
58
+ advancedOptions : false ,
59
+ hasHooks : false
59
60
} ;
60
61
$scope . breadcrumbs = [
61
62
{
@@ -117,6 +118,79 @@ angular.module('openshiftConsole')
117
118
"SerialLatestOnly"
118
119
] ;
119
120
121
+ $scope . buildHookTypes = [ {
122
+ id : "command" ,
123
+ label : "Command"
124
+ } , {
125
+ id : "script" ,
126
+ label : "Shell Script"
127
+ } , {
128
+ id : "args" ,
129
+ label : "Arguments to default image entry point"
130
+ } , {
131
+ id : "commandArgs" ,
132
+ label : "Command with arguments"
133
+ } , {
134
+ id : "scriptArgs" ,
135
+ label : "Shell script with arguments"
136
+ } ] ;
137
+
138
+ $scope . buildHookSelection = {
139
+ type : { }
140
+ } ;
141
+
142
+ var getInitialBuildHookSelection = function ( ) {
143
+ var hasArgs = ! _ . isEmpty ( _ . get ( $scope , 'buildConfig.spec.postCommit.args' ) ) ;
144
+ var hasCommand = ! _ . isEmpty ( _ . get ( $scope , 'buildConfig.spec.postCommit.command' ) ) ;
145
+ var hasScript = ! ! _ . get ( $scope , 'buildConfig.spec.postCommit.script' ) ;
146
+ $scope . view . hasHooks = hasArgs || hasCommand || hasScript ;
147
+
148
+ var id ;
149
+
150
+ if ( hasArgs && hasCommand ) {
151
+ id = 'commandArgs' ;
152
+ } else if ( hasArgs && hasScript ) {
153
+ id = 'scriptArgs' ;
154
+ } else if ( hasArgs ) {
155
+ id = 'args' ;
156
+ } else if ( hasScript ) {
157
+ id = 'script' ;
158
+ } else {
159
+ id = 'command' ;
160
+ }
161
+
162
+ $scope . buildHookSelection . type = _ . find ( $scope . buildHookTypes , { id : id } ) ;
163
+ } ;
164
+
165
+ var clearIncompatibleBuildHookFields = function ( ) {
166
+ if ( ! $scope . view . hasHooks ) {
167
+ delete $scope . updatedBuildConfig . spec . postCommit . command ;
168
+ delete $scope . updatedBuildConfig . spec . postCommit . args ;
169
+ delete $scope . updatedBuildConfig . spec . postCommit . script ;
170
+ } else {
171
+ switch ( $scope . buildHookSelection . type . id ) {
172
+ case "script" :
173
+ delete $scope . updatedBuildConfig . spec . postCommit . command ;
174
+ delete $scope . updatedBuildConfig . spec . postCommit . args ;
175
+ break ;
176
+ case "command" :
177
+ delete $scope . updatedBuildConfig . spec . postCommit . script ;
178
+ delete $scope . updatedBuildConfig . spec . postCommit . args ;
179
+ break ;
180
+ case "args" :
181
+ delete $scope . updatedBuildConfig . spec . postCommit . script ;
182
+ delete $scope . updatedBuildConfig . spec . postCommit . command ;
183
+ break ;
184
+ case "scriptArgs" :
185
+ delete $scope . updatedBuildConfig . spec . postCommit . command ;
186
+ break ;
187
+ case "commandArgs" :
188
+ delete $scope . updatedBuildConfig . spec . postCommit . script ;
189
+ break ;
190
+ }
191
+ }
192
+ } ;
193
+
120
194
AlertMessageService . getAlerts ( ) . forEach ( function ( alert ) {
121
195
$scope . alerts [ alert . name ] = alert . data ;
122
196
} ) ;
@@ -143,6 +217,8 @@ angular.module('openshiftConsole')
143
217
// success
144
218
function ( buildConfig ) {
145
219
$scope . buildConfig = buildConfig ;
220
+ getInitialBuildHookSelection ( ) ;
221
+
146
222
$scope . updatedBuildConfig = angular . copy ( $scope . buildConfig ) ;
147
223
$scope . buildStrategy = buildStrategy ( $scope . updatedBuildConfig ) ;
148
224
$scope . strategyType = $scope . buildConfig . spec . strategy . type ;
@@ -180,7 +256,7 @@ angular.module('openshiftConsole')
180
256
}
181
257
182
258
if ( imageOptions . type === "ImageStreamImage" ) {
183
- isimage = ( imageData . namespace || buildConfig . metadata . namespace ) + "/" + imageData . name ;
259
+ isimage = ( imageData . namespace || buildConfig . metadata . namespace ) + "/" + imageData . name ;
184
260
} else {
185
261
isimage = "" ;
186
262
}
@@ -414,6 +490,7 @@ angular.module('openshiftConsole')
414
490
415
491
$scope . save = function ( ) {
416
492
$scope . disableInputs = true ;
493
+ clearIncompatibleBuildHookFields ( ) ;
417
494
// Update Configuration
418
495
buildStrategy ( $scope . updatedBuildConfig ) . forcePull = $scope . options . forcePull ;
419
496
0 commit comments