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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .busted
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local default = {
verbose = true,
['shuffle-tests'] = true,
['shuffle-files'] = true,
lpath = path.join(root, 'spec/?.lua;') .. path.join(root, 'apicast/src/?.lua;'),
lpath = path.join(root, 'spec/?.lua;') .. path.join(root, 'gateway/src/?.lua;'),
}

if ci then
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ jobs:
- run: rm -rf lua_modules
- restore_cache:
keys:
- apicast-rocks-{{ arch }}-{{ checksum "apicast/Roverfile.lock" }}
- apicast-rocks-{{ arch }}-{{ checksum "gateway/Roverfile.lock" }}
- apicast-rocks-{{ arch }}-{{ .Branch }}
- apicast-rocks-{{ arch }}-master
- run: make dependencies
- save_cache:
key: apicast-rocks-{{ arch }}-{{ checksum "apicast/Roverfile.lock" }}
key: apicast-rocks-{{ arch }}-{{ checksum "gateway/Roverfile.lock" }}
paths:
- lua_modules
- run: mkdir -p tmp/junit
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Resolver can resolve nginx upstreams [PR #478](https://github.com/3scale/apicast/pull/478)
- Calls 3scale backend with the 'no_body' option enabled. This reduces network traffic in cases where APIcast does not need to parse the response body [PR #483](https://github.com/3scale/apicast/pull/483)

## Changed

- Namespace all APIcast code in `apicast` folder. Possible BREAKING CHANGE for some customizations. [PR #486](https://github.com/3scale/apicast/pull/486)

## [3.2.0-alpha1]

## Added
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ DEVEL_IMAGE ?= apicast-development
DEVEL_DOCKERFILE ?= Dockerfile-development
DEVEL_DOCKER_COMPOSE_FILE ?= docker-compose-devel.yml

S2I_CONTEXT ?= gateway

CIRCLE_NODE_INDEX ?= 0
CIRCLE_STAGE ?= build
COMPOSE_PROJECT_NAME ?= apicast_$(CIRCLE_STAGE)_$(CIRCLE_NODE_INDEX)
Expand Down Expand Up @@ -58,12 +60,12 @@ prove-docker: ## Test nginx inside docker
$(DOCKER_COMPOSE) run --rm -T prove | awk '/Result: NOTESTS/ { print "FAIL: NOTESTS"; print; exit 1 }; { print }'

builder-image: ## Build builder image
$(S2I) build . $(BUILDER_IMAGE) $(IMAGE_NAME) --context-dir=apicast --copy --incremental
$(S2I) build . $(BUILDER_IMAGE) $(IMAGE_NAME) --context-dir=$(S2I_CONTEXT) --copy --incremental

runtime-image: PULL_POLICY ?= always
runtime-image: IMAGE_NAME = apicast-runtime-test
runtime-image: ## Build runtime image
$(S2I) build . $(BUILDER_IMAGE) $(IMAGE_NAME) --context-dir=apicast --runtime-image=$(RUNTIME_IMAGE) --pull-policy=$(PULL_POLICY) --runtime-pull-policy=$(PULL_POLICY)
$(S2I) build . $(BUILDER_IMAGE) $(IMAGE_NAME) --context-dir=$(S2I_CONTEXT) --runtime-image=$(RUNTIME_IMAGE) --pull-policy=$(PULL_POLICY) --runtime-pull-policy=$(PULL_POLICY)

push: ## Push image to the registry
docker tag $(IMAGE_NAME) $(REGISTRY)/$(IMAGE_NAME)
Expand Down Expand Up @@ -124,10 +126,10 @@ rover: $(ROVER)
@echo $(ROVER)

dependencies: $(ROVER)
$(ROVER) install --roverfile=apicast/Roverfile
$(ROVER) install --roverfile=$(S2I_CONTEXT)/Roverfile

lua_modules/bin/rover:
@LUAROCKS_CONFIG=apicast/config-5.1.lua luarocks install --server=http://luarocks.org/dev lua-rover --tree lua_modules 1>&2
@LUAROCKS_CONFIG=$(S2I_CONTEXT)/config-5.1.lua luarocks install --server=http://luarocks.org/dev lua-rover --tree lua_modules 1>&2

clean-containers: apicast-source
$(DOCKER_COMPOSE) down --volumes
Expand Down
3 changes: 0 additions & 3 deletions apicast/conf.d/management.conf

This file was deleted.

11 changes: 0 additions & 11 deletions apicast/src/oauth.lua

This file was deleted.

8 changes: 0 additions & 8 deletions apicast/src/policy/echo.lua

This file was deleted.

2 changes: 1 addition & 1 deletion bin/apicast
2 changes: 1 addition & 1 deletion bin/cli
12 changes: 6 additions & 6 deletions doc/config.ld
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
file = {
'../apicast/src/proxy.lua',
'../apicast/src/configuration/service.lua',
'../apicast/src/resty/http_ng.lua',
'../apicast/src/resty/http_ng/backend/resty.lua',
'../apicast/src/backend_client.lua',
'../apicast/src/resty/synchronization.lua',
'../gateway/src/apicast/proxy.lua',
'../gateway/src/apicast/configuration/service.lua',
'../gateway/src/resty/http_ng.lua',
'../gateway/src/resty/http_ng/backend/resty.lua',
'../gateway/src/apicast/backend_client.lua',
'../gateway/src/resty/synchronization.lua',
}
dir = '../doc/api'
project = 'APIcast'
Expand Down
1 change: 0 additions & 1 deletion examples/configuration/echo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"host": "echo"
},
"policy_chain": [
{ "name": "policy.echo" },
{ "name": "apicast" }
],
"proxy_rules": [
Expand Down
4 changes: 2 additions & 2 deletions examples/custom-module/blacklist.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local apicast = require('apicast').new()
local apicast = require('apicast.policy.apicast').new()
local iputils = require("resty.iputils")
local default_balancer = require('balancer').default_balancer
local default_balancer = require('apicast.balancer').default_balancer
local resty_balancer = require('resty.balancer')

local _M = { _VERSION = '0.0' }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 12 additions & 12 deletions apicast/conf.d/apicast.conf → gateway/conf.d/apicast.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
set_by_lua $user_agent 'return require("user_agent")()';
set_by_lua $user_agent 'return require("apicast.user_agent")()';
set_by_lua_block $deployment {
local user_agent = require('user_agent')
local user_agent = require('apicast.user_agent')
return user_agent.platform() .. '+' .. user_agent.deployment()
}

# TODO: enable in the future when we support SSL
# ssl_certificate_by_lua_block { require('executor').call() }
# ssl_session_fetch_by_lua_block { require('executor').call() }
# ssl_session_store_by_lua_block { require('executor').call() }
# ssl_certificate_by_lua_block { require('apicast.executor').call() }
# ssl_session_fetch_by_lua_block { require('apicast.executor').call() }
# ssl_session_store_by_lua_block { require('apicast.executor').call() }

location = /___http_call {
internal;
Expand Down Expand Up @@ -48,11 +48,11 @@ location @out_of_band_authrep_action {

set_by_lua $original_request_time 'return ngx.var.request_time';

content_by_lua_block { require('executor'):post_action() }
content_by_lua_block { require('apicast.executor'):post_action() }

log_by_lua_block {
ngx.var.post_action_impact = ngx.var.request_time - ngx.var.original_request_time
require('executor'):log()
require('apicast.executor'):log()
}
}

Expand Down Expand Up @@ -81,12 +81,12 @@ location / {

proxy_ignore_client_abort on;

rewrite_by_lua_block { require('executor'):rewrite() }
access_by_lua_block { require('executor'):access() }
body_filter_by_lua_block { require('executor'):body_filter() }
header_filter_by_lua_block { require('executor'):header_filter() }
rewrite_by_lua_block { require('apicast.executor'):rewrite() }
access_by_lua_block { require('apicast.executor'):access() }
body_filter_by_lua_block { require('apicast.executor'):body_filter() }
header_filter_by_lua_block { require('apicast.executor'):header_filter() }

content_by_lua_block { require('executor'):content() }
content_by_lua_block { require('apicast.executor'):content() }

proxy_pass $proxy_pass;
proxy_http_version 1.1;
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions gateway/conf.d/management.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
location / {
content_by_lua_block { require('apicast.management').call() }
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions apicast/http.d/init.conf → gateway/http.d/init.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ init_by_lua_block {
require("resty.core")
require('resty.resolver').init()

local module = require('executor')
local module = require('apicast.executor')

if not module then
ngx.log(ngx.EMERG, 'fatal error when loading the root module')
Expand All @@ -21,7 +21,7 @@ init_by_lua_block {
}

init_worker_by_lua_block {
require('executor'):init_worker()
require('apicast.executor'):init_worker()
}

lua_shared_dict init 16k;
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
upstream upstream {
server 0.0.0.1:1;

balancer_by_lua_block { require('executor'):balancer() }
balancer_by_lua_block { require('apicast.executor'):balancer() }

keepalive 1024;
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion apicast/libexec/boot.lua → gateway/libexec/boot.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pcall(require, 'luarocks.loader')
package.path = package.path .. ";./src/?.lua"

local configuration = require 'configuration_loader'
local configuration = require 'apicast.configuration_loader'

local config = configuration.boot()

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local len = string.len
local format = string.format

local http_ng = require('resty.http_ng')
local user_agent = require('user_agent')
local user_agent = require('apicast.user_agent')
local resty_url = require('resty.url')
local resty_env = require('resty.env')

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ local mt = {}

local function load_commands(commands, argparse)
for i=1, #commands do
commands[commands[i]] = require('apicast.cli.' .. commands[i]).new(argparse)
commands[commands[i]] = require('apicast.cli.command.' .. commands[i]).new(argparse)
end
return commands
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ local concat = table.concat
local exec = require('resty.execvp')
local resty_env = require('resty.env')

local Template = require('apicast.template')
local configuration = require('apicast.configuration')
local Template = require('apicast.cli.template')
local configuration = require('apicast.cli.configuration')

local pl = {
path = require('pl.path'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ local inspect = require 'inspect'
local re = require 'ngx.re'
local env = require 'resty.env'
local resty_url = require 'resty.url'
local util = require 'util'
local policy_chain = require 'policy_chain'
local util = require 'apicast.util'
local policy_chain = require 'apicast.policy_chain'

local mt = { __index = _M, __tostring = function() return 'Configuration' end }

Expand Down Expand Up @@ -132,7 +132,7 @@ local function check_querystring_params(params, args)
return match
end

local Service = require 'configuration.service'
local Service = require 'apicast.configuration.service'

local noop = function() end
local function readonly_table(table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local select = select

local http_authorization = require 'resty.http_authorization'

local oauth = require('oauth')
local oauth = require('apicast.oauth')

local _M = { }
local mt = { __index = _M }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
local configuration_store = require('configuration_store')
local configuration_parser = require 'configuration_parser'
local mock_loader = require 'configuration_loader.mock'
local file_loader = require 'configuration_loader.file'
local remote_loader_v1 = require 'configuration_loader.remote_v1'
local remote_loader_v2 = require 'configuration_loader.remote_v2'
local util = require 'util'
local configuration_store = require('apicast.configuration_store')
local configuration_parser = require 'apicast.configuration_parser'
local mock_loader = require 'apicast.configuration_loader.mock'
local file_loader = require 'apicast.configuration_loader.file'
local remote_loader_v1 = require 'apicast.configuration_loader.remote_v1'
local remote_loader_v2 = require 'apicast.configuration_loader.remote_v2'
local util = require 'apicast.util'
local env = require('resty.env')
local resty_url = require('resty.url')
local synchronization = require('resty.synchronization').new(1)
Expand Down Expand Up @@ -55,7 +55,7 @@ local function ttl()
end

function _M.global(contents)
local context = require('executor'):context()
local context = require('apicast.executor'):context()

return _M.configure(context.configuration, contents)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local tostring = tostring
local open = io.open
local assert = assert
local sub = string.sub
local util = require 'util'
local util = require 'apicast.util'
local env = require 'resty.env'

local _M = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ local tonumber = tonumber
local resty_url = require 'resty.url'
local http = require "resty.resolver.http"
local socket_resolver = require('resty.resolver.socket')
local configuration_parser = require 'configuration_parser'
local user_agent = require 'user_agent'
local configuration_parser = require 'apicast.configuration_parser'
local user_agent = require 'apicast.user_agent'
local env = require 'resty.env'

local _M = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ local type = type

local resty_url = require 'resty.url'
local http_ng = require "resty.http_ng"
local user_agent = require 'user_agent'
local user_agent = require 'apicast.user_agent'
local cjson = require 'cjson'
local resty_env = require 'resty.env'
local re = require 'ngx.re'
local configuration = require 'configuration'
local configuration = require 'apicast.configuration'

local _M = {
_VERSION = '0.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local configuration = require 'configuration'
local configuration = require 'apicast.configuration'
local cjson = require 'cjson'

local type = type
Expand Down
14 changes: 8 additions & 6 deletions apicast/src/executor.lua → gateway/src/apicast/executor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
-- when calling the policy chain methods. This 'context' contains information
-- shared among policies.

local policy_chain = require('policy_chain')
local policy = require('policy')
local linked_list = require('linked_list')
require('apicast.loader') -- to load code from deprecated paths

local policy_chain = require('apicast.policy_chain')
local policy = require('apicast.policy')
local linked_list = require('apicast.linked_list')

local setmetatable = setmetatable

local _M = { }

local DEFAULT_POLICIES = {
'policy.load_configuration',
'policy.find_service',
'policy.local_chain'
'apicast.policy.load_configuration',
'apicast.policy.find_service',
'apicast.policy.local_chain'
}

local mt = { __index = _M }
Expand Down
File renamed without changes.
Loading