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

[Task] Add a way to distinguish if a value is default or what the default value is #2869

Closed
gbraad opened this issue Dec 1, 2021 · 4 comments
Assignees
Labels
kind/task Workable task status/stale Issue went stale; did not receive attention or no reply from the OP

Comments

@gbraad
Copy link
Contributor

gbraad commented Dec 1, 2021

General information

  • OS: Linux

CRC version

Current dev and master branch

CRC config

<none>

Steps to reproduce

  1. GET /api/config

Issue

The current API will return all settings that possible, but does not indicate if the config is a default or not.

{ autostart-tray: true, bundle: '/home/gbraad/.crc/cache/crc_libvirt_4.9.0.crcbundle', ... , nameserver: "",

This means empty options are given or bundle, which is not explicitly set. It would be better to return settings that also includes what the default is or even if the default is used.

   { nameserver: "",
       default: "" }, ...
    { bundle: '/home/gbraad/.crc/cache/crc_libvirt_4.9.0.crcbundle', isDefault: true }, ...

This way we can also print this as a description or information in the React components for Electron and Cockpit module.

@gbraad gbraad added kind/bug Something isn't working status/need triage labels Dec 1, 2021
@gbraad gbraad changed the title [BUG] [Task] Add a way to distinguish if a value is default or what the default value is Dec 1, 2021
@gbraad gbraad added kind/task Workable task and removed kind/bug Something isn't working status/need triage labels Dec 1, 2021
@gbraad
Copy link
Contributor Author

gbraad commented Feb 14, 2022

Currently these have been defined in the Configuration component

@anjannath anjannath self-assigned this Mar 16, 2022
@anjannath
Copy link
Member

this is what the api returns with the changes in https://github.com/anjannath/crc/tree/config-defaults but not very clean

{
  "Configs": {
    "bundle": {
      "value": "/Users/anjan/.crc/cache/crc_podman_hyperkit_3.4.4_amd64.crcbundle",
      "IsDefault": true,
      "defaultValue": "/Users/anjan/.crc/cache/crc_podman_hyperkit_3.4.4_amd64.crcbundle"
    },
    "consent-telemetry": {
      "value": "no",
      "IsDefault": false,
      "defaultValue": ""
    },
    "cpus": {
      "value": 2,
      "IsDefault": true,
      "defaultValue": 2
    },
    [...]
}

might be better to extend the SettingValue struct to also include a DefaultValue field, although the difference between Setting and SettingValue becomes a bit distorted after this:

https://github.com/code-ready/crc/blob/88a0aeeb5d89af1f37b4f8000a67b5c517a1a404/pkg/crc/config/types.go#L16-L29

@cfergeau
Copy link
Contributor

cfergeau commented Apr 6, 2022

might be better to extend the SettingValue struct to also include a DefaultValue field, although the difference between Setting and SettingValue becomes a bit distorted after this:

I'd prefer not to go this way, SettingValue describes the current state of the key, while Setting describes its 'format'. The former can be changed at runtime, the latter cannot.

@stale
Copy link

stale bot commented Jun 12, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status/stale Issue went stale; did not receive attention or no reply from the OP label Jun 12, 2022
@stale stale bot closed this as completed Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Workable task status/stale Issue went stale; did not receive attention or no reply from the OP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants