Skip to content

Commit cc6e1ce

Browse files
committed
patch(feat): octo deprecated Support model.
- The Support model is similar to Server, and hence not needed.
1 parent 8bb5e65 commit cc6e1ce

File tree

15 files changed

+134
-335
lines changed

15 files changed

+134
-335
lines changed

packages/octo/src/app.type.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export type ResourceSerializedOutput = {
3434
sharedResources: { [p: string]: { className: string; resource: IResource } };
3535
};
3636

37-
export type SupportApplicationType = 'nginx';
38-
3937
export type TransactionOptions = {
4038
yieldModelTransaction?: boolean;
4139
yieldNewResources?: boolean;

packages/octo/src/functions/diff/diff.utility.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ describe('Diff Utility UT', () => {
4343
expect(DiffUtility.isObjectDeepEquals([{ a: 1 }, { b: 2 }], [{ a: 1 }, { b: 3 }])).toEqual(false);
4444
});
4545

46-
it('should return true when array of booleans and undefined are equal', () => {
46+
it('should return true when array of boolean and undefined are equal', () => {
4747
expect(DiffUtility.isObjectDeepEquals([undefined, false], [undefined, false])).toEqual(true);
4848
});
4949

50-
it('should return false when array of booleans and undefined are not equal', () => {
50+
it('should return false when array of boolean and undefined are not equal', () => {
5151
expect(DiffUtility.isObjectDeepEquals([undefined, false], [null, true])).toEqual(false);
5252
});
5353
});

packages/octo/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export { IService } from './models/service/service.interface.js';
3333
export { Service } from './models/service/service.model.js';
3434
export { ISubnet } from './models/subnet/subnet.interface.js';
3535
export { Subnet, SubnetType } from './models/subnet/subnet.model.js';
36-
export { ISupport } from './models/support/support.interface.js';
37-
export { Support } from './models/support/support.model.js';
3836

3937
export { AModel } from './models/model.abstract.js';
4038
export { IModel, IModelReference } from './models/model.interface.js';

packages/octo/src/models/app/app.model.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Pipeline } from '../pipeline/pipeline.model.js';
88
import { Region } from '../region/region.model.js';
99
import { Server } from '../server/server.model.js';
1010
import { Service } from '../service/service.model.js';
11-
import { Support } from '../support/support.model.js';
1211
import { IApp } from './app.interface.js';
1312

1413
@Model()
@@ -82,18 +81,6 @@ export class App extends AModel<IApp, App> {
8281
this.addChild('name', service, 'serviceId');
8382
}
8483

85-
addSupport(support: Support): void {
86-
const childrenDependencies = this.getChildren('support');
87-
if (!childrenDependencies['support']) childrenDependencies['support'] = [];
88-
89-
// Check for duplicates.
90-
const supports = childrenDependencies['support'].map((d) => d.to);
91-
if (supports.find((s: Support) => s.serverKey === support.serverKey)) {
92-
throw new Error('Support already exists!');
93-
}
94-
this.addChild('name', support, 'serverKey');
95-
}
96-
9784
getContext(): string {
9885
return `${this.MODEL_NAME}=${this.name}`;
9986
}

packages/octo/src/models/execution/execution.model.spec.ts

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { ModelSerializationService } from '../../services/serialization/model/mo
33
import { App } from '../app/app.model.js';
44
import { Deployment } from '../deployment/deployment.model.js';
55
import { Environment } from '../environment/environment.model.js';
6-
import { Image } from '../image/image.model.js';
76
import { Region } from '../region/region.model.js';
8-
import { Support } from '../support/support.model.js';
7+
import { Server } from '../server/server.model.js';
98
import { Execution } from './execution.model.js';
109

1110
describe('Execution UT', () => {
@@ -16,43 +15,39 @@ describe('Execution UT', () => {
1615
});
1716

1817
describe('diff()', () => {
19-
describe('when diff of object with children', () => {
20-
it('should capture delete of children', async () => {
21-
const app0_0 = new App('test');
22-
const image0_0 = new Image('test', 'imageTag', {
23-
dockerfilePath: 'path/to/Dockerfile',
24-
});
25-
app0_0.addImage(image0_0);
26-
const region0_0 = new Region('region');
27-
app0_0.addRegion(region0_0);
28-
const environment0_0 = new Environment('qa');
29-
region0_0.addEnvironment(environment0_0);
30-
const support0_0 = new Support('nginx', 'nginx');
31-
app0_0.addSupport(support0_0);
32-
const deployment0_0 = new Deployment('nginx@0.0.1');
33-
support0_0.addDeployment(deployment0_0);
34-
new Execution(deployment0_0, environment0_0);
18+
describe('when diff of object', () => {
19+
it('should capture delete', async () => {
20+
const app_0 = new App('test');
21+
const region_0 = new Region('region');
22+
app_0.addRegion(region_0);
23+
const environment_0 = new Environment('qa');
24+
region_0.addEnvironment(environment_0);
25+
const server_0 = new Server('backend');
26+
app_0.addServer(server_0);
27+
const deployment_0 = new Deployment('backend@0.0.1');
28+
server_0.addDeployment(deployment_0);
29+
new Execution(deployment_0, environment_0);
3530

36-
const app0_1 = (await modelSerializationService.deserialize(
37-
await modelSerializationService.serialize(app0_0),
31+
const app_1 = (await modelSerializationService.deserialize(
32+
await modelSerializationService.serialize(app_0),
3833
)) as App;
39-
const region0_1 = app0_1.getChild('region', [{ key: 'regionId', value: 'region' }]) as Region;
40-
const environment0_1 = region0_1.getChild('environment', [
34+
const region_1 = app_1.getChild('region', [{ key: 'regionId', value: 'region' }]) as Region;
35+
const environment_1 = region_1.getChild('environment', [
4136
{ key: 'environmentName', value: 'qa' },
4237
]) as Environment;
43-
const execution0_1 = environment0_1.getChild('execution', [
44-
{ key: 'executionId', value: 'nginx@0.0.1_qa' },
38+
const execution_1 = environment_1.getChild('execution', [
39+
{ key: 'executionId', value: 'backend@0.0.1_qa' },
4540
]) as Execution;
4641

47-
execution0_1.remove(true);
48-
const diff = await app0_1.diff(app0_0);
42+
execution_1.remove();
43+
const diff = await app_1.diff(app_0);
4944

5045
expect(diff).toMatchInlineSnapshot(`
5146
[
5247
{
5348
"action": "delete",
5449
"field": "executionId",
55-
"value": "nginx@0.0.1_qa",
50+
"value": "backend@0.0.1_qa",
5651
},
5752
]
5853
`);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { Container } from '../../decorators/container.js';
2+
import { ModelSerializationService } from '../../services/serialization/model/model-serialization.service.js';
3+
import { App } from '../app/app.model.js';
4+
import { Deployment } from '../deployment/deployment.model.js';
5+
import { Environment } from '../environment/environment.model.js';
6+
import { Execution } from '../execution/execution.model.js';
7+
import { Region } from '../region/region.model.js';
8+
import { Server } from './server.model.js';
9+
10+
describe('Server UT', () => {
11+
let modelSerializationService: ModelSerializationService;
12+
13+
beforeAll(async () => {
14+
modelSerializationService = await Container.get(ModelSerializationService);
15+
});
16+
17+
describe('diff()', () => {
18+
describe('when diff of object with children', () => {
19+
it('should capture delete of children', async () => {
20+
const app_0 = new App('test');
21+
const region_0 = new Region('region');
22+
app_0.addRegion(region_0);
23+
const environment_0 = new Environment('qa');
24+
region_0.addEnvironment(environment_0);
25+
const server_0 = new Server('backend');
26+
app_0.addServer(server_0);
27+
const deployment_0 = new Deployment('backend@0.0.1');
28+
server_0.addDeployment(deployment_0);
29+
new Execution(deployment_0, environment_0);
30+
31+
const app_1 = (await modelSerializationService.deserialize(
32+
await modelSerializationService.serialize(app_0),
33+
)) as App;
34+
const region_1 = app_1.getChild('region', [{ key: 'regionId', value: 'region' }]) as Region;
35+
const environment_1 = region_1.getChild('environment', [
36+
{ key: 'environmentName', value: 'qa' },
37+
]) as Environment;
38+
const execution_1 = environment_1.getChild('execution', [
39+
{ key: 'executionId', value: 'backend@0.0.1_qa' },
40+
]) as Execution;
41+
const server_1 = app_1.getChild('server', [{ key: 'serverKey', value: 'backend' }]) as Server;
42+
const deployment_1 = server_1.getChild('deployment', [
43+
{ key: 'deploymentTag', value: 'backend@0.0.1' },
44+
]) as Deployment;
45+
46+
execution_1.remove();
47+
deployment_1.remove();
48+
server_1.remove();
49+
const diff = await app_1.diff(app_0);
50+
51+
expect(diff).toMatchInlineSnapshot(`
52+
[
53+
{
54+
"action": "delete",
55+
"field": "executionId",
56+
"value": "backend@0.0.1_qa",
57+
},
58+
{
59+
"action": "delete",
60+
"field": "deploymentTag",
61+
"value": "backend@0.0.1",
62+
},
63+
{
64+
"action": "delete",
65+
"field": "serverKey",
66+
"value": "backend",
67+
},
68+
]
69+
`);
70+
});
71+
});
72+
});
73+
});

packages/octo/src/models/support/support.interface.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/octo/src/models/support/support.model.spec.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

packages/octo/src/models/support/support.model.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)