diff --git a/README.md b/README.md index f83fe42..47cecf2 100644 --- a/README.md +++ b/README.md @@ -106,9 +106,11 @@ your repository. | github
features
issues `boolean` |false| Enable issues tab.| | github
features
projects `boolean` |false| Enable projects tab.| | helm_charts `boolean` |false| Enable generation of Helm charts.| -| devcontainer
private_packagist `boolean` |true| Repository requires private packagist access. Property is ignored is not of type php-*, or the other (deprecated) types: application, library, symfony-bundle.| | devcontainer
postCreateCommand `string` |-| Additional (shell) commands to run when the containers is created. For a typical project you would specify commands that only need to run once when the project is setup. For example you might add a command in here to load database fixtures for your project.| | devcontainer
postStartCommand `string` |-| Additional (shell) commands to run when the container is started. This event takes place after the create event, but opposed to the create event it's triggered every time the container is started (including when it's resumed from a suspended state). In a typical JavaScript application you might set it to run a `npm run dev` or equivalent step.| +| devcontainer
customizations_vscode
extensions `array` |-| Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for extensions installed by default.| +| devcontainer
customizations_vscode
settings `object` |-| Settings overrides for VSCode and installed extensions. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file regarding proper format and default values.| +| devcontainer
private_packagist `boolean` |true| Repository requires private packagist access. Property is ignored is not of type php-*, or the other (deprecated) types: application, library, symfony-bundle.| | devcontainer
repository `string` |ghcr.io/linkorb/php-docker-base| Image to use for devcontainer (registry image URL)| | devcontainer
tag `string` |php8-review| Image tag| | archived `boolean` |false| Setting this option to `true` will cause the repository to be archived. Once archived, it can only be unarchived manually.| diff --git a/docs/partials/readme.configuration.md b/docs/partials/readme.configuration.md index f17e226..212cfc1 100644 --- a/docs/partials/readme.configuration.md +++ b/docs/partials/readme.configuration.md @@ -28,9 +28,11 @@ | github
features
issues `boolean` |false| Enable issues tab.| | github
features
projects `boolean` |false| Enable projects tab.| | helm_charts `boolean` |false| Enable generation of Helm charts.| -| devcontainer
private_packagist `boolean` |true| Repository requires private packagist access. Property is ignored is not of type php-*, or the other (deprecated) types: application, library, symfony-bundle.| | devcontainer
postCreateCommand `string` |-| Additional (shell) commands to run when the containers is created. For a typical project you would specify commands that only need to run once when the project is setup. For example you might add a command in here to load database fixtures for your project.| | devcontainer
postStartCommand `string` |-| Additional (shell) commands to run when the container is started. This event takes place after the create event, but opposed to the create event it's triggered every time the container is started (including when it's resumed from a suspended state). In a typical JavaScript application you might set it to run a `npm run dev` or equivalent step.| +| devcontainer
customizations_vscode
extensions `array` |-| Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for extensions installed by default.| +| devcontainer
customizations_vscode
settings `object` |-| Settings overrides for VSCode and installed extensions. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file regarding proper format and default values.| +| devcontainer
private_packagist `boolean` |true| Repository requires private packagist access. Property is ignored is not of type php-*, or the other (deprecated) types: application, library, symfony-bundle.| | devcontainer
repository `string` |ghcr.io/linkorb/php-docker-base| Image to use for devcontainer (registry image URL)| | devcontainer
tag `string` |php8-review| Image tag| | archived `boolean` |false| Setting this option to `true` will cause the repository to be archived. Once archived, it can only be unarchived manually.| \ No newline at end of file diff --git a/group_vars/all.yaml b/group_vars/all.yaml new file mode 100644 index 0000000..60d74ac --- /dev/null +++ b/group_vars/all.yaml @@ -0,0 +1,14 @@ +default_devcontainer_customizations_vscode: + extensions: + - xdebug.php-debug + - bmewburn.vscode-intelephense-client + - mrmlnc.vscode-apache + - 74th.json-yaml-schema-selector + + settings: + "php.validate.executablePath": /usr/local/bin/php + "yaml.schemas": + "https://raw.githubusercontent.com/linkorb/repo-ansible/main/repo.schema.yaml": + - repo.yaml + # YAML extension by RedHat that prompts on each new devcontainer to enable telemetry + "redhat.telemetry.enabled": false diff --git a/repo.schema.yaml b/repo.schema.yaml index d7d7487..7e54d59 100644 --- a/repo.schema.yaml +++ b/repo.schema.yaml @@ -195,12 +195,6 @@ properties: type: object description: Devcontainer specific values properties: - private_packagist: - type: boolean - default: true - description: > - Repository requires private packagist access. Property is ignored is not of type php-*, or the - other (deprecated) types: application, library, symfony-bundle. postCreateCommand: description: > Additional (shell) commands to run when the containers is created. For a typical project you would specify @@ -215,6 +209,32 @@ properties: `npm run dev` or equivalent step. type: string + customizations_vscode: + type: object + additionalProperties: false + default: {} + description: > + Customizations done in this group will be merged with the default values configured in + [group_vars/all.yaml](group_vars/all.yaml) + properties: + extensions: + type: array + description: > + Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for + extensions installed by default. + settings: + type: object + description: > + Settings overrides for VSCode and installed extensions. Refer to the + [group_vars/all.yaml](group_vars/all.yaml) file regarding proper format and default values. + + private_packagist: + type: boolean + default: true + description: > + Repository requires private packagist access. Property is ignored is not of type php-*, or the + other (deprecated) types: application, library, symfony-bundle. + repository: type: string description: Image to use for devcontainer (registry image URL) diff --git a/tasks/devcontainer.yaml b/tasks/devcontainer.yaml index 9271fd4..86abddd 100644 --- a/tasks/devcontainer.yaml +++ b/tasks/devcontainer.yaml @@ -23,6 +23,8 @@ ansible.builtin.template: src: "{{ './templates/.devcontainer/devcontainer.json.j2' }}" dest: "{{ repo_path + '/.devcontainer/devcontainer.json' }}" + vars: + customizations_vscode: "{{ default_devcontainer_customizations_vscode | combine(repo.devcontainer.customizations_vscode, recursive=True, list_merge='append') }}" - name: copy .devcontainer/git directory ansible.builtin.copy: diff --git a/templates/.devcontainer/devcontainer.json.j2 b/templates/.devcontainer/devcontainer.json.j2 index e478a32..e2b49a2 100644 --- a/templates/.devcontainer/devcontainer.json.j2 +++ b/templates/.devcontainer/devcontainer.json.j2 @@ -15,27 +15,10 @@ "ghcr.io/devcontainers/features/docker-in-docker:1": {} }, - // Configure tool-specific properties. "customizations": { - // Configure properties specific to VS Code. - "vscode": { - // Set *default* container specific settings.json values on container create. - "settings": { - "php.validate.executablePath": "/usr/local/bin/php", - "yaml.schemas": { - "https://raw.githubusercontent.com/linkorb/repo-ansible/main/repo.schema.yaml": ["repo.yaml"] - }, - // YAML extension by RedHat that prompts on each new devcontainer to enable telemetry - "redhat.telemetry.enabled": false - }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "xdebug.php-debug", - "bmewburn.vscode-intelephense-client", - "mrmlnc.vscode-apache", - "74th.json-yaml-schema-selector" - ] - } + // auto-generated based on repo-ansible defaults + repo.yaml (devcontainer.customizations_vscode) definition + "vscode": +{{ customizations_vscode | to_json(indent=2) }} }, "forwardPorts": [ 80, 8000 ], "remoteUser": "vscode",