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

feat: load etcd configuration when apisix starts #3799

Merged
merged 1 commit into from
Mar 12, 2021
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
14 changes: 10 additions & 4 deletions apisix/cli/etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

local base64_encode = require("base64").encode
local dkjson = require("dkjson")
local constants = require("apisix.constants")
local util = require("apisix.cli.util")
local file = require("apisix.cli.file")
local http = require("socket.http")
Expand All @@ -25,6 +26,7 @@ local ltn12 = require("ltn12")

local type = type
local ipairs = ipairs
local pairs = pairs
local print = print
local tonumber = tonumber
local str_format = string.format
Expand Down Expand Up @@ -248,11 +250,15 @@ function _M.init(env, args)
end


for _, dir_name in ipairs({"/routes", "/upstreams", "/services",
"/plugins", "/consumers", "/ssl",
"/global_rules", "/stream_routes", "/proto",
"/plugin_metadata", "/plugin_configs"}) do
local dirs = {}
for name in pairs(constants.HTTP_ETCD_DIRECTORY) do
dirs[name] = true
end
for name in pairs(constants.STREAM_ETCD_DIRECTORY) do
dirs[name] = true
end

for dir_name in pairs(dirs) do
local key = (etcd_conf.prefix or "") .. dir_name .. "/"

local put_url = host .. "/v3/kv/put"
Expand Down
38 changes: 38 additions & 0 deletions apisix/constants.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
return {
HTTP_ETCD_DIRECTORY = {
["/upstreams"] = true,
["/plugins"] = true,
["/ssl"] = true,
["/stream_routes"] = true,
["/plugin_metadata"] = true,
["/routes"] = true,
["/services"] = true,
["/consumers"] = true,
["/global_rules"] = true,
["/proto"] = true,
["/plugin_configs"] = true,
},
STREAM_ETCD_DIRECTORY = {
["/upstreams"] = true,
["/plugins"] = true,
["/ssl"] = true,
["/stream_routes"] = true,
["/plugin_metadata"] = true,
},
}
Loading