Skip to content

Persist self references with "${self:}" and restore it correctly - #3527

Merged
eahefnawy merged 5 commits into
serverless:masterfrom
HyperBrain:filter-self-reference
Apr 27, 2017
Merged

eahefnawy merged 5 commits into
serverless:masterfrom
HyperBrain:filter-self-reference

Conversation

@HyperBrain

@HyperBrain HyperBrain commented Apr 26, 2017 •

Copy link
Copy Markdown
Contributor

What did you implement:

This is work-in-progress!

Closes #3509

Self references created with ${self:} are now persisted as ${self:} and will be restored properly on state restoration.

How did you implement it:

In saveServiceState() a deep search for self references is done now (the FQ property paths are extracted) and all refs are replaced with "${self:}".

How can we verify it:

Create a service that contains

...
custom:
  newService: ${self:}
  ...

Run a package and then a deploy.

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@HyperBrain
HyperBrain force-pushed the filter-self-reference branch from c9efe32 to 33a93e7 Compare April 26, 2017 19:57
@HyperBrain

Copy link
Copy Markdown
Contributor Author

@erikerikson The pure implementation is finished. Can you verify that it works as expected?
I will finish the PR as soon as I finished the unit tests.

@erikerikson

Copy link
Copy Markdown
Contributor

@gwsii can look into this

@HyperBrain

Copy link
Copy Markdown
Contributor Author

PR finalized
/cc @pmuens @eahefnawy

@HyperBrain HyperBrain changed the title Persist self references with "${self:}" and restore it correctly [WIP] Persist self references with "${self:}" and restore it correctly Apr 27, 2017
@pmuens
pmuens self-requested a review April 27, 2017 06:30
@pmuens pmuens added this to the 1.13 milestone Apr 27, 2017

@pmuens pmuens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the fix @HyperBrain 🥇

Just tested it with the following config:

service: self-reference

provider:
  name: aws
  runtime: nodejs4.3

custom:
  newService: ${self:}
  exportName: ${self:custom.newService.service}-export

functions:
  hello:
    handler: handler.hello

resources:
  Outputs:
    selfExport:
      Value: 'A Value To Export'
      Export:
        Name: ${self:custom.exportName}
    OptExport:
      Value: 'Exported option variable'
      Export:
        Name: ${opt:}
    EnvExport:
      Value: 'Exported env variable'
      Export:
        Name: ${env:}

I ran serverless package and serverless package --foo bar and looked into the compiled template which is written to disk.

Works on my machine. Therefore --> LGTM :shipit:

@eahefnawy

Copy link
Copy Markdown
Contributor

@HyperBrain ❤️ ❤️ ❤️ ❤️

@eahefnawy
eahefnawy merged commit 4e752fb into serverless:master Apr 27, 2017
@eahefnawy
eahefnawy deleted the filter-self-reference branch April 27, 2017 11:35
@eahefnawy

Copy link
Copy Markdown
Contributor

@pmuens @HyperBrain @erikerikson I just published a patch release (v1.12.1) that includes this fix. @erikerikson please confirm that everything is now ok on your end 😊

@erikerikson

Copy link
Copy Markdown
Contributor

Confirmed! Thank you @HyperBrain @eahefnawy @pmuens!!! You guys rock! 🎸

@pmuens

pmuens commented Apr 27, 2017 •

Copy link
Copy Markdown
Contributor

Thanks for confirming and the warm words @erikerikson 💯

Good to see that it's working again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants