config-client icon indicating copy to clipboard operation
config-client copied to clipboard

added handling child lists

Open joul87 opened this issue 1 year ago • 5 comments

For now, the library does not parse child lists and leave them in this format:

{'main_list': [{'child_list[0]': {'property-name': 'example0'}, 'child_list[1]': {'property-name': 'example1'}}]}

This PR will change the result dictionary to the next format:

{'main_list': [{'child_list': [{'property-name': 'example0'}, {'property-name': 'example1'}]}

joul87 avatar Jul 06 '24 13:07 joul87

@joul87,

Thank you for your contribution.

Could you share an example in YAML format for the result that you shared in this PR?

I would like to include the example in this repository: https://github.com/amenezes/spring_config

amenezes avatar Jul 21 '24 15:07 amenezes

@joul87,

Thank you for your contribution.

Could you share an example in YAML format for the result that you shared in this PR?

I would like to include the example in this repository: https://github.com/amenezes/spring_config

Hello Sure. The config file has the following structure:

environments:
- type: dev
  properties:
    - name: property1
      schema:
        type: string
        minLength: 1
    - name: property2
      schema:
        type: string
- type: stage
  properties:
    - name: property1
      schema:
        type: string

Also, I would like to ask you to re-run the tests for my commit. They were not completed due to Rate limit reached. I'm pretty sure it is not related to my changes.

joul87 avatar Jul 21 '24 16:07 joul87

@joul87,

Really sorry for delay.

But I have some doubts. I'm include the configuration that you shared with me and I tried reproduce the behavior related in the first comment, but using the command line option and the output, initially, make sense.

For example:

$ python -m config client simpleweb000 -f environments 
╭────────────────────────────────────────────────── report for filter: 'environments' ───────────────────────────────────────────────────╮
│ [                                                                                                                                      │
│     {                                                                                                                                  │
│         "properties": [                                                                                                                │
│             {                                                                                                                          │
│                 "name": "property1",                                                                                                   │
│                 "schema": {                                                                                                            │
│                     "minLength": 1,                                                                                                    │
│                     "type": "string"                                                                                                   │
│                 }                                                                                                                      │
│             },                                                                                                                         │
│             {                                                                                                                          │
│                 "name": "property2",                                                                                                   │
│                 "schema": {                                                                                                            │
│                     "type": "string"                                                                                                   │
│                 }                                                                                                                      │
│             }                                                                                                                          │
│         ],                                                                                                                             │
│         "type": "dev"                                                                                                                  │
│     },                                                                                                                                 │
│     {                                                                                                                                  │
│         "properties": [                                                                                                                │
│             {                                                                                                                          │
│                 "name": "property1",                                                                                                   │
│                 "schema": {                                                                                                            │
│                     "type": "string"                                                                                                   │
│                 }                                                                                                                      │
│             }                                                                                                                          │
│         ],                                                                                                                             │
│         "type": "stage"                                                                                                                │
│     }                                                                                                                                  │
│ ]                                                                                                                                      │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
$ python -m config client simpleweb000 -f environments.0.properties
╭──────────────────────────────────────────── report for filter: 'environments.0.properties' ────────────────────────────────────────────╮
│ [                                                                                                                                      │
│     {                                                                                                                                  │
│         "name": "property1",                                                                                                           │
│         "schema": {                                                                                                                    │
│             "minLength": 1,                                                                                                            │
│             "type": "string"                                                                                                           │
│         }                                                                                                                              │
│     },                                                                                                                                 │
│     {                                                                                                                                  │
│         "name": "property2",                                                                                                           │
│         "schema": {                                                                                                                    │
│             "type": "string"                                                                                                           │
│         }                                                                                                                              │
│     }                                                                                                                                  │
│ ]                                                                                                                                      │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Could you share some more examples with me using the config-server running as the example below:

docker run -it --rm -p 8888:8888 \
       hyness/spring-cloud-config-server:3.1.0-jre17 \
       --spring.cloud.config.server.git.uri=https://github.com/amenezes/spring_config

amenezes avatar Aug 08 '24 20:08 amenezes

Hi guys ! Any idea if this issue could be handled soon ? It would be great for us to have this feature working asap @joul87 do you need help to finish your work ?

Maassa avatar Nov 28 '24 13:11 Maassa

Hello, @amenezes

I'm so sorry for delay.

I have another output. I used command to start docker:

docker run -v ~/conf:/tmp/conf -it --rm -p 8888:8888 hyness/spring-cloud-config-server:3.1.0-jre17 --spring.cloud.config.server.native.searchLocations=/tmp/conf --spring.profiles.active=native

Conf directory:

{0} joul87[~/conf]: ls -1
simpleweb000.yml
{0} joul87[~/conf]: cat simpleweb000.yml
environments:
- type: dev
  properties:
    - name: property1
      schema:
        type: string
        minLength: 1
    - name: property2
      schema:
        type: string
- type: stage
  properties:
    - name: property1
      schema:
        type: string

Result:

(config_client) {0} joul87[/tmp/config_client]: python -m config client simpleweb000 -f environments.0
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────── report for filter: 'environments.0' ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ {                                                                                                                                                                                                                                                                            │
│     "properties[0]": {                                                                                                                                                                                                                                                       │
│         "name": "property1",                                                                                                                                                                                                                                                 │
│         "schema": {                                                                                                                                                                                                                                                          │
│             "minLength": 1,                                                                                                                                                                                                                                                  │
│             "type": "string"                                                                                                                                                                                                                                                 │
│         }                                                                                                                                                                                                                                                                    │
│     },                                                                                                                                                                                                                                                                       │
│     "properties[1]": {                                                                                                                                                                                                                                                       │
│         "name": "property2",                                                                                                                                                                                                                                                 │
│         "schema": {                                                                                                                                                                                                                                                          │
│             "type": "string"                                                                                                                                                                                                                                                 │
│         }                                                                                                                                                                                                                                                                    │
│     },                                                                                                                                                                                                                                                                       │
│     "type": "dev"                                                                                                                                                                                                                                                            │
│ }                                                                                                                                                                                                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
(config_client) {0} joul87[/tmp/config_client]: pip freeze | grep config-client
config-client==1.4.0

joul87 avatar Nov 29 '24 09:11 joul87