Skip to content

Commit 228d8ea

Browse files
committed
fix: add hooks config reference and document default container timeout
Fixes #2701 Fixed ENG-1958 Signed-off-by: Russell Centanni <russell.centanni@gmail.com>
1 parent c477eaf commit 228d8ea

49 files changed

Lines changed: 1009 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

devspace-schema.json

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@
361361
},
362362
"updateImageTags": {
363363
"type": "boolean",
364-
"description": "UpdateImageTags lets you define if DevSpace should update the tags of the images defined in the\nimages section with their most recent built tag."
364+
"description": "UpdateImageTags lets you define if DevSpace should update the tags of the images defined in the\nimages section with their most recent built tag.",
365+
"default": true
365366
},
366367
"namespace": {
367368
"type": "string",
@@ -753,6 +754,159 @@
753754
"type": "object",
754755
"description": "HelmConfig defines the specific helm options used during deployment"
755756
},
757+
"HookConfig": {
758+
"properties": {
759+
"name": {
760+
"type": "string",
761+
"description": "Name is the name of the hook"
762+
},
763+
"disabled": {
764+
"type": "boolean",
765+
"description": "Disabled can be used to disable the hook"
766+
},
767+
"events": {
768+
"items": {
769+
"type": "string"
770+
},
771+
"type": "array",
772+
"description": "Events are the events when the hook should be executed"
773+
},
774+
"command": {
775+
"type": "string",
776+
"description": "Command is the base command that is either executed locally or in a remote container.\nCommand is mutually exclusive with other hook actions. In the case this is defined\ntogether with where.container, DevSpace will until the target container is running and\nonly then execute the command. If the container does not start in time, DevSpace will fail."
777+
},
778+
"args": {
779+
"items": {
780+
"type": "string"
781+
},
782+
"type": "array",
783+
"description": "Args are additional arguments passed together with the command to execute."
784+
},
785+
"os": {
786+
"type": "string",
787+
"description": "If an operating system is defined, the hook will only be executed for the given os.\nAll supported golang OS types are supported and multiple can be combined with ','."
788+
},
789+
"upload": {
790+
"$ref": "#/$defs/HookSyncConfig",
791+
"description": "If Upload is specified, DevSpace will upload certain local files or folders into a\nremote container."
792+
},
793+
"download": {
794+
"$ref": "#/$defs/HookSyncConfig",
795+
"description": "Same as Upload, but with this option DevSpace will download files or folders from\na remote container."
796+
},
797+
"logs": {
798+
"$ref": "#/$defs/HookLogsConfig",
799+
"description": "If logs is defined will print the logs of the target container. This is useful for containers\nthat should finish like init containers or job pods. Otherwise this hook will never terminate."
800+
},
801+
"wait": {
802+
"$ref": "#/$defs/HookWaitConfig",
803+
"description": "If wait is defined the hook will wait until the matched pod or container is running or is terminated\nwith a certain exit code."
804+
},
805+
"background": {
806+
"type": "boolean",
807+
"description": "If true, the hook will be executed in the background."
808+
},
809+
"silent": {
810+
"type": "boolean",
811+
"description": "If true, the hook will not output anything to the standard out of DevSpace except\nfor the case when the hook fails, where DevSpace will show the error including\nthe captured output streams of the hook."
812+
},
813+
"container": {
814+
"$ref": "#/$defs/HookContainer",
815+
"description": "Container specifies where the hook should be run. If this is omitted DevSpace expects a\nlocal command hook."
816+
}
817+
},
818+
"type": "object",
819+
"required": [
820+
"events"
821+
],
822+
"description": "HookConfig defines a hook"
823+
},
824+
"HookContainer": {
825+
"properties": {
826+
"labelSelector": {
827+
"patternProperties": {
828+
".*": {
829+
"type": "string"
830+
}
831+
},
832+
"type": "object",
833+
"description": "LabelSelector to select a container"
834+
},
835+
"pod": {
836+
"type": "string",
837+
"description": "Pod name to use"
838+
},
839+
"namespace": {
840+
"type": "string",
841+
"description": "Namespace to use"
842+
},
843+
"imageSelector": {
844+
"type": "string",
845+
"description": "ImageSelector to select a container"
846+
},
847+
"containerName": {
848+
"type": "string",
849+
"description": "ContainerName to use"
850+
},
851+
"wait": {
852+
"type": "boolean",
853+
"description": "Wait can be used to disable waiting"
854+
},
855+
"timeout": {
856+
"type": "integer",
857+
"description": "Timeout is how long to wait (in seconds) for the container to start. Default is 150 seconds.",
858+
"default": 150
859+
},
860+
"once": {
861+
"type": "boolean",
862+
"description": "Once only executes an hook once in the container until it is restarted"
863+
}
864+
},
865+
"type": "object",
866+
"description": "HookContainer defines how to select one or more containers to execute a hook in"
867+
},
868+
"HookLogsConfig": {
869+
"properties": {
870+
"tailLines": {
871+
"type": "integer",
872+
"description": "If set, the number of lines from the end of the logs to show. If not specified,\nlogs are shown from the creation of the container"
873+
}
874+
},
875+
"type": "object",
876+
"description": "HookLogsConfig defines a hook logs config"
877+
},
878+
"HookSyncConfig": {
879+
"properties": {
880+
"localPath": {
881+
"type": "string",
882+
"description": "LocalPath to sync files from"
883+
},
884+
"containerPath": {
885+
"type": "string",
886+
"description": "ContainerPath to sync files to"
887+
}
888+
},
889+
"type": "object",
890+
"description": "HookSyncConfig defines a hook upload config"
891+
},
892+
"HookWaitConfig": {
893+
"properties": {
894+
"running": {
895+
"type": "boolean",
896+
"description": "If running is true, will wait until the matched containers are running. Can be used together with terminatedWithCode."
897+
},
898+
"terminatedWithCode": {
899+
"type": "integer",
900+
"description": "If terminatedWithCode is not nil, will wait until the matched containers are terminated with the given exit code.\nIf the container has exited with a different exit code, the hook will fail. Can be used together with running."
901+
},
902+
"timeout": {
903+
"type": "integer",
904+
"description": "The amount of seconds to wait until the hook will fail. Defaults to 150 seconds."
905+
}
906+
},
907+
"type": "object",
908+
"description": "HookWaitConfig defines a hook wait config"
909+
},
756910
"Image": {
757911
"properties": {
758912
"name": {
@@ -2210,6 +2364,13 @@
22102364
"$ref": "#/$defs/RequireConfig",
22112365
"description": "Require defines what DevSpace, plugins and command versions are required to use this config and if a condition is not\nfulfilled, DevSpace will fail."
22122366
},
2367+
"hooks": {
2368+
"items": {
2369+
"$ref": "#/$defs/HookConfig"
2370+
},
2371+
"type": "array",
2372+
"description": "Hooks are actions that are executed at certain points within the pipeline. Hooks are ordered and are executed\nin the order they are specified. They are deprecated and pipelines should be used instead."
2373+
},
22132374
"localRegistry": {
22142375
"$ref": "#/$defs/LocalRegistryConfig",
22152376
"description": "LocalRegistry specifies the configuration for a local image registry"

docs/hack/util/schema.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,22 @@ func createSections(basePath, prefix string, schema *jsonschema.Schema, definiti
182182
fieldPartial = fmt.Sprintf(TemplateConfigField, true, "", headlinePrefix, fieldName, false, fieldType, "", "", anchorName, fieldSchema.Description, fieldPartial)
183183
} else {
184184
if fieldType == "boolean" {
185-
fieldDefault = "false"
186185
if required {
187186
fieldDefault = "true"
188187
required = false
188+
} else {
189+
fieldDefault = "false"
190+
boolDefault, ok := fieldSchema.Default.(bool)
191+
if ok && boolDefault {
192+
fieldDefault = "true"
193+
}
194+
}
195+
} else if fieldType == "integer" {
196+
intDefault, ok := fieldSchema.Default.(int)
197+
if ok {
198+
fieldDefault = strconv.Itoa(intDefault)
199+
} else {
200+
fieldDefault = ""
189201
}
190202
} else {
191203
fieldDefault, ok = fieldSchema.Default.(string)

docs/pages/configuration/_partials/v2beta1/deployments/updateImageTags.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<details className="config-field" data-expandable="false" open>
33
<summary>
44

5-
### `updateImageTags` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">boolean</span> <span className="config-field-default">false</span> <span className="config-field-enum"></span> {#deployments-updateImageTags}
5+
### `updateImageTags` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">boolean</span> <span className="config-field-default">true</span> <span className="config-field-enum"></span> {#deployments-updateImageTags}
66

77
UpdateImageTags lets you define if DevSpace should update the tags of the images defined in the
88
images section with their most recent built tag.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
import PartialHooksreference from "./hooks_reference.mdx"
3+
4+
5+
<details className="config-field" data-expandable="true" open>
6+
<summary>
7+
8+
## `hooks` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">object[]</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#hooks}
9+
10+
Hooks are actions that are executed at certain points within the pipeline. Hooks are ordered and are executed
11+
in the order they are specified. They are deprecated and pipelines should be used instead.
12+
13+
</summary>
14+
15+
<PartialHooksreference />
16+
17+
18+
</details>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
<details className="config-field" data-expandable="false" open>
3+
<summary>
4+
5+
### `args` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string[]</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#hooks-args}
6+
7+
Args are additional arguments passed together with the command to execute.
8+
9+
</summary>
10+
11+
12+
13+
</details>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
<details className="config-field" data-expandable="false" open>
3+
<summary>
4+
5+
### `background` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">boolean</span> <span className="config-field-default">false</span> <span className="config-field-enum"></span> {#hooks-background}
6+
7+
If true, the hook will be executed in the background.
8+
9+
</summary>
10+
11+
12+
13+
</details>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
<details className="config-field" data-expandable="false" open>
3+
<summary>
4+
5+
### `command` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#hooks-command}
6+
7+
Command is the base command that is either executed locally or in a remote container.
8+
Command is mutually exclusive with other hook actions. In the case this is defined
9+
together with where.container, DevSpace will until the target container is running and
10+
only then execute the command. If the container does not start in time, DevSpace will fail.
11+
12+
</summary>
13+
14+
15+
16+
</details>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
import PartialContainerreference from "./container_reference.mdx"
3+
4+
5+
<details className="config-field" data-expandable="true" open>
6+
<summary>
7+
8+
### `container` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type"></span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#hooks-container}
9+
10+
Container specifies where the hook should be run. If this is omitted DevSpace expects a
11+
local command hook.
12+
13+
</summary>
14+
15+
<PartialContainerreference />
16+
17+
18+
</details>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
<details className="config-field" data-expandable="false" open>
3+
<summary>
4+
5+
#### `containerName` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#hooks-container-containerName}
6+
7+
ContainerName to use
8+
9+
</summary>
10+
11+
12+
13+
</details>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
<details className="config-field" data-expandable="false" open>
3+
<summary>
4+
5+
#### `imageSelector` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#hooks-container-imageSelector}
6+
7+
ImageSelector to select a container
8+
9+
</summary>
10+
11+
12+
13+
</details>

0 commit comments

Comments
 (0)