You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 30, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: script-library/README.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Some scripts have special installation instructions (like `desktop-lite-debian.s
14
14
15
15
| Document | Script | Maintainers |
16
16
|----------|--------|------------|
17
+
|[AWS CLI Install Script](docs/awscli.md)|`awscli-debian.sh`| VS Code and GitHub Codespaces teams |
17
18
|[Azure CLI Install Script](docs/azcli.md)|`azcli-debian.sh`| VS Code and GitHub Codespaces teams |
18
19
|[Common Script](docs/common.md)|`common-debian.sh`<br />`common-alpine.sh`<br />`common-redhat.sh` (Community) | VS Code and GitHub Codespaces teams |
19
20
|[Desktop (Lightweight) Install Script](docs/desktop-lite.md)|`desktop-lite-debian.sh`| VS Code and GitHub Codespaces teams|
Copy file name to clipboardExpand all lines: script-library/container-features/README.md
+20-10
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,15 @@ This folder includes some explorations around dynamic container feature injectio
8
8
9
9
**Registering a feature**
10
10
11
-
Create the install script in the [script-library](../../script-library/) directory with the naming convention `<lowercase-feature-name>-<target-os>.sh`. EG`python-debian.sh` or `common-alpine.sh`
11
+
Create the install script in the [script-library](../../script-library/) directory with the naming convention `<lowercase-feature-name>-<target-os>.sh`. E.g.,`python-debian.sh` or `common-alpine.sh`
12
12
13
13
Add a new object to the [devcontainer-features.json](../../script-library/container-features/src/devcontainer-features.json) file:
14
14
15
15
```json
16
16
{
17
17
"id": "<lowercase-feature-name>", // Must match the <lowercase-feature-name> used to name the install script.
- Options declared in `devcontainer-features.json` are mapped using the naming convention `_BUILD_ARG_<FEATURE>_<OPTIONNAME>` and their default should match the declared default for that option.
- If your script takes the installation user as an argument, be sure to specify it as ${USERNAME} in the tests for programatic testing.
72
74
73
75
*Regression tests*
76
+
74
77
- Add your feature to the [test-features.env](../../script-library/container-features/test-features.env) file to include it in regression tests of the container-feature functionality. By setting the `_VSC_INSTALL_<FEATURE>` ENV VAR to true and adding the expected _BUILD_ARG options for your feature.
75
78
76
-
EG
79
+
E.g.:
80
+
77
81
```
78
82
_VSC_INSTALL_DOTNET=true
79
83
_BUILD_ARG_DOTNET_VERSION=latest
@@ -82,11 +86,12 @@ EG
82
86
83
87
**Feature documentation**
84
88
85
-
Add your new feature to the list of scripts in the [script-library README.md](https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/README.md#scripts).
89
+
Add your new feature to the list of scripts in the [script-library README.md](../../script-library/README.md#scripts).
90
+
91
+
Add documentation for your new feature script to the [script-library/docs](../../script-library/docs) directory.
86
92
87
-
Add documentation for your new feature script to the [script-library/docs](https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs) directory.
93
+
Documentation should include:
88
94
89
-
Documentation should include:
90
95
- the status of the script, supported operating systems, and maintainer.
91
96
- the syntax expected to run as a feature or script
92
97
- a description of the script arguments
@@ -97,6 +102,7 @@ Feel free to use other scripts in that directory as inspiration.
97
102
### Best practices for writing feature install scripts
98
103
99
104
- Decouple sections of the shellscript that handle user setup, helper functions, and feature installation. Doing so will apply a logical and natural flow to the script for future developers and maintainers to follow. One way to denote this distinction is to use in-line comments throughout the script.
105
+
100
106
```md
101
107
# Logical flow recommended:
102
108
1. File header and description.
@@ -109,6 +115,7 @@ Feel free to use other scripts in that directory as inspiration.
109
115
```
110
116
111
117
- One way to make troubleshooting the script easier when writing a bash shell script is to echo error messages to `STDERR`. A possible way we implemented this in bash scripts is to create an `err()` function like so:
118
+
112
119
```sh
113
120
# Setup STDERR.
114
121
err() {
@@ -119,12 +126,14 @@ Feel free to use other scripts in that directory as inspiration.
119
126
```
120
127
121
128
- If writing a bash shellscript, we recommend using double quotes and braces when referencing named variables:
129
+
122
130
```sh
123
131
variable="My example var"
124
132
echo "${variable}"
125
133
```
126
134
127
135
- One method to to ensure the global space in a script is not too crowded with unnecessary variables is to assign return values from functions to a new variable, and use the keyword `local` for vars inside of functions. For example:
136
+
128
137
```sh
129
138
test_function() {
130
139
local test = "hello world!"
@@ -134,6 +143,7 @@ Feel free to use other scripts in that directory as inspiration.
134
143
```
135
144
136
145
- If using temporary files within the script, we recommend removing all those files once they are no longer needed. One method for doing this is running a cleanup function with a `trap` method when the script exits:
146
+
137
147
```sh
138
148
# Cleanup temporary directory and associated files when exiting the script.
139
149
cleanup() {
@@ -150,7 +160,7 @@ Feel free to use other scripts in that directory as inspiration.
150
160
151
161
- Consider using [shellcheck](https://github.com/koalaman/shellcheck) or the [vscode-shellcheck extension](https://github.com/vscode-shellcheck/vscode-shellcheck) to apply linting and static code analysis to the bash script to ensure it is formatted correctly.
152
162
153
-
- Consider using common helper functions from [shared/utils.sh](../../script-library/shared/utils.sh) when managing common tasks (like updating PATH variables, or managing gpg keys) by copying them directly into your script.
163
+
- Consider using common helper functions from [shared/utils.sh](../../script-library/shared/utils.sh) when managing common tasks (like updating PATH variables, or managing gpg keys) by copying them directly into your script.
154
164
- NOTE: This is done to minimize the impact that any change can have on existing working scripts.
155
165
- Similarly, if you add a helper function to your script that could benefit others in the future, consider adding it to the `shared/utils.sh` file as well.
0 commit comments