odo icon indicating copy to clipboard operation
odo copied to clipboard

Inconsistent order of registries in `odo preference view` JSON output

Open rm3l opened this issue 3 years ago • 1 comments

/kind bug

What versions of software are you using?

Operating System: Fedora 36

Output of odo version:

odo v3.0.0-rc2 (a450cec6e)

Server: https://10.10.10.105:6443
Kubernetes: v1.24.6

How did you run odo exactly?

export GLOBALODOCONFIG=/tmp/my-odo-preferences.yaml

odo preference add registry StagingRegistry https://registry.stage.devfile.io

Actual behavior

  • Order in preferences file: odo preference add registry adds new entries to the end of the list.
$ cat $GLOBALODOCONFIG

kind: Preference
apiversion: odo.dev/v1alpha1
OdoSettings:
  RegistryList:
  - Name: DefaultDevfileRegistry
    URL: https://registry.devfile.io
    secure: false
  - Name: StagingRegistry
    URL: https://registry.stage.devfile.io
    secure: false
  ConsentTelemetry: true
$ odo preference view

Preference parameters:
 PARAMETER           VALUE 
 ConsentTelemetry    true  
 Ephemeral                 
 PushTimeout               
 RegistryCacheTime         
 Timeout                   
 UpdateNotification        

Devfile registries:
 NAME                    URL                                SECURE 
 StagingRegistry         https://registry.stage.devfile.io  No     
 DefaultDevfileRegistry  https://registry.devfile.io        No     
  • odo preference view -o json: no order. We rely on the order of registries in the preferences file.
{
  --- Truncated --

  "registries": [
    {
      "name": "DefaultDevfileRegistry",
      "url": "https://registry.devfile.io",
      "secure": false
    },
    {
      "name": "StagingRegistry",
      "url": "https://registry.stage.devfile.io",
      "secure": false
    }
  ]
}

Expected behavior

Unless I missed something, I remember a discussion a few months ago where it was mentioned that the list of registries should be handled as last-in, first-out: the last registry added with odo preference add registry should have priority. To me, this should be reflected consistently in the code base and in the related commands outputs.

I was also wondering if it wouldn't be safer that odo preference add registry simply adds the new entry to the beginning of the list, and have all other commands just rely on the order of the elements in the preferences file, without having to duplicate the iteration logic. This would also make it clearer if users happen to manually edit the preferences file.

Any logs, error output, etc?

rm3l avatar Oct 10 '22 10:10 rm3l

Discussed the possibility to make odo preference add registry insert new entries at the beginning of the list, but this would be a breaking change for users with existing preferences. Breaking changes could be handled using the apiversion field that we already have in the preferences file. This will be the scope of a separate issue (https://github.com/redhat-developer/odo/issues/6208).

For now, the scope of this issue is to fix the order inconsistency in odo preference view -o json: pointed to 1 Story Point.

/retitle Inconsistent order of registries in odo preference view JSON output

rm3l avatar Oct 10 '22 14:10 rm3l