serverless/serverless

Packing of layers is broken

Open

#8612 aperta il 11 dic 2020

Vedi su GitHub
 (5 commenti) (0 reazioni) (0 assegnatari)JavaScript (5734 fork)batch import
bugcat/packaginghelp wanted

Metriche repository

Star
 (46.915 star)
Metriche merge PR
 (Merge medio 1g 15h) (34 PR mergiate in 30 g)

Descrizione

/cc @juanjoDiaz

Folow up to https://github.com/serverless/serverless/pull/8602, where layer packaging issue was put to light

Related bugs: #5583, #5892 and #7837

Currently layers are packaged taking into package include and exclude patterns as defined on service level package property and on layer layers[].package property.

Still glob patterns are resolved against layer path, so service level patterns in a bad way influence what's being packaged for layer, and that often leads to bugs and unexpected results

Proposed fix

I believe we should either:

  1. Ignore service level patterns when packaging the layer (respect purely layer level patterns). Downside is that we may break packaging for users, which by chance rely on current behavior (still I hope that'll be rare)
  2. Package against service folder, but prepand patterns with ['!**', layerPath] and map layer level pattenrs to${layerPath}/**/${layerPattern}. Still I'm not 100% sure weather it's fully safe

At this point I'm leaning towards (1), as it will make configuration less confusing (it's more intuitive to assume that include and exclude patterns as set in layer context will be applied against layer directory and not service directory).

Guida contributor