-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit ce18fc3.
- Loading branch information
juzhiyuan
committed
Jun 17, 2020
1 parent
cdf14d4
commit 4fef39c
Showing
48 changed files
with
4,968 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: API unit test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- manager | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: use docker-compose in api | ||
run: cd ./api && docker-compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# READMD for Dashboard | ||
|
||
This project is initialized with [Ant Design Pro](https://pro.ant.design). Follow is the quick guide for how to use. | ||
|
||
## Environment Prepare | ||
|
||
1. Make sure you have `Node.js` installed on your machine. | ||
2. Install [yarn](https://yarnpkg.com/). | ||
3. Install `node_modules`: | ||
|
||
```bash | ||
$ yarn | ||
``` | ||
|
||
### Start project | ||
|
||
```bash | ||
yarn start:no-mock | ||
``` | ||
|
||
### Build project | ||
|
||
```bash | ||
yarn build | ||
``` | ||
|
||
### Check code style | ||
|
||
```bash | ||
yarn lint | ||
``` | ||
|
||
You can also use script to auto fix some lint error: | ||
|
||
```bash | ||
yarn lint:fix | ||
``` | ||
|
||
### Test code | ||
|
||
```bash | ||
yarn test | ||
``` | ||
|
||
## More | ||
|
||
You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,12 @@ | ||
# READMD for Dashboard | ||
# Apache APISIX Dashboard | ||
|
||
This project is initialized with [Ant Design Pro](https://pro.ant.design). Follow is the quick guide for how to use. | ||
Dashboard for [Apache APISIX](https://github.com/apache/incubator-apisix-dashboard) | ||
|
||
## Environment Prepare | ||
## Deploy with Docker | ||
|
||
1. Make sure you have `Node.js` installed on your machine. | ||
2. Install [yarn](https://yarnpkg.com/). | ||
3. Install `node_modules`: | ||
|
||
```bash | ||
$ yarn | ||
``` | ||
|
||
### Start project | ||
|
||
```bash | ||
yarn start:no-mock | ||
``` | ||
|
||
### Build project | ||
|
||
```bash | ||
yarn build | ||
``` | ||
|
||
### Check code style | ||
|
||
```bash | ||
yarn lint | ||
``` | ||
|
||
You can also use script to auto fix some lint error: | ||
|
||
```bash | ||
yarn lint:fix | ||
``` | ||
|
||
### Test code | ||
|
||
```bash | ||
yarn test | ||
``` | ||
Please refer to [Deploy with Docker README](./compose/README.md) | ||
|
||
## More | ||
|
||
You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro). | ||
1. More infomation about the frontend Dashboard, please refer to [README for Dashboard](./README-dashboard.md) | ||
2. If you need the dashboard built with Vue.js, please refer to [master-vue](https://github.com/apache/incubator-apisix-dashboard/tree/master-vue). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
FROM golang:1.13.8 AS build-env | ||
|
||
WORKDIR /go/src/github.com/apisix/manager-api | ||
COPY . . | ||
RUN mkdir /root/manager-api \ | ||
&& go env -w GOPROXY=https://goproxy.io,direct \ | ||
&& export GOPROXY=https://goproxy.io \ | ||
&& go build -o /root/manager-api/manager-api \ | ||
&& mv /go/src/github.com/apisix/manager-api/build.sh /root/manager-api/ \ | ||
&& mv /go/src/github.com/apisix/manager-api/conf.json /root/manager-api/ \ | ||
&& rm -rf /go/src/github.com/apisix/manager-api \ | ||
&& rm -rf /etc/localtime \ | ||
&& ln -s /usr/share/zoneinfo/Hongkong /etc/localtime \ | ||
&& dpkg-reconfigure -f noninteractive tzdata | ||
|
||
FROM alpine:3.11 | ||
|
||
RUN mkdir /root/manager-api \ | ||
&& apk update \ | ||
&& apk add ca-certificates \ | ||
&& update-ca-certificates \ | ||
&& apk add --no-cache libc6-compat \ | ||
&& echo "hosts: files dns" > /etc/nsswitch.conf \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
|
||
WORKDIR /root/manager-api | ||
COPY --from=build-env /root/manager-api/* /root/manager-api/ | ||
COPY --from=build-env /usr/share/zoneinfo/Hongkong /etc/localtime | ||
EXPOSE 8080 | ||
RUN chmod +x ./build.sh | ||
CMD ["/root/manager-api/build.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- | ||
# | ||
# 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. | ||
# | ||
--> | ||
|
||
# manager-api | ||
|
||
This is a back-end project that the dashboard depends on, implemented through golang. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
# | ||
# 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. | ||
# | ||
|
||
pwd=`pwd` | ||
|
||
sed -i -e "s%#mysqlAddress#%`echo $MYSQL_SERVER_ADDRESS`%g" ${pwd}/conf.json | ||
sed -i -e "s%#mysqlUser#%`echo $MYSQL_USER`%g" ${pwd}/conf.json | ||
sed -i -e "s%#mysqlPWD#%`echo $MYSQL_PASSWORD`%g" ${pwd}/conf.json | ||
sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json | ||
sed -i -e "s%#apisixBaseUrl#%`echo $APISIX_BASE_URL`%g" ${pwd}/conf.json | ||
sed -i -e "s%#apisixApiKey#%`echo $APISIX_API_KEY`%g" ${pwd}/conf.json | ||
|
||
cd /root/manager-api | ||
exec ./manager-api | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"conf": { | ||
"mysql":{ | ||
"address": "#mysqlAddress#", | ||
"user": "#mysqlUser#", | ||
"password": "#mysqlPWD#", | ||
"maxConns": 50, | ||
"maxIdleConns": 25, | ||
"maxLifeTime": 10 | ||
}, | ||
"syslog": { | ||
"host": "#syslogAddress#" | ||
}, | ||
"apisix": { | ||
"base_url": "#apisixBaseUrl#", | ||
"api_key": "#apisixApiKey#" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package conf | ||
|
||
import ( | ||
"fmt" | ||
"github.com/tidwall/gjson" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"runtime" | ||
) | ||
|
||
const ServerPort = 8080 | ||
const PROD = "prod" | ||
const BETA = "beta" | ||
const DEV = "dev" | ||
const LOCAL = "local" | ||
const confPath = "/root/manager-api/conf.json" | ||
const RequestId = "requestId" | ||
|
||
var ( | ||
ENV string | ||
basePath string | ||
ApiKey = "edd1c9f034335f136f87ad84b625c8f1" | ||
BaseUrl = "http://127.0.0.1:9080/apisix/admin" | ||
) | ||
|
||
func init() { | ||
setEnvironment() | ||
initMysql() | ||
initApisix() | ||
} | ||
|
||
func setEnvironment() { | ||
if env := os.Getenv("ENV"); env == "" { | ||
ENV = LOCAL | ||
} else { | ||
ENV = env | ||
} | ||
_, basePath, _, _ = runtime.Caller(1) | ||
} | ||
|
||
func configurationPath() string { | ||
if ENV == LOCAL { | ||
return filepath.Join(filepath.Dir(basePath), "conf.json") | ||
} else { | ||
return confPath | ||
} | ||
} | ||
|
||
type mysqlConfig struct { | ||
Address string | ||
User string | ||
Password string | ||
|
||
MaxConns int | ||
MaxIdleConns int | ||
MaxLifeTime int | ||
} | ||
|
||
var MysqlConfig mysqlConfig | ||
|
||
func initMysql() { | ||
filePath := configurationPath() | ||
if configurationContent, err := ioutil.ReadFile(filePath); err != nil { | ||
panic(fmt.Sprintf("fail to read configuration: %s", filePath)) | ||
} else { | ||
configuration := gjson.ParseBytes(configurationContent) | ||
mysqlConf := configuration.Get("conf.mysql") | ||
MysqlConfig.Address = mysqlConf.Get("address").String() | ||
MysqlConfig.User = mysqlConf.Get("user").String() | ||
MysqlConfig.Password = mysqlConf.Get("password").String() | ||
MysqlConfig.MaxConns = int(mysqlConf.Get("maxConns").Int()) | ||
MysqlConfig.MaxIdleConns = int(mysqlConf.Get("maxIdleConns").Int()) | ||
MysqlConfig.MaxLifeTime = int(mysqlConf.Get("maxLifeTime").Int()) | ||
} | ||
} | ||
|
||
func initApisix() { | ||
filePath := configurationPath() | ||
if configurationContent, err := ioutil.ReadFile(filePath); err != nil { | ||
panic(fmt.Sprintf("fail to read configuration: %s", filePath)) | ||
} else { | ||
configuration := gjson.ParseBytes(configurationContent) | ||
apisixConf := configuration.Get("conf.apisix") | ||
BaseUrl = apisixConf.Get("base_url").String() | ||
ApiKey = apisixConf.Get("api_key").String() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"conf":{ | ||
"mysql":{ | ||
"address": "127.0.0.1:3306", | ||
"user": "root", | ||
"password": "123456", | ||
"maxConns": 50, | ||
"maxIdleConns": 25, | ||
"maxLifeTime": 10 | ||
}, | ||
"syslog":{ | ||
"host": "localhost" | ||
}, | ||
"apisix":{ | ||
"base_url": "http://127.0.0.1:9080/apisix/admin", | ||
"api_key": "edd1c9f034335f136f87ad84b625c8f1" | ||
} | ||
} | ||
} |
Oops, something went wrong.