## Events
### Use cases
Specify in a devfile to:
- Open a file at workspace startup
- Run build after clone of the project
- Copy files before workspace startup
- Backup files at workspace shutdown
```yaml
events:
<trigger>-<event>:
- <commandName>
```
### Workspaces Lifecycle Phases
1. create
2. start (in the case of Che/Theia starts includes theia plugins loading and source cloning)
4. stop
5. delete
Events happen sequentially and constitute the workspace lifecycle
### Triggers
`pre<Phase>` and `post<Phase>`
### Example
```yaml
components:
- container:
name: "copier"
image: ''
env:
- name: ""
value: ""
volume: ....
- container:
name: "maven"
image: ''
env:
- name: ""
value: ""
volume: ....
- plugin:
id: theia
commands:
- exec:
name: "copyNeededFiles"
component: "copier"
commandLine: "cp somefile"
- exec:
name: "buildAll"
component: "maven"
commandLine: "mvn ..."
- vsCodeTask:
name: "openFile"
component: "theia"
inline: |
{
xxxx
}
events:
preStart:
- "copyNeededFiles" # <== start of the workspace happens after this command is completed
postStart:
- "buildAll" # <== commands are executed in parallel, if sequential
- "openFile"
```
## Specify if multiple components will run in the same pod
### Proposal
- Add an attribute to specify if a component is the main component of a workspace (`isMainPod=true/false` for Che that's the editor/theia pod )
- Add an attribute to specify if a component will run in the main pod or not (`runInMainPod=`true`/`false``)
## Specify if a component is terminating (task) or non terminating ()
### Proposal
- Add an attribute to specify if a component is terminating (`terminating=true/false` the default is false)
## Specify if a component is started when the workspace is started or not
### Proposal
- Split `components` in `tasks` and `services`
## Specify if a component is an editor?
## Attributes for components
### Proposal
```
components:
- container:
attributes:
isTask: true
runInDistinctPod: true
isEditor: true
vsCodeExt: true
name: "copier"
image: ''
env:
- name: ""
value: ""
volume: ....
```
## External Components
`externalComponents/import/external`
```yaml
components:
- externalComponents:
uri: https://...
- externalComponents:
kuernetes:...
- externalComponents:
registry:
:
```
In the components/stacks registry ....
```yaml
components:
- container
- kubernetes
commands:
-
events:
-
```
## Custom components triggers
```yaml
events:
postTheiaStart:
- "editLine"
components:
container:
name: "theia"
lifecycle:
- theiaPreStart
- theiaPostStart
- theiaPreStop
- theiaPostStop
```