Commit 4e90d54c authored by kewei.jia's avatar kewei.jia

删除注释代码

parent 57b99a7e
...@@ -13,19 +13,10 @@ router.get('/', async ctx => { ...@@ -13,19 +13,10 @@ router.get('/', async ctx => {
}) })
router.post('/create', async ctx => { router.post('/create', async ctx => {
let { type, serviceName, namespace, image, system_name ,lable} = ctx.request.body let {type, serviceName, namespace, image, system_name, lable} = ctx.request.body
if (!TYPES.includes(type)) { if (!TYPES.includes(type)) {
return ctx.body = ctx.fail('不支持的服务类型') return ctx.body = ctx.fail('不支持的服务类型')
} }
// try {
// let svc = await ctx.cluster.service_get(serviceName, namespace)
// if (svc) {
// return ctx.body = ctx.fail('服务已经存在')
// }
// } catch (e) {
// }
let data = { let data = {
serviceName, serviceName,
namespace, namespace,
...@@ -44,7 +35,7 @@ router.post('/create', async ctx => { ...@@ -44,7 +35,7 @@ router.post('/create', async ctx => {
return data[arguments[1]] return data[arguments[1]]
}) })
let params = yaml.load(template) let params = yaml.load(template)
await ctx.cluster.service_create(params,type) await ctx.cluster.service_create(params, type)
ctx.body = ctx.ok('创建成功') ctx.body = ctx.ok('创建成功')
}) })
router.post('/details', async ctx => { router.post('/details', async ctx => {
......
This diff is collapsed.
...@@ -27,14 +27,10 @@ class Cluster extends Client { ...@@ -27,14 +27,10 @@ class Cluster extends Client {
return this.post('DescribeClusterServiceInfo', {serviceName, namespace, clusterId: this.clusterId}) return this.post('DescribeClusterServiceInfo', {serviceName, namespace, clusterId: this.clusterId})
} }
async service_create(params,type) { async service_create(params, type) {
params.clusterId = this.clusterId params.clusterId = this.clusterId
let str = JSON.stringify(params) let str = JSON.stringify(params)
await this.post('CreateClusterService', params) await this.post('CreateClusterService', params)
// 腾讯云api暂只能通过修改服务来改成Recreate策略
// let modifyParams = JSON.parse(str)
// modifyParams.strategy = 'Recreate'
// return this.post('ModifyClusterService', modifyParams)
let updateLabels = { let updateLabels = {
clusterId: params.clusterId, clusterId: params.clusterId,
serviceName: params.serviceName, serviceName: params.serviceName,
...@@ -50,9 +46,9 @@ class Cluster extends Client { ...@@ -50,9 +46,9 @@ class Cluster extends Client {
} }
service_modifyImage(serviceName, image, namespace) { service_modifyImage(serviceName, image, namespace) {
// 修改示例的第一个容器
return this.post('ModifyClusterServiceImage', {serviceName, namespace, image, clusterId: this.clusterId}) return this.post('ModifyClusterServiceImage', {serviceName, namespace, image, clusterId: this.clusterId})
} }
ingress_get(namespace) { ingress_get(namespace) {
return this.post('DescribeIngress', {namespace, clusterId: this.clusterId}) return this.post('DescribeIngress', {namespace, clusterId: this.clusterId})
} }
......
...@@ -3,7 +3,7 @@ const crypto = require('crypto') ...@@ -3,7 +3,7 @@ const crypto = require('crypto')
const domainConfig = require('../config') const domainConfig = require('../config')
class Client { class Client {
constructor () { constructor() {
this.secretId = domainConfig.secretId this.secretId = domainConfig.secretId
this.secretKey = domainConfig.secretKey this.secretKey = domainConfig.secretKey
this.region = domainConfig.region this.region = domainConfig.region
...@@ -18,7 +18,7 @@ class Client { ...@@ -18,7 +18,7 @@ class Client {
this.defaultNamespaces = ['default', 'kube-system', 'kube-public'] this.defaultNamespaces = ['default', 'kube-system', 'kube-public']
} }
sign (params, signMethod) { sign(params, signMethod) {
let str = '' let str = ''
let keys = Object.keys(params) let keys = Object.keys(params)
keys.sort() keys.sort()
...@@ -43,7 +43,7 @@ class Client { ...@@ -43,7 +43,7 @@ class Client {
// Nonce: null, // Nonce: null,
// SecretId: '', // SecretId: '',
// Signature: '' // Signature: ''
formatRequestData (action, params = {}) { formatRequestData(action, params = {}) {
params.Action = action params.Action = action
params.Region = this.region params.Region = this.region
params.Timestamp = Math.round(Date.now() / 1000) params.Timestamp = Math.round(Date.now() / 1000)
...@@ -53,7 +53,7 @@ class Client { ...@@ -53,7 +53,7 @@ class Client {
params.Signature = this.sign(params, params.SignatureMethod) params.Signature = this.sign(params, params.SignatureMethod)
} }
post (action, params = {}) { post(action, params = {}) {
if (params.namespace && this.defaultNamespaces.includes(params.namespace)) { if (params.namespace && this.defaultNamespaces.includes(params.namespace)) {
return Promise.reject(new Error('未授权的namespace')) return Promise.reject(new Error('未授权的namespace'))
} }
...@@ -81,80 +81,6 @@ class Client { ...@@ -81,80 +81,6 @@ class Client {
}) })
}) })
} }
// namespace_get () {
// return this.post('DescribeClusterNameSpaces', {clusterId: this.clusterId})
// }
//
// namespace_create (name) {
// return this.post('CreateClusterNamespace', {name, description: '', clusterId: this.clusterId})
// }
//
// namespace_delete (name) {
// return this.post('DeleteClusterNamespace', {"names.0": name, clusterId: this.clusterId})
// }
// service_list (namespace) {
// return this.post('DescribeClusterService', {namespace, clusterId: this.clusterId, allnamespace: 0})
// }
//
// service_get (serviceName, namespace) {
// return this.post('DescribeClusterServiceInfo', {serviceName, namespace, clusterId: this.clusterId})
// }
//
// async service_create (params) {
// params.clusterId = this.clusterId
// let str = JSON.stringify(params)
// await this.post('CreateClusterService', params)
// // 腾讯云api暂只能通过修改服务来改成Recreate策略
// let modifyParams = JSON.parse(str)
// modifyParams.strategy = 'Recreate'
// return this.post('ModifyClusterService', modifyParams)
// }
//
// service_delete (serviceName, namespace) {
// return this.post('DeleteClusterService', {serviceName, namespace, clusterId: this.clusterId})
// }
//
// service_modifyImage (serviceName, image, namespace) {
// // 修改示例的第一个容器
// return this.post('ModifyClusterServiceImage', {serviceName, namespace, image, clusterId: this.clusterId})
// }
//
// ingress_get (namespace) {
// return this.post('DescribeIngress', {namespace, clusterId: this.clusterId})
// }
//
// ingress_create (namespace) {
// return this.post('CreateIngress', {ingressName: `qa-${namespace}`, ingressDesc: '', namespace, clusterId: this.clusterId})
// }
//
// ingress_delete (ingressName, namespace) {
// return this.post('DeleteIngress', {ingressName, namespace, clusterId: this.clusterId})
// }
//
// ingress_modify (ingressName, namespace, rules) {
// return this.post('MosifyIngress', {ingressName, namespace, ...rules, clusterId: this.clusterId})
// }
//腾讯仓库列表
// repository_get(namespace1, reponame1) {
// return this.post('SearchUserRepository', {reponame})
// }
} }
module.exports = Client module.exports = Client
// exports.create = function (config) {
// return new Client(config)
// }
// let client = new Client({
// secretId: 'AKID4rY7wwNphsUcaFsy1pRtKhQvDj4CA3Ac',
// secretKey: 'YBduRnjgVRGzmagZJbss3Vo58wWCyhgc',
// clusterId: 'cls-acfx4pvj',
// region: 'ap-beijing'
// })
// client.post('DescribeClusterNameSpaces', {clusterId: 'cls-acfx4pvj'}).then(res => {
// console.log(5, res)
// })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment