Apply IDE settings to all workspaces

Configure the Code - OSS editor for all workspaces by defining settings, recommended extensions, and product properties in a ConfigMap. When you start a workspace, the editor reads this ConfigMap and applies the configurations to the corresponding config files.

The following sections are currently supported:

settings.json

Contains various settings with which you can customize different parts of the Code - OSS editor.

extensions.json

Contains recommended extensions that are installed when a workspace is started.

product.json

Contains properties that you need to add to the editor’s product.json file. If the property already exists, its value is updated.

configurations.json

Contains properties for Code - OSS editor configuration. For example, you can use the extensions.install-from-vsix-enabled property to disable the Install from VSIX menu item in the Extensions panel.

The extensions.install-from-vsix-enabled property disables only the UI action. Extensions can still be installed by using the workbench.extensions.command.installFromVSIX API command or the CLI. To block these paths as well, see Control which extensions users can install.

policy.json

Controls Code - OSS extension installation by using the AllowedExtensions policy and the ability to fully block extension installation. See Control which extensions users can install.

Prerequisites
  • An active kubectl session with administrative permissions to the Kubernetes cluster. See Overview of kubectl.

Procedure
  1. Add a new ConfigMap in valid JSON format to the user’s namespace, define the supported sections, and specify the properties you want to add.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: vscode-editor-configurations
      labels:
         app.kubernetes.io/part-of: che.eclipse.org
         app.kubernetes.io/component: workspaces-config
    data:
      extensions.json: |
        {
          "recommendations": [
              "dbaeumer.vscode-eslint",
              "github.vscode-pull-request-github"
          ]
        }
      settings.json: |
        {
          "window.header": "A HEADER MESSAGE",
          "window.commandCenter": false,
          "workbench.colorCustomizations": {
            "titleBar.activeBackground": "#CCA700",
            "titleBar.activeForeground": "#ffffff"
          }
        }
      product.json: |
        {
          "extensionEnabledApiProposals": {
            "ms-python.python": [
              "contribEditorContentMenu",
              "quickPickSortByLabel"
            ]
          },
          "trustedExtensionAuthAccess": [
            "<publisher1>.<extension1>",
            "<publisher2>.<extension2>"
          ]
        }
      configurations.json: |
        {
          "extensions.install-from-vsix-enabled": false
        }

    where:

    <publisher1>.<extension1>, <publisher2>.<extension2>

    The publisher and extension name pairs for extensions that are granted trusted authentication access. Use the format publisher.extensionName.

  2. Optional: To replicate the ConfigMap across all user namespaces while preventing user modifications, add the ConfigMap to the eclipse-che namespace instead of individual user namespaces.

  3. Start or restart your workspace.

Verification
  1. Verify that settings defined in the ConfigMap are applied using one of the following methods:

    • Use F1 → Preferences: Open Remote Settings to check if the defined settings are applied.

    • Ensure that the settings from the ConfigMap are present in the /checode/remote/data/Machine/settings.json file by using the F1 → File: Open File…​ command to inspect the file’s content.

  2. Verify that extensions defined in the ConfigMap are applied:

    • Go to the Extensions view (F1 → View: Show Extensions) and check that the extensions are installed

    • Ensure that the extensions from the ConfigMap are present in the .code-workspace file by using the F1 → File: Open File…​ command. By default, the workspace file is placed at /projects/.code-workspace.

  3. Verify that product properties defined in the ConfigMap are being added to the Visual Studio Code product.json:

    • Open a terminal, run the command cat /checode/entrypoint-logs.txt | grep -a "Node.js dir" and copy the Visual Studio Code path.

    • Press Ctrl + O, paste the copied path and open product.json file.

    • Ensure that product.json file contains all the properties defined in the ConfigMap.

  4. Verify that extensions.install-from-vsix-enabled property defined in the ConfigMap is applied to the Code - OSS editor:

    • Open the Command Palette (use F1) to check that Install from VSIX command is not present in the list of commands.

    • Use F1 → Open View → Extensions to open the Extensions panel, then click …​ on the view (Views and More Actions tooltip) to check that Install from VSIX action is absent in the list of actions.

    • Go to the Explorer, find a file with the vsix extension (redhat.vscode-yaml-1.17.0.vsix, for example), open menu for that file. Install from VSIX action should be absent in the menu.