anantab / serverless-plugin-ifelse

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

Using Set if the property is boolean, plugin skips replacement if value is false #1

Closed ashwinaggarwal closed 5 years ago

ashwinaggarwal commented 5 years ago

When evaluating an expression using If, and using the Set key to replace values, if the property to be replaced is a boolean value, it is skipped.

For. e.g.

custom:
  serverlessIfElse:
    - If: '["sit", "uat"].indexOf("${opt:stage, self:provider.stage}") === -1'
      Set:
        custom.customCertificate.enabled: false
      ElseSet:
        custom.customCertificate.enabled: true
  customCertificate:
    certificateName: ${file(./config.yml):${opt:stage, self:provider.stage}.FQDN}
    hostedZoneName: ${file(./config.yml):${opt:stage, self:provider.stage}.HOSTZONENAME}
    writeCertInfoToFile: true
    enabled: false

sls debug output

Serverless: Invoke aws:common:cleanupTempDir
Serverless: serverless-plugin-ifelse - (["sit", "uat"].indexOf("dev") === -1) Condition true.
Serverless: Compiling with Typescript...

expected output

Serverless: Invoke aws:common:cleanupTempDir
Serverless: serverless-plugin-ifelse - (["sit", "uat"].indexOf("dev") === -1) Condition true.
Serverless: serverless-plugin-ifelse - Value Changed for : custom.customCertificate.enabled to: false
Serverless: Compiling with Typescript...