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

Proxy: use a global switch for Filter Middleware #501

Merged
merged 5 commits into from
Aug 17, 2018

Conversation

marwan-at-work
Copy link
Contributor

Fixes last part of #495

@codecov-io
Copy link

codecov-io commented Aug 17, 2018

Codecov Report

Merging #501 into master will decrease coverage by 0.06%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #501      +/-   ##
=========================================
- Coverage   41.26%   41.2%   -0.07%     
=========================================
  Files          99      99              
  Lines        2828    2830       +2     
=========================================
- Hits         1167    1166       -1     
- Misses       1552    1554       +2     
- Partials      109     110       +1
Impacted Files Coverage Δ
cmd/proxy/actions/app.go 66.29% <0%> (-2.68%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0e8037...0d02286. Read the comment docs.

@@ -118,6 +119,7 @@ func (f *Filter) initFromConfig() {
lines, err := getConfigLines()

if err != nil || len(lines) == 0 {
f.Off = true
Copy link
Member

Choose a reason for hiding this comment

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

can we also have a ENV override? what do you think? even with a filter file provided, we could turn it off

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michalpristas I like that. I'll add one. I think the Filter should be Off by default unless provided with an actual configuration (or ENV override). But once we have Olympus working well, then maybe the Filter should be On by default unless the user explicitly turns it off by ENV only.

Copy link
Member

Choose a reason for hiding this comment

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

Could we also skip the whole middleware if the environment var is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michalpristas i liked your ENV idea more than my "Off" idea that I basically removed my code 😄 -- it's much easier to just not use the middleware at all if we want it off.

@marwan-at-work marwan-at-work changed the title Proxy: do not redirect on filter.Include Proxy: use a global switch for Filter Middleware Aug 17, 2018
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

nice

// It defaults to "true" until Olympus is the default
// place to grab modules before the Proxy.
func FilterOff() bool {
return envy.Get("PROXY_FILTER_OFF", "true") == "true"
Copy link

Choose a reason for hiding this comment

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

Should the envy call default to false as the check is whether the filter is off?

like envy.Get("PROXY_FILTER_OFF", "false") == "true"
if PROXY_FILTER_OFF was true, result would be true
if PROXY_FILTER_OFF was 'false' result would be false

the way it is now, with default of true, if the user does not set PROXY_FILTER_OFF the result will be true.

Copy link

Choose a reason for hiding this comment

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

I guess not, re-reading the comment clears that up. :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes by default, it's just the Proxy, no filtering needed. But we will use Olympus by default once Olympus is ready.

// It defaults to "true" until Olympus is the default
// place to grab modules before the Proxy.
func FilterOff() bool {
return envy.Get("PROXY_FILTER_OFF", "true") == "true"
Copy link

Choose a reason for hiding this comment

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

I guess not, re-reading the comment clears that up. :D

@marwan-at-work marwan-at-work merged commit 70167dc into gomods:master Aug 17, 2018
@marwan-at-work
Copy link
Contributor Author

@michalpristas merging this to unblock myself and @carolynvs -- feel free to make comments if you have any and I'll open another PR :)

@@ -113,7 +113,9 @@ func App() (*buffalo.App, error) {
app.Stop(err)
}
app.Use(T.Middleware())
app.Use(newFilterMiddleware(mf))
if !env.FilterOff() {
Copy link
Member

Choose a reason for hiding this comment

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

👍

marpio pushed a commit to marpio/athens that referenced this pull request Aug 20, 2018
* Proxy: do not redirect on filter.Include

* Filter: add Off opt

* Filter: set Off to true when there's no config

* Proxy: use a global switch for filter
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