-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_run.ts
52 lines (48 loc) · 1.23 KB
/
local_run.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Service } from './src/models';
import { validate } from './src/policy';
import { ValidationContext } from './src/types';
const dummyValidationContext: ValidationContext = {
entity: 'service',
action: 'apply',
filters: {
env_name: 'dev',
}
}
// Sample service with GitHub build source (should throw error)
const githubService: Service = {
type: 'service',
name: 'test-service',
image: {
type: 'build',
build_spec: {
type: 'dockerfile',
dockerfile_path: 'Dockerfile',
build_context_path: '.'
},
build_source: {
type: 'git',
repo_url: 'https://github.com/user/repo',
ref: 'main',
}
},
ports: [
{
port: 8080,
protocol: 'TCP',
expose: true
}
],
auto_shutdown: {
wait_time: 300
}
};
const validationInput = {
manifest: githubService,
context: dummyValidationContext
}
try {
const validatedService = validate(validationInput); // will throw error that auto_shutdown wait_time should be less than 300 seconds for the dev environment
console.log(validatedService);
} catch (error) {
console.error(error);
}