Skip to content

Commit

Permalink
Add a new lifetime property to the container process
Browse files Browse the repository at this point in the history
Closes #1013

Signed-off-by: Charles d'Avernas <[email protected]>
  • Loading branch information
cdavernas committed Jan 8, 2025
1 parent df6686a commit 3983190
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
32 changes: 32 additions & 0 deletions dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
+ [HTTP Response](#http-response)
+ [HTTP Request](#http-request)
+ [URI Template](#uri-template)
+ [Container Lifetime](#container-lifetime)

## Abstract

Expand Down Expand Up @@ -772,6 +773,7 @@ Enables the execution of external processes encapsulated within a containerized
| ports | `map` | `no` | The container's port mappings, if any |
| volumes | `map` | `no` | The container's volume mappings, if any |
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process |
| lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. |

###### Examples

Expand Down Expand Up @@ -1888,3 +1890,33 @@ This has the following limitations compared to runtime expressions:
```yaml
uri: https://petstore.swagger.io/v2/pet/{petId}
```

### Container Lifetime

Configures the lifetime of a container.

#### Properties

| Property | Type | Required | Description |
|----------|:----:|:--------:|-------------|
| cleanup | `string` | `yes` | The cleanup policy to use.<br>*Supported values are:<br>- `always`: the container is deleted immediately after execution.<br>-`never`: the runtime should never delete the container.<br>-`eventually`: the container is deleted after a configured amount of time after its execution.*<br>*Defaults to `never`.* |
| after | [`duration`](#duration) | `no` | The [`duration`](#duration), if any, after which to delete the container once executed.<br>*Required if `cleanup` has been set to `eventually`, otherwise ignored.* |

#### Examples

```yaml
document:
dsl: '1.0.0-alpha5'
namespace: test
name: run-container-example
version: '0.1.0'
do:
- runContainer:
run:
container:
image: fake-image
lifetime:
cleanup: eventually
after:
minutes: 30
```
12 changes: 12 additions & 0 deletions examples/run-container-cleanup-always.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
document:
dsl: '1.0.0-alpha5'
namespace: test
name: run-container
version: '0.1.0'
do:
- runContainer:
run:
container:
image: hello-world
lifetime:
cleanup: always
14 changes: 14 additions & 0 deletions examples/run-container-cleanup-eventually.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
document:
dsl: '1.0.0-alpha5'
namespace: test
name: run-container
version: '0.1.0'
do:
- runContainer:
run:
container:
image: hello-world
lifetime:
cleanup: eventually
after:
minutes: 30
30 changes: 30 additions & 0 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ $defs:
type: object
title: ContainerEnvironment
description: A key/value mapping of the environment variables, if any, to use when running the configured process.
lifetime:
$ref: '#/$defs/containerLifetime'
title: ContainerLifetime
description: An object, if any, used to configure the container's lifetime
required: [ image ]
required: [ container ]
- title: RunScript
Expand Down Expand Up @@ -1535,3 +1539,29 @@ $defs:
title: RuntimeExpression
description: A runtime expression.
pattern: "^\\s*\\$\\{.+\\}\\s*$"
containerLifetime:
type: object
title: ContainerLifetime
description: The configuration of a container's lifetime
unevaluatedProperties: false
properties:
cleanup:
type: string
title: ContainerCleanupPolicy
description: The container cleanup policy to use
enum: [ always, never, eventually ]
default: never
after:
$ref: '#/$defs/duration'
title: ContainerLifetimeDuration
description: The duration after which to cleanup the container, in case the cleanup policy has been set to 'eventually'
required: [ cleanup ]
if:
properties:
cleanup:
const: eventually
then:
required: [ after ]
else:
not:
required: [ after ]

0 comments on commit 3983190

Please sign in to comment.