Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sandbox] environment policies have the same env as policy loader #596

Merged
merged 3 commits into from
Feb 15, 2018

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Feb 15, 2018

  • Extracts sandbox from policy loader to own module.

  • Load environment configurations with the same sandbox env as policies.

  • Expose arg in sandbox.

  • Expose also cli as an alias to arg when loading environment configurations.
    So policies can detect if they are being executed on the CLI
    and decide to do something different like not loading themselves.

    Because some might require shared dict that is not available.

So policies can detect if they are being executed on the CLI
and decide to do something different like not loading themselves.

Because some might require shared dict that is not available.
@mikz mikz changed the title [sandbox] expose arg [sandbox] environment policies have the same env as policy loader Feb 15, 2018
@mikz mikz requested a review from davidor February 15, 2018 07:37
@mikz mikz force-pushed the apicast-sandbox-env branch 2 times, most recently from 2855f21 to de53506 Compare February 15, 2018 07:40
@@ -0,0 +1,255 @@
--- Sandbox
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice refactor 👍
I think this module does not contain any apicast-specific code so it could potentially be extracted into its own library, and that's why it's in the resty directory. However, there are some comments that mention apicast and policies. I think we should get rid of them. For example, the description of the module mentions APIcast, and the comment for local env mentions policies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. I did not want to bother much with it now, but rather when it is extracted. Would that be ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

tonumber = tonumber, tostring = tostring, os = { getenv = resty_env.value },
pcall = pcall, require = require, assert = assert, error = error,
})
local box = sandbox.new()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs a comment explaining why we need the sandbox here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. We don't need one. But is is quite convenient way of adding some extra env and not using global variables. Will add it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@mikz mikz merged commit ec98c89 into master Feb 15, 2018
@mikz mikz deleted the apicast-sandbox-env branch February 15, 2018 12:19
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.

2 participants