Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: default extension in visual studio code #2819

Merged
merged 17 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
87dde96
docs: default extension in visual studio code
vitaliy-guliy Nov 13, 2024
196dfd9
docs: default extension in visual studio code
vitaliy-guliy Nov 13, 2024
9813b95
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
8733569
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
70d1e5a
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
d65da71
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
42f8bea
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
e4e3e30
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
692ffb8
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
159f974
Apply suggestions from code review
vitaliy-guliy Nov 14, 2024
6750ee2
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 14, 2024
2c63de4
docs: default extension in visual studio code
vitaliy-guliy Nov 14, 2024
414a57b
docs: highlight samples with border
vitaliy-guliy Nov 14, 2024
b18352c
Update modules/administration-guide/pages/default-extensions-for-micr…
vitaliy-guliy Nov 15, 2024
5d0d01b
Apply suggestions from code review
vitaliy-guliy Nov 17, 2024
723ef3e
Apply formatting
vitaliy-guliy Nov 18, 2024
020c358
Apply suggestions from code review
vitaliy-guliy Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/administration-guide/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@
*** xref:enabling-fuse-for-all-workspaces.adoc[]
* xref:managing-ide-extensions.adoc[]
** xref:extensions-for-microsoft-visual-studio-code-open-source.adoc[]
** xref:trusted-extensions-for-microsoft-visual-studio-code.adoc[]
* xref:configuring-visual-studio-code.adoc[]
** xref:configuring-single-and-multiroot-workspaces.adoc[]
** xref:trusted-extensions-for-microsoft-visual-studio-code.adoc[]
** xref:default-extensions-for-microsoft-visual-studio-code.adoc[]
* xref:managing-workloads-using-the-che-server-api.adoc[]
* xref:upgrading-che.adoc[]
** xref:upgrading-the-chectl-management-tool.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
Learn how to configure Visual Studio Code - Open Source ("Code - OSS").

