Skip to content

Commit 8d548db

Browse files
authored
Merge pull request #96 from yangcao77/add-validation-doc
expose devfile validation rules
2 parents 7637d29 + 4b45850 commit 8d548db

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 `targetPort`, but one `container` component may have two endpoints with the same `targetPort`. 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 a valid URI format
51+
52+
### Image component
53+
- An `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+
## Starter projects:
68+
- Starter project entries cannot have more than one remote defined
69+
- If `checkoutFrom.remote` is mentioned, validate it against the starter project remote configured map
70+
71+
## Projects
72+
- `checkoutFrom.remote` is mandatory if more than one remote is configured
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)