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

Commit 95e9a0e

Browse files
cppwfsghillert
authored andcommitted
Allow app and deployment properties to have more than 1 = char
resolves #529
1 parent 6929bfd commit 95e9a0e

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

ui/src/app/streams/stream-definitions/deployment-properties/deployment-properties.component.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,17 @@ describe('DeploymentPropertiesComponent', () => {
7676
expect(submitEvent).toHaveBeenCalled();
7777
});
7878

79+
it('should update the stream definition to deploy with multiple properties and emit event Submit on submit', () => {
80+
component.stream = new StreamDefinition('foo2', 'time |log', 'undeployed');
81+
fixture.detectChanges();
82+
const submitEvent = spyOn(component.submit, 'emit');
83+
component.deploymentProperties.setValue('a=a\nb=c=d\ne=f');
84+
component.deployDefinition();
85+
expect(component.stream.deploymentProperties.a).toBe('a');
86+
expect(component.stream.deploymentProperties.b).toBe('c=d');
87+
expect(component.stream.deploymentProperties.e).toBe('f');
88+
89+
expect(submitEvent).toHaveBeenCalled();
90+
});
91+
7992
});

ui/src/app/streams/stream-definitions/deployment-properties/deployment-properties.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export class DeploymentPropertiesComponent implements OnInit {
5757
if (this.deploymentProperties.value) {
5858
for (const prop of this.deploymentProperties.value.split('\n')) {
5959
if (prop && prop.length > 0 && !prop.startsWith('#')) {
60-
const keyValue = prop.split('=');
61-
if (keyValue.length === 2) {
62-
propertiesAsMap[keyValue[0]] = keyValue[1];
60+
const index = prop.indexOf('=');
61+
if (index > 0) {
62+
propertiesAsMap[prop.substr(0, index)] = prop.substr(index + 1);
6363
}
6464
}
6565
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ import { FormControl } from '@angular/forms';
77
*/
88
export function validateDeploymentProperties(formControl: FormControl) {
99
const properties = formControl.value.split('\n');
10-
let propertiesAsMap = null;
1110

1211
if (properties) {
13-
propertiesAsMap = {};
1412
for (const prop of properties) {
1513
if (prop && prop.length > 0 && !prop.startsWith('#')) {
1614
const keyValue = prop.split('=');
17-
if (keyValue.length === 2) {
18-
propertiesAsMap[keyValue[0]] = keyValue[1];
19-
} else {
15+
if (keyValue.length < 2) {
2016
return {
2117
validateDeploymentProperties: {
2218
reason: `Invalid deployment property "${prop}" must contain a single "=".`

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ describe('StreamDeployComponent', () => {
8080
const de: DebugElement = fixture.debugElement.query(By.css('button[id=deployBtn]'));
8181
const el: HTMLElement = de.nativeElement;
8282
const navigate = spyOn((<any>component).router, 'navigate');
83-
component.deploymentProperties.setValue('app.bar=foo');
83+
component.deploymentProperties.setValue('app.bar=foo\napp.aaa=bbb=ccc\napp.ddd=eee');
8484
el.click();
85+
expect(component.propertiesAsMap['app.bar']).toBe('foo');
86+
expect(component.propertiesAsMap['app.aaa']).toBe('bbb=ccc');
87+
expect(component.propertiesAsMap['app.ddd']).toBe('eee');
8588

8689
expect(navigate).toHaveBeenCalledWith(['streams/definitions']);
8790
expect(toastyService.testSuccess).toContain('Successfully deployed stream definition "1"');

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
2222
private sub: any;
2323
form: FormGroup;
2424
deploymentProperties = new FormControl('', validateDeploymentProperties);
25+
propertiesAsMap = {};
2526

2627
/**
2728
* Adds deployment properties to the FormBuilder
@@ -69,19 +70,19 @@ export class StreamDeployComponent implements OnInit, OnDestroy {
6970
deployDefinition() {
7071
console.log('deployDefinition ' + this.deploymentProperties.value);
7172

72-
const propertiesAsMap = {};
73+
this.propertiesAsMap = {};
7374
if (this.deploymentProperties.value) {
7475
for (const prop of this.deploymentProperties.value.split('\n')) {
7576
if (prop && prop.length > 0 && !prop.startsWith('#')) {
76-
const keyValue = prop.split('=');
77-
if (keyValue.length === 2) {
78-
propertiesAsMap[keyValue[0]] = keyValue[1];
77+
const index = prop.indexOf('=');
78+
if (index > 0) {
79+
this.propertiesAsMap[prop.substr(0, index)] = prop.substr(index + 1);
7980
}
8081
}
8182
}
8283
}
8384

84-
this.streamsService.deployDefinition(this.id, propertiesAsMap).subscribe(
85+
this.streamsService.deployDefinition(this.id, this.propertiesAsMap).subscribe(
8586
data => {
8687
this.toastyService.success('Successfully deployed stream definition "'
8788
+ this.id + '"');

0 commit comments

Comments
 (0)