anantab / serverless-plugin-ifelse

A Serverless Plugin to write If Else conditions in serverless YAML file
69 stars 19 forks source link

feat: make exclude on array items remove them completely #42

Open jhrdina opened 1 year ago

jhrdina commented 1 year ago

This PR adds support for completely removing excluded array indices.

Before

custom: {
    cors: {
        headers: [
            "X-Prod-Specific-Header-1",
            "Normal-Header",
            "X-Prod-Specific-Header-2"
        ]
    }
},

and

Exclude: [
    "custom.cors.headers.0",
    "custom.cors.headers.2",
],

results in

custom: {
    cors: {
        headers: [
            undefined,
            "Normal-Header",
            undefined
        ]
    }
},

After

The result will be

custom: {
    cors: {
        headers: [
            "Normal-Header",
        ]
    }
},

Why

The motivation for this change is that, in our use-case, CloudFormation crashed when it ran into the excluded undefined item in the array. If we remove the item completely, it works as it should.

Note

:firecracker: BREAKING CHANGE: Exclusion of an array item now removes it completely instead of keeping undefined on its index.

akzincsystems commented 6 months ago

This should also fix this reported issue