crc icon indicating copy to clipboard operation
crc copied to clipboard

[Idea] Switching preset should store configuration option in a preset-specific file

Open gbraad opened this issue 1 year ago • 3 comments

At the moment, we store our configuration in crc.json, which is unaware of preset specific changes. It stores all the values (eg. 16G of memory) in a single file, and when moved from OpenShift to Microshift, this might mean we assign a lot more memory to this instance as it assign 16G that was given for OpenShift.

We could keep crc.json to store the general configuration, but a specific file for preset-based values, such as memory, cpus, disksize and bundle. This can be stored as crc-[preset].json (eg. crc-microshift.json) and when switched we therefore preserve these specific configuration options.

crc.json

{
  "preset": "openshift",
  "proxy": ...
}

crc-openshift.json

{ 
  "cpus": 8,
  "memory": "16G"
  // no disk-size => implies the default value
}

crc-microshift.json

{
   "memory": "4G",
   //cpus not set => implies default of 2
}

gbraad avatar May 05 '23 12:05 gbraad

This should be considered as a spike as this is not proven to be a solution yet.

gbraad avatar May 05 '23 12:05 gbraad

An alternative could be single file with an array of preset-specific values:

{
  "preset": "openshift",
  "vm-config": [
      "microshift": {
        "memory": "6"
      },
      "openshift": {
        "disk-size": "..."
      },
  ]
}

With viper separate preset files taking precedence over the main one might be easier to implement though.

cfergeau avatar May 09 '23 08:05 cfergeau

changing to read a file by name sounds easier than adding logic to handle the array. you would like this eventually to be 'exchangeable' maybe?

gbraad avatar Jun 21 '23 08:06 gbraad