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

feat: allow to configure product.json using configmap #521

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vitaliy-guliy
Copy link
Contributor

@vitaliy-guliy vitaliy-guliy commented Mar 4, 2025

What does this PR do?

Allows to configure product.json file using Config Map

What issues does this PR fix?

eclipse-che/che#23270

How to test this PR?

Check the existing functionality

Add a Config Map from the template below and create a workspace with the editor quay.io/che-incubator-pull-requests/che-code:pr-521-amd64 clicking the button

Contribute

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"
      }
    }
immutable: false
  • A header message should be shown, recommended extensions being installed.
  • A section in the entrypoint-logs.txt file should contain:
# Checking for editor configurations provided by 'vscode-editor-configurations' Config Map...
  > Configure editor settings...
    > Found setings file: /checode/remote/data/Machine/settings.json
    > Editor settings have been configured.
  > Configure workspace extensions...
    > Found workspace file: /projects/.code-workspace
    > Workspace extensions have been configured.

Add Enabled API proposal, trusted extension

Add a Config Map from the template below and create a workspace clicking the button

Contribute

apiVersion: v1
kind: ConfigMap
metadata:
  name: vscode-editor-configurations
data:
  product.json: |
    {
      "extensionEnabledApiProposals": {
        "ms-python.python": [
          "contribEditorContentMenu",
          "quickPickSortByLabel",
          "testObserver",
          "quickPickItemTooltip",
          "terminalDataWriteEvent",
          "terminalExecuteCommandEvent",
          "contribIssueReporter"
        ]
      },
      "trustedExtensionAuthAccess": [
        "vgulyy.extension"
      ],
      "version": "1.96.4"
    }
immutable: false
  • Product.json should contain both extensionEnabledApiProposals and trustedExtensionAuthAccess sections.
  • Go to Help -> About, a version should be changed to 1.96.4.
  • A section in the entrypoint-logs.txt file should contain:
# Checking for editor configurations provided by 'vscode-editor-configurations' Config Map...
  > Configure product.json ...
    > product.json have been configured.

Test the behavior with corrupted Config Map

Add a Config Map from the template below and create a workspace clicking the button

Contribute

apiVersion: v1
kind: ConfigMap
metadata:
  name: vscode-editor-configurations
data:
  extensions.json: |
    ...
  settings.json: |
    ...
  product.json: |
    ...
immutable: false
  • A section in the entrypoint-logs.txt should contain:
# Checking for editor configurations provided by 'vscode-editor-configurations' Config Map...
  > Configure editor settings...
Failed to configure editor settings. SyntaxError: Configmap content is not valid. Unexpected token '.', "...
" is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSON (file:///checode/checode-linux-libc/ubi9/launcher/json-utils.js:49:21)
    at EditorConfigurations.configureSettings (file:///checode/checode-linux-libc/ubi9/launcher/editor-configurations.js:52:43)
    at EditorConfigurations.configure (file:///checode/checode-linux-libc/ubi9/launcher/editor-configurations.js:37:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Main.start (file:///checode/checode-linux-libc/ubi9/launcher/main.js:34:9)
    at async file:///checode/checode-linux-libc/ubi9/launcher/entrypoint.js:14:9
  > Configure workspace extensions...
Failed to configure workspace extensions. SyntaxError: Configmap content is not valid. Unexpected token '.', "...
" is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSON (file:///checode/checode-linux-libc/ubi9/launcher/json-utils.js:49:21)
    at EditorConfigurations.configureExtensions (file:///checode/checode-linux-libc/ubi9/launcher/editor-configurations.js:83:45)
    at EditorConfigurations.configure (file:///checode/checode-linux-libc/ubi9/launcher/editor-configurations.js:38:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Main.start (file:///checode/checode-linux-libc/ubi9/launcher/main.js:34:9)
    at async file:///checode/checode-linux-libc/ubi9/launcher/entrypoint.js:14:9
  > Configure product.json ...
Failed to configure product.json. SyntaxError: Configmap content is not valid. Unexpected token '.', "...
" is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSON (file:///checode/checode-linux-libc/ubi9/launcher/json-utils.js:49:21)
    at EditorConfigurations.configureProductJSON (file:///checode/checode-linux-libc/ubi9/launcher/editor-configurations.js:118:42)
    at EditorConfigurations.configure (file:///checode/checode-linux-libc/ubi9/launcher/editor-configurations.js:39:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Main.start (file:///checode/checode-linux-libc/ubi9/launcher/main.js:34:9)
    at async file:///checode/checode-linux-libc/ubi9/launcher/entrypoint.js:14:9

Does this PR contain changes that override default upstream Code-OSS behavior?

  • the PR contains changes in the code folder (you can skip it if your changes are placed in a che extension )
  • the corresponding items were added to the CHANGELOG.md file
  • rules for automatic git rebase were added to the .rebase folder

Copy link

github-actions bot commented Mar 4, 2025

Click here to review and test in web IDE: Contribute

Copy link

github-actions bot commented Mar 4, 2025

@vitaliy-guliy vitaliy-guliy marked this pull request as ready for review March 5, 2025 13:37
@vitaliy-guliy vitaliy-guliy added the made-with-che Changes made with Che-Code label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
made-with-che Changes made with Che-Code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant