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

namespace all apicast source code #486

Merged
merged 7 commits into from
Nov 21, 2017
Merged

namespace all apicast source code #486

merged 7 commits into from
Nov 21, 2017

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Nov 20, 2017

tl;dr

From now instead of require('policy') use require('apicast.policy'). All APIcast source code is in the apicast namespace.


Right now APIcast is polluting global namespace with its source files.
As more dependencies are installed there is higher chance of a clash.
So we need to namespace all APIcast source code in apicast folder inside
the Lua load path.

To prevent weird paths like apicast/apicast/src/apicast this also renames the
folder that contains all APIcast distributed source from apicast to gateway.

Print deprecation warnings when old code refers to new paths:

2017/11/20 17:11:13 [warn] 91413#25180842: [lua] loader.lua:18: DEPRECATION: when loading apicast code use correct prefix: require("apicast.policy_chain")
2017/11/20 17:11:13 [warn] 91413#25180842: [lua] loader.lua:18: DEPRECATION: when loading apicast code use correct prefix: require("apicast.policy")
2017/11/20 17:11:13 [warn] 91413#25180842: [lua] loader.lua:18: DEPRECATION: when loading apicast code use correct prefix: require("apicast.linked_list")
2017/11/20 17:11:13 [warn] 91413#25180842: [lua] loader.lua:29: DEPRECATION: file renamed, change: require("apicast") to: require("apicast.policy.apicast")

Please note the benchmark does not work because the new configuration is not compatible with the old one. But the old one should be compatible with the new one.

Also note that if someone was overriding a path of APIcast then it will stop working after this change.
Requiring old files continue to work with a deprecation warning, but overriding those files on old paths
will not be taken into effect in the APIcast codebase. This is potential BREAKING CHANGE for some customizations.

Another interesting change is the echo policy. Now it short circuits the upstream api and responds directly in the rewrite phase stopping everything else.

/cc @3scale/support

* to not have too many things named apicast
* because that directory will include another apicast folder with lua sources
* `apicast/apicast/src/apicast` would look really silly
* all related files to the cli should be in `apicast/cli`
@mikz mikz force-pushed the rename-global-namespace branch 3 times, most recently from 73e7c53 to 1ce43dc Compare November 21, 2017 09:38
@mikz mikz changed the title [wip] namespace all apicast source code namespace all apicast source code Nov 21, 2017
@mikz mikz requested a review from davidor November 21, 2017 09:41
mikz added 2 commits November 21, 2017 10:46
so we don't pollute global namespace with files
and prevent clashes when new dependencies are installed
this is going to be a breaking change for policies that previously
required apicast policy
@mikz mikz force-pushed the rename-global-namespace branch from 1ce43dc to acb0fba Compare November 21, 2017 09:46
@@ -0,0 +1,51 @@
local loadfile = loadfile
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 It would be good to document the purpose of this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, good point :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be addressed in b1d677a.


__DATA__

=== TEST 1: authentication credentials missing
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd change the title and description of the test so they make reference to what is actually being tested 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.

hah, yeah my copy paste issue
well spotted

Copy link
Contributor

Choose a reason for hiding this comment

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

👀

Copy link
Contributor

@davidor davidor left a comment

Choose a reason for hiding this comment

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

A bit scary, but looks good. 👍

mikz added 3 commits November 21, 2017 12:06
* custom loader can try to load files from new paths
  even when the caller code refers to the old ones
* print deprecation warnings with suggestions how to fix them
* makes it way easier in tests to not stub upstream
@mikz mikz force-pushed the rename-global-namespace branch from 109e5cb to a12a22c Compare November 21, 2017 11:07
@mikz mikz merged commit 632d0f3 into master Nov 21, 2017
@mikz mikz deleted the rename-global-namespace branch November 21, 2017 14:26
mikz added a commit that referenced this pull request Nov 21, 2017
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