anantab / serverless-plugin-ifelse

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

Feature request: sls print #7

Closed Enase closed 5 years ago

Enase commented 5 years ago

Would be great to have an ability to see the result before build process with serverless print

PS: "before:print:print": this.applyConditions.bind(this), doesn't help here

anantab commented 5 years ago

Looking at how Print is implemented in https://github.com/serverless/serverless/blob/master/lib/plugins/print/print.js They are actually reading the serverless config file and repopulating values, thus ignoring any changes to the values made by any plugins. That is why you don't see the updated values, even though before:print:print hook executes before print:print. The comment in the code explains why it is implemented this way:

  // ###################################################################
    // The *already loaded* Service (i.e. serverless.yml) is adorned with extras for use by the
    // framework and throughout its codebase.  We could try using the populated service but that
    // would require playing whack-a-mole on issues as changes are made to the service anywhere in
    // the codebase.  Avoiding that, this method must read the serverless.yml file itself, adorn it
    // as the Service class would and then populate it, reversing the adornments thereafter in
    // preparation for printing the service for the user.

I don't think we can implement this feature. Closing this for now.

barbarossa22 commented 1 year ago

@anantab hi! what about adding a note about it in the documentation? I believe many people got confused about print unable to work with your great plugin. I guess numbers of ppl abandoning your plugin because of this problem may be sufficient.

Personally I spent two hours scratching my head why if condition didn't work, but later it turned out print just ignores everything. I've just carefully reread your doc where it says deploy and package commands are supported so I deduced there can be something wrong with print.