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
36cba627
Commit
36cba627
authored
Dec 15, 2019
by
智勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getLatestSvcDB
parent
6c9f2f1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
proconfig.js
app/controller/proconfig.js
+43
-0
ProConfig.js
app/model/mongo/qa_api/ProConfig.js
+1
-0
No files found.
app/controller/proconfig.js
View file @
36cba627
...
...
@@ -3,6 +3,8 @@ const bodyParser = require('koa-bodyparser')
const
_
=
require
(
'
lodash
'
)
const
{
ProConfig
}
=
require
(
'
../service/mongoService
'
)
const
config
=
require
(
global
.
configPath
)
const
getProjectByType
=
async
function
(
ctx
)
{
let
item
=
await
ProConfig
.
findByQuery
({
des
:
{
$ne
:
'
海外
'
}
},
{},
{
project_name
:
1
})
item
=
_
.
groupBy
(
item
,
'
type
'
)
...
...
@@ -135,6 +137,46 @@ const getK8sConf = async function (ctx) {
ctx
.
body
=
ctx
.
ok
(
item
)
}
const
subSet
=
function
(
arr1
,
arr2
)
{
const
set1
=
new
Set
(
arr1
);
const
set2
=
new
Set
(
arr2
);
const
subset
=
[];
for
(
const
item
of
set1
)
{
if
(
!
set2
.
has
(
item
))
{
subset
.
push
(
item
);
}
}
return
subset
;
};
const
getLatestSvcDB
=
async
(
ctx
)
=>
{
const
ns
=
ctx
.
request
.
query
.
namespace
const
res
=
await
ctx
.
curl
({
uri
:
`
${
config
.
api
.
tke_api
}
/service?namespace=
${
ns
}
`
,
method
:
'
get
'
,
headers
:
{
cluster
:
ctx
.
request
.
headers
.
cluster
||
'
qa
'
,
},
})
const
allDB
=
[]
const
notLatestDB
=
[]
const
svcs
=
_
.
get
(
res
,
'
body.data.services
'
,
[])
for
(
const
i
of
svcs
)
{
if
(
i
.
labels
.
type
===
'
java
'
)
{
const
proconfig
=
await
ProConfig
.
getOneProject
({
project_name
:
i
.
serviceName
},
{
database
:
1
,
_id
:
0
})
if
(
proconfig
.
database
)
{
allDB
.
push
(...
proconfig
.
database
.
split
(
'
'
))
if
(
i
.
image
.
indexOf
(
'
latest
'
)
===
-
1
&&
i
.
image
.
indexOf
(
'
:master-
'
)
===
-
1
)
{
notLatestDB
.
push
(...
proconfig
.
database
.
split
(
'
'
))
}
}
}
}
const
latestDB
=
subSet
(
allDB
,
notLatestDB
)
ctx
.
body
=
latestDB
.
join
(
'
'
)
}
const
router
=
new
Router
()
router
.
use
(
bodyParser
())
...
...
@@ -148,5 +190,6 @@ router
.
get
(
'
/get_type
'
,
getType
)
.
get
(
'
/getHostName
'
,
getDomain
)
.
get
(
'
/getK8sConf
'
,
getK8sConf
)
.
get
(
'
/getLatestSvcDB
'
,
getLatestSvcDB
)
module
.
exports
=
router
app/model/mongo/qa_api/ProConfig.js
View file @
36cba627
...
...
@@ -30,6 +30,7 @@ const schema = new Schema({
api
:
{
type
:
String
},
ddl
:
{
type
:
String
},
wiki
:
{
type
:
String
},
database
:
{
type
:
String
},
cpuRequest
:
{
type
:
Number
},
cpuLimit
:
{
type
:
Number
},
memRequest
:
{
type
:
Number
},
...
...
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