Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-api
Commits
3c790b94
Commit
3c790b94
authored
Apr 24, 2020
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
statistic
parent
4fc93e46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
k8s.js
app/controller/k8s.js
+17
-3
ProConfig.js
app/model/mongo/qa_api/ProConfig.js
+1
-1
No files found.
app/controller/k8s.js
View file @
3c790b94
const
Router
=
require
(
'
koa-router
'
);
const
Router
=
require
(
'
koa-router
'
);
const
bodyParser
=
require
(
'
koa-bodyparser
'
)
const
config
=
require
(
'
../../src
'
);
const
config
=
require
(
'
../../src
'
);
const
{
StatisticsLog
}
=
require
(
'
../service/mongoService
'
);
const
api
=
async
function
(
ctx
)
{
const
api
=
async
function
(
ctx
)
{
await
ctx
.
pipe
({
await
ctx
.
pipe
({
uri
:
config
.
api
.
tke_api
+
ctx
.
url
.
replace
(
'
/k8s
'
,
''
),
uri
:
config
.
api
.
tke_api
+
ctx
.
url
.
replace
(
'
/k8s
'
,
''
),
})
})
if
(
ctx
.
request
.
method
===
'
POST
'
&&
ctx
.
response
.
status
===
200
&&
ctx
.
request
.
url
.
indexOf
(
'
/service
'
)
!==
-
1
)
{
const
user
=
await
ctx
.
redisGet
(
config
.
QA_TOKEN
,
ctx
.
request
.
header
[
'
x-token
'
])
const
body
=
ctx
.
request
.
body
const
data
=
{
namespace
:
body
.
namespace
,
active
:
ctx
.
request
.
url
.
replace
(
'
/k8s/
'
,
''
).
replace
(
'
/
'
,
'
_
'
),
microservice_name
:
body
.
serviceName
,
user
:
user
&&
user
.
cn
,
user_mail
:
user
&&
user
.
mail
,
detail
:
body
,
}
await
StatisticsLog
.
saveLog
(
data
);
}
}
}
const
router
=
new
Router
();
const
router
=
new
Router
();
router
router
.
use
(
bodyParser
())
.
get
(
'
/*
'
,
api
)
.
get
(
'
/*
'
,
api
)
.
post
(
'
/*
'
,
api
)
.
post
(
'
/*
'
,
api
)
module
.
exports
=
router
module
.
exports
=
router
app/model/mongo/qa_api/ProConfig.js
View file @
3c790b94
...
@@ -42,7 +42,7 @@ const schema = new Schema({
...
@@ -42,7 +42,7 @@ const schema = new Schema({
})
})
schema
.
statics
.
getActiveProjectsHostName
=
function
()
{
schema
.
statics
.
getActiveProjectsHostName
=
function
()
{
return
this
.
find
({
des
:
{
$ne
:
'
海外
'
}
,
is_active
:
1
}).
select
([
'
host_name
'
,
'
project_name
'
,
'
type
'
]).
lean
().
then
((
res
)
=>
{
return
this
.
find
({
des
:
{
$ne
:
'
海外
'
}
}).
select
([
'
host_name
'
,
'
project_name
'
,
'
type
'
]).
lean
().
then
((
res
)
=>
{
const
reg
=
/^
([\w
-
\.]
+
)\.[\w
-
]
+
\.[
a-z
]
+$/
const
reg
=
/^
([\w
-
\.]
+
)\.[\w
-
]
+
\.[
a-z
]
+$/
// 转为对象形式
// 转为对象形式
const
o
=
res
.
reduce
((
prev
,
next
)
=>
{
const
o
=
res
.
reduce
((
prev
,
next
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment