@@ -58,6 +58,11 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
58
58
*/
59
59
properties : Array < string > = [ ] ;
60
60
61
+ /**
62
+ * Original properties Array
63
+ */
64
+ ignoreProperties : Array < string > = [ ] ;
65
+
61
66
/**
62
67
* Constructor
63
68
*
@@ -96,6 +101,7 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
96
101
val => this . streamsService . getDeploymentInfo ( val . id ) ,
97
102
( config : any , deploymentInfo : StreamDefinition ) => {
98
103
const properties = [ ] ;
104
+ const ignoreProperties = [ ] ;
99
105
100
106
// Deployer properties
101
107
Object . keys ( deploymentInfo . deploymentProperties ) . map ( app => {
@@ -128,11 +134,14 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
128
134
keyShort = key . substring ( `${ appType } .` . length , key . length ) ;
129
135
}
130
136
properties . push ( `app.${ app } .${ keyShort } =${ value } ` ) ;
137
+ ignoreProperties . push ( `app.${ app } .${ keyShort } =${ value } ` ) ;
131
138
} ) ;
132
139
}
133
140
} ) ;
134
-
135
141
this . properties = properties ;
142
+ if ( ! config . skipper ) {
143
+ this . ignoreProperties = ignoreProperties ;
144
+ }
136
145
config . streamDefinition = deploymentInfo ;
137
146
return config ;
138
147
}
@@ -181,35 +190,55 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
181
190
this . update ( value ) ;
182
191
const propertiesMap = { } ;
183
192
value . forEach ( ( val ) => {
184
- const arr = val . split ( / = ( .* ) / ) ;
185
- if ( arr . length !== 3 ) {
186
- console . error ( 'Split line property' , val ) ;
187
- } else {
188
- // Workaround sensitive property: ignored property
189
- if ( arr [ 1 ] === `'******'` ) {
190
- console . log ( `Sensitive property ${ arr [ 0 ] } is ignored` ) ;
193
+ if ( this . ignoreProperties . indexOf ( val ) === - 1 ) {
194
+ const arr = val . split ( / = ( .* ) / ) ;
195
+ if ( arr . length !== 3 ) {
196
+ console . error ( 'Split line property' , val ) ;
191
197
} else {
192
- propertiesMap [ arr [ 0 ] ] = arr [ 1 ] ;
198
+ // Workaround sensitive property: ignored property
199
+ if ( arr [ 1 ] === `'******'` ) {
200
+ console . log ( `Sensitive property ${ arr [ 0 ] } is ignored` ) ;
201
+ } else {
202
+ propertiesMap [ arr [ 0 ] ] = arr [ 1 ] ;
203
+ }
193
204
}
194
205
}
195
206
} ) ;
196
207
197
208
let obs = Observable . of ( { } ) ;
198
- if ( [ 'deployed' , 'deploying' ] . indexOf ( this . refConfig . streamDefinition . status ) > - 1 ) {
199
- obs = this . streamsService . undeployDefinition ( this . refConfig . streamDefinition ) ;
200
- }
201
- const busy = obs . pipe ( mergeMap (
209
+ const isDeployed = ( [ 'deployed' , 'deploying' ] . indexOf ( this . refConfig . streamDefinition . status ) > - 1 ) ;
210
+ const update = this . refConfig . skipper && isDeployed ;
211
+
212
+ if ( update ) {
213
+ obs = obs . pipe ( mergeMap (
214
+ val => this . streamsService . updateDefinition ( this . refConfig . id , propertiesMap ) ,
215
+ ( val1 , val2 ) => val2
216
+ ) ) ;
217
+ } else {
218
+ if ( isDeployed ) {
219
+ obs = obs . pipe ( mergeMap (
220
+ val => this . streamsService . undeployDefinition ( this . refConfig . streamDefinition ) ,
221
+ ( val1 , val2 ) => val2
222
+ ) ) ;
223
+ }
224
+ obs = obs . pipe ( mergeMap (
202
225
val => this . streamsService . deployDefinition ( this . refConfig . id , propertiesMap ) ,
203
226
( val1 , val2 ) => val2
204
- ) )
205
- . pipe ( takeUntil ( this . ngUnsubscribe$ ) )
206
- . subscribe (
207
- data => {
208
- this . toastyService . success ( `Successfully deployed stream definition "${ this . refConfig . id } "` ) ;
227
+ ) ) ;
228
+ }
229
+
230
+ const busy = obs . pipe ( takeUntil ( this . ngUnsubscribe$ ) )
231
+ . subscribe ( data => {
232
+ if ( update ) {
233
+ this . toastyService . success ( `Successfully update stream definition "${ this . refConfig . id } "` ) ;
234
+ } else {
235
+ this . toastyService . success ( `Successfully deployed stream definition "${ this . refConfig . id } "` ) ;
236
+ }
209
237
this . router . navigate ( [ 'streams' ] ) ;
210
238
} ,
211
239
error => {
212
- this . toastyService . error ( `${ error . message ? error . message : error . toString ( ) } ` ) ;
240
+ const err = error . message ? error . message : error . toString ( ) ;
241
+ this . toastyService . error ( err ? err : 'An error occurred during the stream deployment update.' ) ;
213
242
}
214
243
) ;
215
244
0 commit comments