-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_run.ts
52 lines (47 loc) · 1.18 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, Workspace } from './src/models';
import { validate } from './src/policy';
import { ValidationContext } from './src/types';
const dummyWorkspace: Workspace = {
type: 'workspace',
cluster_fqn: 'test-cluster',
name: 'test-workspace'
}
const dummyValidationContext: ValidationContext = {
workspace_name: dummyWorkspace.name,
action: 'apply'
}
// 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
}
]
};
const validationInput = {
manifest: githubService,
context: dummyValidationContext
}
try {
const validatedService = validate(validationInput);
console.log(validatedService);
} catch (error) {
console.error(error);
}