amenezes / config-client

config-client package for spring cloud config and cloud foundry
https://config-client.amenezes.net/
Apache License 2.0
24 stars 17 forks source link

added handling child lists #51

Open joul87 opened 2 months ago

joul87 commented 2 months ago

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'}]}
amenezes commented 2 months ago

@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

joul87 commented 2 months ago

@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.

amenezes commented 1 month ago

@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