Skip to content

Commit

Permalink
SC-8536: Multiple import of the same file (#274)
Browse files Browse the repository at this point in the history
* SC-8536: Multiple import of the same file

* SC-8536: adjust multiply import

* ALO-278: adjust multiply parameters

* ALO-278: adjust multiply parameters

* SC-8536: adjusted docs

* SC-8536: updated tests

* SC-8536: updated docs

* SC-8536: updated docs

Co-authored-by: Filip Sushko <[email protected]>
  • Loading branch information
alexanderM91 and zyuzka authored Feb 9, 2022
1 parent d365ab0 commit 97ccc7e
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 53 deletions.
48 changes: 46 additions & 2 deletions docs/07-deploy-file/01-deploy-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ To include a deploy file template into an application's configuration, use the [
```yaml
import:
custom_deploy_file.yml:
template: custom_deploy_file.yml
```
### Dynamic parameters
Expand All @@ -31,8 +32,9 @@ version: 1.0
imports:
deploy.base.template.yml:
parameters:
env_name: 'dev'
template: deploy.base.template.yml
parameters:
env_name: 'dev'
```

The included deploy file includes more deploy files:
Expand Down Expand Up @@ -67,9 +69,51 @@ imports:
environment/dev/docker.deploy.template.yml:
```

### Import types

You can include a deploy file into an application's configuration using one of the following import types.

* Named array:
```yaml
imports:
base-deploy-file:
template: deploy.base.template.yml
project-deploy-file:
template: deploy.project.template.yml
```

* Unnamed array:
```yaml
imports:
- template: deploy.base.template.yml
- template: deploy.project.template.yml
```

Named and unnamed array imports support including the same deploy file multiple types. This can be useful when you want to add the same configuration multiple times with different parameters.

Example of including the same deploy file with different parameters via a named array import:

```yaml
imports:
project-deploy-file:
template: deploy.project.template.yml
parameters: 'stage'
extended-project-deploy-file:
template: deploy.project.template.yml
parameters:
env_name: 'dev'
```

Example of including the same deploy file with different parameters via an unnamed array import:

```yaml
- template: deploy.porject.template.yml
parameters:
env-name: 'stage'
- template: deploy.porject.template.yml
parameters:
env-name: 'dev'
```


## Deploy file inheritance
Expand Down
78 changes: 62 additions & 16 deletions docs/07-deploy-file/02-deploy.file.reference.v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,28 @@ environment: 'docker'

### imports:

Defines additional deploy files to be included into a build. The files must exist on a [project or base layer](/01-deploy-file.md).
Defines any of the following:

* Imports of additional deploy files to be included into a build. Supports imports of the same deploy file multiple times. To define a deploy file and dynamic parameters for this type of import, see [imports: {import_name}:](#imports-importname).
```yaml
version: 1.0
imports:
{import_name}:
template: {deploy_file_name}
{import_name}:
template: {deploy_file_name}
```

* An array of additional deploy files to be included into a build. Supports imports of the same deploy file multiple times. To define dynamic parameters for this type of import, see [imports: parameters:](#imports-parameters)
```yaml
imports:
deploy.base.template.yml:
- template: {deploy_file_name}
- template: {deploy_file_name}
```

The files must exist on a [project or base layer](/docs/scos/dev/the-docker-sdk/{{page.version}}/deploy-file/deploy-file.html).



{% info_block infoBox "Merged deploy files" %}

If you include a deploy file, the included deploy file is merged with the original one. The final deploy file is used to build the application. To check how the final deploy file looks without stopping containers, run `docker config {DEPLOY_FILE_NAME}`. For example, if your main deploy file is `deploy.dev.yml`, run `docker config deploy.dev.yml`. The command parses the included deploy files and returns the merged file and validation errors, if any.
Expand All @@ -151,29 +164,62 @@ If you include a deploy file, the included deploy file is merged with the origin

***

### imports: {deploy_file_name}:
### imports: parameters:

Defines the configuration to be used when parsing the included deploy file.
* `{deploy_file_name}: parameters:` - defines the [dynamic parameters](01-deploy-file.md#dynamic-parameters) to be used when parsing the included deploy file. In the included deploy file, the parameter name should be wrapped in `%`.
Defines the [dynamic parameters](/docs/scos/dev/the-docker-sdk/{{page.version}}/deploy-file/deploy-file.html#dynamic-parameters) to be used when parsing the included deploy file. In the included deploy file, the parameter name should be wrapped in `%`.

```yaml
version: 1.0
imports:
- template: {deploy_file_name}
parameters:
{dynamic_parameter_name}: '{dynamic_parameter_value}'
{dynamic_parameter_name}: '{dynamic_parameter_value}'
```

Example:
```yaml
imports:
{deploy_file_name}:
parameters:
{dynamic_parameter_name}: '{dynamic_parameter_value}'
- template: deploy.porject.yml
parameters:
env-name: 'dev'
locale: 'en'
```
Example:

```yaml
version: 1.0
{% info_block warningBox "" %}

Affects the included deploy file that it follows in an array of included deploy files. To learn how you can add dynamic parameters for other types of imports, see [imports: {import_name}:](#imports-importname) and [imports: {deploy_file_name}:](#imports-deployfilename).

{% endinfo_block %}

***


### imports: {import_name}:

Defines the configuration of the import:
* `{import_name}: template:` — defines the deploy file to be included into a build as part of this import.
* `{import_name}: parameters:` - defines the [dynamic parameters](/docs/scos/dev/the-docker-sdk/{{page.version}}/deploy-file/deploy-file.html#dynamic-parameters) to be used when parsing the included deploy file. In the included deploy file, the parameter name should be wrapped in `%`.

```yaml
imports:
deploy.base.template.yml:
parameters:
env_name: 'dev'
{import_name}:
template: {deploy_file_name}
parameters:
{dynamic_parameter_name}: '{dynamic_parameter_value}'
{dynamic_parameter_name}: '{dynamic_parameter_value}'
```
Example:
```yaml
imports:
base:
template: deploy.base.template.yml
parameters:
env_name: 'dev'
locale: 'en'
```

***


***

Expand Down
Loading

0 comments on commit 97ccc7e

Please sign in to comment.