Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 6de858d

Browse files
oodamienghillert
authored andcommitted
Stream deploy: fix quotes parameters
Resolves #854
1 parent ed467df commit 6de858d

File tree

3 files changed

+57
-12
lines changed

3 files changed

+57
-12
lines changed

ui/src/app/streams/stream-deploy/stream-deploy.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
7575
* @param {NotificationService} notificationService
7676
* @param {BusyService} busyService
7777
* @param {LoggerService} loggerService
78+
* @param {StreamDeployService} streamDeployService
7879
* @param {Router} router
7980
* @param {SharedAboutService} sharedAboutService
8081
*/
@@ -83,6 +84,7 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
8384
private notificationService: NotificationService,
8485
private busyService: BusyService,
8586
private loggerService: LoggerService,
87+
private streamDeployService: StreamDeployService,
8688
private router: Router,
8789
private sharedAboutService: SharedAboutService) {
8890
}
@@ -109,13 +111,11 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
109111
.pipe(map((deploymentInfo) => {
110112
const properties = [];
111113
const ignoreProperties = [];
112-
const cleanValue = (v) => (v && v.length > 1 && v.startsWith('"') && v.endsWith('"'))
113-
? v.substring(1, v.length - 1) : v;
114114

115115
// Deployer properties
116116
Object.keys(deploymentInfo.deploymentProperties).map(app => {
117117
Object.keys(deploymentInfo.deploymentProperties[app]).forEach((key: string) => {
118-
const value = cleanValue(deploymentInfo.deploymentProperties[app][key]);
118+
const value = this.streamDeployService.cleanValueProperties(deploymentInfo.deploymentProperties[app][key]);
119119
if (key === StreamDeployService.version.keyEdit) {
120120
properties.push(`version.${app}=${value}`);
121121
} else if (key.startsWith(StreamDeployService.deployer.keyEdit)) {
@@ -138,7 +138,7 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
138138
const appType = node['name'];
139139
if (node['options']) {
140140
node.options.forEach((value, key) => {
141-
value = cleanValue(value);
141+
value = this.streamDeployService.cleanValueProperties(value);
142142
let keyShort = key;
143143
if (key.startsWith(`${appType}.`)) {
144144
keyShort = key.substring(`${appType}.`.length, key.length);

ui/src/app/streams/stream-deploy/stream-deploy.service.spec.ts

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {SharedAppsService} from '../../shared/services/shared-apps.service';
2-
import {ErrorHandler} from '../../shared/model';
3-
import {StreamsService} from '../streams.service';
4-
import {AppsService} from '../../apps/apps.service';
5-
import {AppsWorkaroundService} from '../../apps/apps.workaround.service';
6-
import {StreamDeployService} from './stream-deploy.service';
7-
import {Observable} from 'rxjs/Observable';
8-
import {HttpUtils} from '../../shared/support/http.utils';
1+
import { SharedAppsService } from '../../shared/services/shared-apps.service';
2+
import { ErrorHandler } from '../../shared/model';
3+
import { StreamsService } from '../streams.service';
4+
import { AppsService } from '../../apps/apps.service';
5+
import { AppsWorkaroundService } from '../../apps/apps.workaround.service';
6+
import { StreamDeployService } from './stream-deploy.service';
7+
import { Observable } from 'rxjs/Observable';
8+
import { HttpUtils } from '../../shared/support/http.utils';
99
import { LoggerService } from '../../shared/services/logger.service';
1010

1111
/**
@@ -76,4 +76,34 @@ describe('StreamDeployService', () => {
7676

7777
});
7878

79+
describe('Clean Value properties', () => {
80+
81+
it('without change', () => {
82+
[
83+
'foo',
84+
'foo bar',
85+
'foo " bar',
86+
'"foo',
87+
'\'foo',
88+
'foo\'',
89+
'foo barr"'
90+
].forEach((mock) => {
91+
expect(this.streamDeployService.cleanValueProperties(mock)).toBe(mock);
92+
});
93+
});
94+
95+
it('with change', () => {
96+
[
97+
['\'foo\'', 'foo'],
98+
['\"foo\"', 'foo'],
99+
['\"foo bar\"', 'foo bar'],
100+
['\"foo \' bar\"', 'foo \' bar'],
101+
['\"foo \" bar\"', 'foo \" bar']
102+
].forEach((mock) => {
103+
expect(this.streamDeployService.cleanValueProperties(mock[0])).toBe(mock[1]);
104+
});
105+
});
106+
107+
});
108+
79109
});

ui/src/app/streams/stream-deploy/stream-deploy.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,19 @@ export class StreamDeployService {
284284
});
285285
}
286286

287+
/**
288+
* Clean value properties
289+
* @param {string} value
290+
* @returns {any}
291+
*/
292+
cleanValueProperties(value:string) {
293+
if ((value && value.length > 1 && value.startsWith('"') && value.endsWith('"'))) {
294+
return value.substring(1, value.length - 1);
295+
}
296+
if ((value && value.length > 1 && value.startsWith("'") && value.endsWith("'"))) {
297+
return value.substring(1, value.length - 1);
298+
}
299+
return value;
300+
}
301+
287302
}

0 commit comments

Comments
 (0)