Skip to content

Fix export feature to filter only on updates plugins #44

@clarsonneur

Description

@clarsonneur

0.0.9 export all changes.

While using a template, we cannot easily describe a list with a separator between each element, if we would like to filter the whole list.

As our template generates an array in json, the comma array syntax is key to be valid.

In short,
a template like this

[
{{ range $index, $item := . }}\
            { 
                "name": "{{ $item.Name }}", 
                "value": "updated from {{ $item.OldVersion }} to {{ $item.NewVersion }}" 
            },
{{ end }}\
]

provide this kind of invalid json data (last comma must not exist)

[
            {
                "name": "ec2",
                "value": "updated from 1.40.1 to 1.41"
            },
            {
                "name": "ws-cleanup",
                "value": "updated from 0.36 to 0.37"
            },
]

We need to find a way to detect the last element to avoid printing out the last comma

[
{{ range $index, $item := . }}\
            { 
                "name": "{{ $item.Name }}", 
                "value": "updated from {{ $item.OldVersion }} to {{ $item.NewVersion }}" 
            }{{ if not ($List.IsLast $index) }},{{ end }}
{{ end }}\
]

and then generate following valid json:

[
            {
                "name": "ec2",
                "value": "updated from 1.40.1 to 1.41"
            },
            {
                "name": "ws-cleanup",
                "value": "updated from 0.36 to 0.37"
            }
]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions