Skip to content

Commit a330829

Browse files
committed
expose devfile validation rules
Signed-off-by: Stephanie <[email protected]>
1 parent 06bb898 commit a330829

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Devfile Validation Rules
3+
description: Devfile Validation Rules
4+
---
5+
6+
### Id and Name:
7+
`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
8+
9+
The restriction is added to allow easy translation to K8s resource names, and also to have consistent rules for both name and id fields.
10+
11+
The validation will be done as part of schema validation, the rule will be introduced as a regex in schema definition, any objection of the rule in devfile will result in a failure.
12+
13+
- limit to lowercase characters i.e., no uppercase allowed
14+
- limit within 63 characters
15+
- no special characters allowed except dash(-)
16+
- start with an alphanumeric character
17+
- end with an alphanumeric character
18+
19+
20+
### Endpoints:
21+
- all the endpoint names are unique across components
22+
- endpoint ports must be unique across container components -- two container components cannot have the same target port, but one container component may have two endpoints with the same target port. This restriction does not apply to container components with `dedicatedPod` set to `true`.
23+
24+
25+
### Commands:
26+
1. id must be unique
27+
2. composite command:
28+
- Should not reference itself via a subcommand
29+
- Should not indirectly reference itself via a subcommand which is a composite command
30+
- Should reference a valid devfile command
31+
3. exec command should: map to a valid container component
32+
4. apply command should: map to a valid container/kubernetes/openshift/image component
33+
5. `{build, run, test, debug, deploy}`, each kind of group can only have one default command associated with it. If there are multiple commands of the same kind without a default, a warning will be displayed.
34+
35+
### Components:
36+
Common rules for all components types:
37+
- Name must be unique
38+
39+
#### Container component
40+
1. the container components must reference a valid volume component if it uses volume mounts, and the volume components are unique
41+
2. `PROJECT_SOURCE` or `PROJECTS_ROOT` are reserved environment variables defined under env, cannot be defined again in `env`
42+
3. the annotations should not have conflict values for same key, except deployment annotations and service annotations set for a container with `dedicatedPod=true`
43+
4. resource requirements, e.g. `cpuLimit`, `cpuRequest`, `memoryLimit`, `memoryRequest`, must be in valid quantity format; and the resource requested must be less than the resource limit (if specified).
44+
45+
#### Plugin Component
46+
- Commands in plugins components share the same commands validation rules as listed above. Validation occurs after overriding and merging, in flattened devfile
47+
- Registry URL needs to be in valid format
48+
49+
#### Kubernetes & Openshift component
50+
- URI needs to be in valid URI format
51+
52+
#### Image component
53+
- A Dockerfile Image component's git source cannot have more than one remote defined. If checkout remote is mentioned, validate it against the remote configured map
54+
55+
56+
### Events:
57+
1. preStart and postStop events can only be Apply commands
58+
2. postStart and preStop events can only be Exec commands
59+
3. if preStart and postStop events refer to a composite command, then all containing commands need to be Apply commands.
60+
4. if postStart and preStop events refer to a composite command, then all containing commands need to be Exec commands.
61+
62+
63+
### Parent:
64+
- Share the same validation rules as listed above. Validation occurs after overriding and merging, in flattened devfile
65+
66+
67+
### starterProjects:
68+
- Starter project entries cannot have more than one remote defined
69+
- if checkout remote is mentioned, validate it against the starter project remote configured map
70+
71+
### projects
72+
- if more than one remote is configured, a checkout remote is mandatory
73+
- if checkout remote is mentioned, validate it against the starter project remote configured map

libs/docs/src/navigation/no-version.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ top:
3333
href: ./integrate-with-editors
3434
- title: Library
3535
href: ./library
36+
- title: Devfile validation rules
37+
href: ./devfile-validation-rules
3638
bottom:
3739
- title: Registry
3840
links:

0 commit comments

Comments
 (0)