Applying editor configurations

You can configure Visual Studio Code - Open Source editor by adding configurations to a ConfigMap. These configurations are applied to any workspace you open. Once a workspace is started, the editor checks for this ConfigMap and stores configurations to the corresponding config files.

The following sections are currently supported:

  • settings.json

  • extensions.json

  • product.json

The settings.json section contains various settings with which you can customize different parts of the Code - OSS editor.
The extensions.json section contains recommended extensions that are installed when a workspace is started.
The product.json section contains properties that you need to add to the editor’s product.json file. If the property already exists, its value will be updated.

Procedure
  • Add a new ConfigMap to the user’s namespace, define the settings.json and extensions.json sections, specify the settings you want to add, and the IDs of the extensions you want to install.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: vscode-editor-configurations
    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>"
          ]
        }
    immutable: false
  • Start or restart your workspace

Make sure that the Configmap contains data in a valid JSON format.

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 "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.