mirror of
https://github.com/hassio-addons/addon-vscode.git
synced 2025-05-06 20:21:32 +00:00
✨ Add support for setting the default configuration path
This commit is contained in:
parent
97c35599ad
commit
35cad4b5fd
4 changed files with 37 additions and 12 deletions
|
@ -31,6 +31,7 @@ Example add-on configuration:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
log_level: info
|
log_level: info
|
||||||
|
config_path: /share/my_path
|
||||||
packages:
|
packages:
|
||||||
- mariadb-client
|
- mariadb-client
|
||||||
init_commands:
|
init_commands:
|
||||||
|
@ -49,7 +50,7 @@ dealing with an unknown issue. Possible values are:
|
||||||
- `debug`: Shows detailed debug information.
|
- `debug`: Shows detailed debug information.
|
||||||
- `info`: Normal (usually) interesting events.
|
- `info`: Normal (usually) interesting events.
|
||||||
- `warning`: Exceptional occurrences that are not errors.
|
- `warning`: Exceptional occurrences that are not errors.
|
||||||
- `error`: Runtime errors that do not require immediate action.
|
- `error`: Runtime errors that do not require immediate action.
|
||||||
- `fatal`: Something went terribly wrong. Add-on becomes unusable.
|
- `fatal`: Something went terribly wrong. Add-on becomes unusable.
|
||||||
|
|
||||||
Please note that each level automatically includes log messages from a
|
Please note that each level automatically includes log messages from a
|
||||||
|
@ -57,6 +58,14 @@ more severe level, e.g., `debug` also shows `info` messages. By default,
|
||||||
the `log_level` is set to `info`, which is the recommended setting unless
|
the `log_level` is set to `info`, which is the recommended setting unless
|
||||||
you are troubleshooting.
|
you are troubleshooting.
|
||||||
|
|
||||||
|
### Option: `config_path`
|
||||||
|
|
||||||
|
This option allows you to override the default path the add-on will open
|
||||||
|
when accessing the web interface. For example, use a different
|
||||||
|
configuration directory like `/share/myconfig` instead of `/config`.
|
||||||
|
|
||||||
|
When not configured, the addon will automatically use the default: `/config`
|
||||||
|
|
||||||
### Option: `packages`
|
### Option: `packages`
|
||||||
|
|
||||||
Allows you to specify additional [Ubuntu packages][ubuntu-packages] to be
|
Allows you to specify additional [Ubuntu packages][ubuntu-packages] to be
|
||||||
|
@ -128,13 +137,13 @@ will come up with a better solution for this soon.
|
||||||
- "Visual Studio Code is unable to watch for file changes in this large
|
- "Visual Studio Code is unable to watch for file changes in this large
|
||||||
workspace" (error ENOSPC)
|
workspace" (error ENOSPC)
|
||||||
|
|
||||||
This issue is caused by your system not having enough file handles,
|
This issue is caused by your system not having enough file handles,
|
||||||
which causes VSCode to be unable to watch all your files. For HassOS,
|
which causes VSCode to be unable to watch all your files. For HassOS,
|
||||||
currently the only option is to click on the little cog when the
|
currently the only option is to click on the little cog when the
|
||||||
notification appears and tell it to not show again. In case you have
|
notification appears and tell it to not show again. In case you have
|
||||||
a generic Linux setup (e.g., Ubuntu), follow this guide by Microsoft:
|
a generic Linux setup (e.g., Ubuntu), follow this guide by Microsoft:
|
||||||
|
|
||||||
<https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc>
|
<https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc>
|
||||||
|
|
||||||
## Changelog & Releases
|
## Changelog & Releases
|
||||||
|
|
||||||
|
@ -143,12 +152,12 @@ functionality. The format of the log is based on
|
||||||
[Keep a Changelog][keepchangelog].
|
[Keep a Changelog][keepchangelog].
|
||||||
|
|
||||||
Releases are based on [Semantic Versioning][semver], and use the format
|
Releases are based on [Semantic Versioning][semver], and use the format
|
||||||
of ``MAJOR.MINOR.PATCH``. In a nutshell, the version will be incremented
|
of `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented
|
||||||
based on the following:
|
based on the following:
|
||||||
|
|
||||||
- ``MAJOR``: Incompatible or major changes.
|
- `MAJOR`: Incompatible or major changes.
|
||||||
- ``MINOR``: Backwards-compatible new features and enhancements.
|
- `MINOR`: Backwards-compatible new features and enhancements.
|
||||||
- ``PATCH``: Backwards-compatible bugfixes and package updates.
|
- `PATCH`: Backwards-compatible bugfixes and package updates.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
},
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
"log_level": "list(trace|debug|info|notice|warning|error|fatal)?",
|
"log_level": "list(trace|debug|info|notice|warning|error|fatal)?",
|
||||||
|
"config_path": "str?",
|
||||||
"packages": ["str"],
|
"packages": ["str"],
|
||||||
"init_commands": ["str"]
|
"init_commands": ["str"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# Home Assistant Community Add-on: Visual Studio Code
|
# Home Assistant Community Add-on: Visual Studio Code
|
||||||
# Sets up code-server.
|
# Sets up code-server.
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
declare config_path
|
||||||
|
|
||||||
# List of previous config hashes, to allow upgrade "default" configs.
|
# List of previous config hashes, to allow upgrade "default" configs.
|
||||||
readonly -a PREVIOUS_DEFAULT_CONFIG_HASHES=(
|
readonly -a PREVIOUS_DEFAULT_CONFIG_HASHES=(
|
||||||
|
@ -16,6 +17,13 @@ readonly -a PREVIOUS_DEFAULT_CONFIG_HASHES=(
|
||||||
08d86c84a0d80720b22712e878963e90cbb34b659330dad8a823f3c5c7f0ae043d197a5e3020dd7ab4fda3625e17f794675ec074984951e7107db2488898a8d0
|
08d86c84a0d80720b22712e878963e90cbb34b659330dad8a823f3c5c7f0ae043d197a5e3020dd7ab4fda3625e17f794675ec074984951e7107db2488898a8d0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if bashio::config.has_value 'config_path'; then
|
||||||
|
config_path=$(bashio::config 'config_path')
|
||||||
|
if ! bashio::fs.directory_exists "${config_path}"; then
|
||||||
|
bashio::exit.nok "Configured config path does not exists"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Ensure persistent data folder exists.
|
# Ensure persistent data folder exists.
|
||||||
if ! bashio::fs.directory_exists '/data/vscode'; then
|
if ! bashio::fs.directory_exists '/data/vscode'; then
|
||||||
mkdir -p /data/vscode/extensions \
|
mkdir -p /data/vscode/extensions \
|
||||||
|
|
|
@ -4,9 +4,15 @@
|
||||||
# Runs the code server
|
# Runs the code server
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
declare -a options
|
declare -a options
|
||||||
|
declare config_path
|
||||||
|
|
||||||
bashio::log.info 'Starting the code server...'
|
bashio::log.info 'Starting the code server...'
|
||||||
|
|
||||||
|
config_path="/config"
|
||||||
|
if bashio::config.has_value 'config_path'; then
|
||||||
|
config_path=$(bashio::config 'config_path')
|
||||||
|
fi
|
||||||
|
|
||||||
options+=(--port 1337)
|
options+=(--port 1337)
|
||||||
options+=(--user-data-dir "/data/vscode")
|
options+=(--user-data-dir "/data/vscode")
|
||||||
options+=(--extra-builtin-extensions-dir "/root/.code-server/extensions/")
|
options+=(--extra-builtin-extensions-dir "/root/.code-server/extensions/")
|
||||||
|
@ -22,4 +28,5 @@ export HASS_SERVER="http://supervisor/core"
|
||||||
export HASS_TOKEN="${SUPERVISOR_TOKEN:-}"
|
export HASS_TOKEN="${SUPERVISOR_TOKEN:-}"
|
||||||
|
|
||||||
# Run the code server
|
# Run the code server
|
||||||
exec code-server "${options[@]}" /config
|
cd "${config_path}"
|
||||||
|
exec code-server "${options[@]}" "${config_path}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue