onyxia-api icon indicating copy to clipboard operation
onyxia-api copied to clipboard

Pre and post regional script: feature proposal

Open mickaelbaron opened this issue 1 year ago • 0 comments

Hi,

I submit you a new feature.

We can override the ide/init.json schema to execute a regional initialization script. However, this regional script is triggered at the start of the onyxia-init.sh script. Unfortunately, some changes made by the regional script can be overwritten by subsequent instructions in the onyxia-init.sh script.

Concrete example: Git

In a region init script, I would like to change the credential.helper value: git config --global credential.helper '!f() { printf "%s\n" "username=$GIT_USER_NAME" "password=$GIT_PERSONAL_ACCESS_TOKEN"; };f'

When onyxia-init.sh script is executed credential.helper is updated by the below code:

    if [ -n "$GIT_CREDENTIALS_CACHE_DURATION" ]; then
        git config --"$git_config" credential.helper "cache --timeout=$GIT_CREDENTIALS_CACHE_DURATION"
    fi

A workaround could be a pre and post mecanism like this:

"preregionInit": {
  "type": "string",
  "description": "pre region initialization script",
  "default": "",
  "x-onyxia": {
     "hidden": true,
     "overwriteDefaultWith": "{{k8s.initScriptUrl}}"
  }
},
"postregionInit": {
  "type": "string",
  "description": "post region initialization script",
  "default": "",
  "x-onyxia": {
    "hidden": true,
    "overwriteDefaultWith": "{{k8s.initScriptUrl}}"
   }
},

How do you feel about this feature?

mickaelbaron avatar Oct 04 '24 18:10 mickaelbaron