* xref:configuring-single-and-multiroot-workspaces.adoc[]
* xref:trusted-extensions-for-microsoft-visual-studio-code.adoc[]
* xref:default-extensions-for-microsoft-visual-studio-code.adoc[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
:_content-type: PROCEDURE
:description: Configure default extensions
:keywords: extensions, workspace
:navtitle: Configure default extensions
// :page-aliases:

[id="visual-studio-code-default-extensions"]
= Configure default extensions
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

Default extensions, like recommended extensions, allow you to work with a pre-installed set of extensions.

Recommended extension is specified by adding the extension identifier to the workspace file or to the *.vscode/extensions.json* file of your project.
When the editor starts, the recommended extension will be fetched from the extension marketplace and installed.

Default extensions are specified by putting the extension binary *.vsix* file path to the __DEFAULT_EXTENSIONS__ environment variable.
After startup, the editor checks for the environment variable, and if it is specified, takes the path to the extensions and installs it in the background without disturbing the user.

Recommended extensions from *.vscode/extensions.json* and default extensions from the __DEFAULT_EXTENSIONS__ environment variable both installs extensions on editor startup. Recommended extensions are useful when extensions are different per workspace and when the desired extensions are available in the plugin registry configured in {prod-short}. Default extensions described in this documentation are useful for installing .vsix extensions by default from the editor level.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

[NOTE]
====
It is possible to specify several extensions separated by semicolon.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

[source,yaml]
----
DEFAULT_EXTENSIONS='/projects/extension-1.vsix;/projects/extension-2.vsix'
----
====

Below you can find several examples how to add *.vsix* files to your workspace and how to define the DEFAULT_EXTENSIONS environment variable.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

.Procedure
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

This documentation describes three different ways to embed default .vsix extensions for your workspace.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

* Put the extension binary to the source repository.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
The easiest way is to put the extension binary to the Git repository and define the environment variable in the devfile.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
If the *extension.vsix* file exists in the repository root, the __DEFAULT_EXTENSIONS__ could be set for a tooling container.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
Just specify it in your *.devfile.yaml* like below.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
[source,yaml]
----
schemaVersion: 2.3.0
metadata:
generateName: example-project
components:
- name: tools
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest
env:
- name: 'DEFAULT_EXTENSIONS'
value: '/projects/example-project/extension.vsix'
----

* Use the Devfile *postStart* event to fetch extension binaries from the network.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
It is possible to use *curl* or *wget* to download extensions to your workspace.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
For that you need to:
+
** specify a devfile command to donload one or several extensions to your workpace
** add a *postStart* event to run the command on workspace startup
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
** define the __DEFAULT_EXTENSIONS__ environment variable in the Devfile
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
The following sample demonstrates what should be added to the devfile to add two extensions.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
[source,yaml]
----
schemaVersion: 2.3.0
metadata:
generateName: example-project
components:
- name: tools
container:
image: quay.io/devfile/universal-developer-image:ubi8-latest
env:
- name: DEFAULT_EXTENSIONS
value: '/tmp/extension-1.vsix;/tmp/extension-2.vsix'

commands:
- id: add-default-extensions
exec:
# name of the tooling container
component: tools
# download several extensions using curl
commandLine: |
curl https://.../extension-1.vsix --location -o /tmp/extension-1.vsix
curl https://.../extension-2.vsix --location -o /tmp/extension-2.vsix
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved

events:
postStart:
- add-default-extensions
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
----

* Include the extensions' *.vsix* binaries in the *che-code* image.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
Having default extensions bundled in the editor image along with the __DEFAULT_EXTENSIONS__ environment variable defined in a ConfigMap, will allow you to apply the default extensions without the need to change the Devfile.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
Following steps will help you to add the extensions you need to the editor image.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
1. Create a directory and place one or several *.vsix* extensions in this directory.
+
2. Create a Dockerfile with following content.
+
[source,]
----
# inherit che-incubator/che-code:latest
FROM quay.io/che-incubator/che-code:latest
USER 0

# copy all .vsix files to /default-extensions directory
RUN mkdir --mode=775 /default-extensions
COPY --chmod=755 *.vsix /default-extensions/

# add instruction to the script to copy default extensions to the working container
RUN echo "cp -r /default-extensions /checode/" >> /entrypoint-init-container.sh
----
+
3. Build the image and then push it to a registry.
+
[,console]
----
$ docker build -t yourname/che-code:next .
$ docker push yourname/che-code:next
----
+
4. Add the new ConfigMap in the user's {orch-namespace}, define the __DEFAULT_EXTENSIONS__ environment variable and specify the absolute paths to the extensions. This ConfigMap sets the environment variable to all workspaces in the user's {orch-namespace}.
+
[source,yaml]
----
kind: ConfigMap
apiVersion: v1
metadata:
name: vscode-default-extensions
labels:
controller.devfile.io/mount-to-devworkspace: 'true'
controller.devfile.io/watch-configmap: 'true'
annotations:
controller.devfile.io/mount-as: env
data:
DEFAULT_EXTENSIONS: '/checode/default-extensions/extension1.vsix;/checode/default-extensions/extension2.vsix'
----
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
+
5. Create a workspace using *yourname/che-code:next* image.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
First, open the dashboard and navigate to the *Create Workspace* tab on the left-hand side.

Check failure on line 145 in modules/administration-guide/pages/default-extensions-for-microsoft-visual-studio-code.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [RedHat.TermsErrors] Use 'left' rather than 'left-hand'. Raw Output: {"message": "[RedHat.TermsErrors] Use 'left' rather than 'left-hand'.", "location": {"path": "modules/administration-guide/pages/default-extensions-for-microsoft-visual-studio-code.adoc", "range": {"start": {"line": 145, "column": 77}}}, "severity": "ERROR"}
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
Then, in the *Editor Selector* section expand the *Use an Editor Definition* dropdown and set the editor URI to the *Editor Image*.
Finally, create a workspace by clicking on any sample or by setting a git repository URL.
vitaliy-guliy marked this conversation as resolved.
Show resolved Hide resolved
Loading