Skip to content

Commit

Permalink
Merge pull request #81 from linkorb/devcontainer-vscode-customization
Browse files Browse the repository at this point in the history
feat: support vscode customizations #8796
  • Loading branch information
mhitza authored Oct 21, 2024
2 parents 448af79 + a4a5661 commit 812e78a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 28 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ your repository.
| github<br>features<br>issues `boolean` |false| Enable issues tab.|
| github<br>features<br>projects `boolean` |false| Enable projects tab.|
| helm_charts `boolean` |false| Enable generation of Helm charts.|
| devcontainer<br>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<br>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<br>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<br>customizations_vscode<br>extensions `array` |-| Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for extensions installed by default.|
| devcontainer<br>customizations_vscode<br>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<br>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<br>repository `string` |ghcr.io/linkorb/php-docker-base| Image to use for devcontainer (registry image URL)|
| devcontainer<br>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.|
Expand Down
4 changes: 3 additions & 1 deletion docs/partials/readme.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
| github<br>features<br>issues `boolean` |false| Enable issues tab.|
| github<br>features<br>projects `boolean` |false| Enable projects tab.|
| helm_charts `boolean` |false| Enable generation of Helm charts.|
| devcontainer<br>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<br>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<br>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<br>customizations_vscode<br>extensions `array` |-| Additional extensions to install. Refer to the [group_vars/all.yaml](group_vars/all.yaml) file for extensions installed by default.|
| devcontainer<br>customizations_vscode<br>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<br>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<br>repository `string` |ghcr.io/linkorb/php-docker-base| Image to use for devcontainer (registry image URL)|
| devcontainer<br>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.|
14 changes: 14 additions & 0 deletions group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 26 additions & 6 deletions repo.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tasks/devcontainer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 3 additions & 20 deletions templates/.devcontainer/devcontainer.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 812e78a

Please sign in to comment.