mirror of
https://github.com/certd/certd.git
synced 2026-04-05 07:20:56 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
991c3dbb76 | ||
|
|
399c23623d | ||
|
|
2232f21b48 | ||
|
|
e41c084381 | ||
|
|
520b27e0dc |
@@ -2,5 +2,5 @@
|
||||
"packages": [
|
||||
"packages/*/*"
|
||||
],
|
||||
"version": "0.1.15"
|
||||
"version": "0.1.16"
|
||||
}
|
||||
|
||||
2
packages/core/api/package-lock.json
generated
2
packages/core/api/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/api",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/api",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"type": "module",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import _ from 'lodash-es'
|
||||
import logger from '../utils/util.log.js'
|
||||
import commonUtil from '../utils/util.common.js'
|
||||
export class AbstractDnsProvider {
|
||||
constructor ({ accessProviders }) {
|
||||
this.logger = logger
|
||||
this.accessProviders = accessProviders
|
||||
this.accessProviders = commonUtil.arrayToMap(accessProviders)
|
||||
}
|
||||
|
||||
async createRecord ({ fullRecord, type, value }) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs'
|
||||
import logger from '../utils/util.log.js'
|
||||
import dayjs from 'dayjs'
|
||||
import Sleep from '../utils/util.sleep.js'
|
||||
|
||||
import commonUtil from '../utils/util.common.js'
|
||||
export class AbstractPlugin {
|
||||
constructor (options) {
|
||||
if (options == null) {
|
||||
@@ -10,7 +10,7 @@ export class AbstractPlugin {
|
||||
}
|
||||
const { accessProviders } = options
|
||||
this.logger = logger
|
||||
this.accessProviders = accessProviders
|
||||
this.accessProviders = commonUtil.arrayToMap(accessProviders)
|
||||
}
|
||||
|
||||
appendTimeSuffix (name) {
|
||||
@@ -65,10 +65,14 @@ export class AbstractPlugin {
|
||||
}
|
||||
|
||||
getAccessProvider (accessProvider, accessProviders = this.accessProviders) {
|
||||
let access = accessProvider
|
||||
if (typeof accessProvider === 'string' && accessProviders) {
|
||||
accessProvider = accessProviders[accessProvider]
|
||||
access = accessProviders[accessProvider]
|
||||
}
|
||||
return accessProvider
|
||||
if (access == null) {
|
||||
throw new Error(`accessProvider :${accessProvider}不存在`)
|
||||
}
|
||||
return access
|
||||
}
|
||||
|
||||
async sleep (time) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import logger from './util.log.js'
|
||||
import path from './util.path.js'
|
||||
import { request } from './util.request.js'
|
||||
import sleep from './util.sleep.js'
|
||||
import common from './util.common.js'
|
||||
export const util = {
|
||||
logger, path, request, sleep
|
||||
logger, path, request, sleep, common
|
||||
}
|
||||
|
||||
33
packages/core/api/src/utils/util.common.js
Normal file
33
packages/core/api/src/utils/util.common.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import _ from 'lodash-es'
|
||||
export default {
|
||||
arrayToMap (array) {
|
||||
if (!array) {
|
||||
return {}
|
||||
}
|
||||
if (!_.isArray(array)) {
|
||||
return array
|
||||
}
|
||||
const map = {}
|
||||
for (const item of array) {
|
||||
if (item.key) {
|
||||
map[item.key] = item
|
||||
}
|
||||
}
|
||||
return map
|
||||
},
|
||||
mapToArray (map) {
|
||||
if (!map) {
|
||||
return []
|
||||
}
|
||||
if (_.isArray(map)) {
|
||||
return map
|
||||
}
|
||||
const array = []
|
||||
for (const key in map) {
|
||||
const item = map[key]
|
||||
item.key = key
|
||||
array.push(item)
|
||||
}
|
||||
return array
|
||||
}
|
||||
}
|
||||
2
packages/core/certd/package-lock.json
generated
2
packages/core/certd/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/certd",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/certd",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"description": "a ssl cert keeper",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
@@ -11,7 +11,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@certd/acme-client": "^0.1.6",
|
||||
"@certd/api": "^0.1.15",
|
||||
"@certd/api": "^0.1.16",
|
||||
"dayjs": "^1.9.7",
|
||||
"lodash-es": "^4.17.20",
|
||||
"node-forge": "^0.10.0"
|
||||
|
||||
2
packages/core/executor/package-lock.json
generated
2
packages/core/executor/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/executor",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/executor",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
@@ -10,15 +10,15 @@
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@certd/api": "^0.1.15",
|
||||
"@certd/certd": "^0.1.15",
|
||||
"@certd/api": "^0.1.16",
|
||||
"@certd/certd": "^0.1.16",
|
||||
"dayjs": "^1.9.7",
|
||||
"lodash-es": "^4.17.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/plugin-aliyun": "^0.1.15",
|
||||
"@certd/plugin-host": "^0.1.15",
|
||||
"@certd/plugin-tencent": "^0.1.15",
|
||||
"@certd/plugin-aliyun": "^0.1.16",
|
||||
"@certd/plugin-host": "^0.1.16",
|
||||
"@certd/plugin-tencent": "^0.1.16",
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.0.1",
|
||||
|
||||
@@ -23,6 +23,7 @@ export class Executor {
|
||||
async run (options) {
|
||||
logger.info('------------------- Cert-D ---------------------')
|
||||
try {
|
||||
this.transfer(options)
|
||||
options = _.merge(createDefaultOptions(), options)
|
||||
return await this.doRun(options)
|
||||
} catch (e) {
|
||||
@@ -31,6 +32,19 @@ export class Executor {
|
||||
}
|
||||
}
|
||||
|
||||
transfer (options) {
|
||||
const providers = options.accessProviders
|
||||
if (_.isArray(providers)) {
|
||||
const map = {}
|
||||
for (const provider of providers) {
|
||||
if (provider.key) {
|
||||
map[provider.key] = provider
|
||||
}
|
||||
}
|
||||
options.accessProviders = map
|
||||
}
|
||||
}
|
||||
|
||||
async doRun (options) {
|
||||
// 申请证书
|
||||
logger.info('任务开始')
|
||||
@@ -49,6 +63,9 @@ export class Executor {
|
||||
logger.info('证书无更新,无需重新部署')
|
||||
logger.info('任务完成')
|
||||
return { cert }
|
||||
} else {
|
||||
// 强制重新运行,清空保存的状态
|
||||
await certd.certStore.setCurrentFile('context.json', '{}')
|
||||
}
|
||||
}
|
||||
// 读取上次执行进度
|
||||
@@ -104,6 +121,7 @@ export class Executor {
|
||||
logger.info('此流程已被禁用,跳过')
|
||||
logger.info('')
|
||||
deployTrace.set({ value: { current: 'skip', status: 'disabled', remark: '流程禁用' } })
|
||||
deployTrace.set({ tasks: null })
|
||||
continue
|
||||
}
|
||||
try {
|
||||
|
||||
2
packages/plugins/plugin-aliyun/package-lock.json
generated
2
packages/plugins/plugin-aliyun/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/plugin-aliyun",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "@certd/plugin-aliyun",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@alicloud/pop-core": "^1.7.10",
|
||||
"@certd/api": "^0.1.15",
|
||||
"@certd/api": "^0.1.16",
|
||||
"dayjs": "^1.9.7",
|
||||
"lodash-es": "^4.17.20"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/certd": "^0.1.15",
|
||||
"@certd/certd": "^0.1.16",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^7.15.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
|
||||
2
packages/plugins/plugin-host/package-lock.json
generated
2
packages/plugins/plugin-host/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/plugin-host",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
{
|
||||
"name": "@certd/plugin-host",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@certd/api": "^0.1.15",
|
||||
"@certd/api": "^0.1.16",
|
||||
"dayjs": "^1.9.7",
|
||||
"lodash-es": "^4.17.20",
|
||||
"ssh2": "^0.8.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/certd": "^0.1.15",
|
||||
"@certd/certd": "^0.1.16",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^7.15.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
|
||||
@@ -29,7 +29,7 @@ export class SshClient {
|
||||
try {
|
||||
for (const transport of transports) {
|
||||
logger.info('上传文件:', JSON.stringify(transport))
|
||||
await this.exec({ conn, cmd: 'mkdir ' + path.dirname(transport.remotePath) })
|
||||
await this.exec({ connectConf, script: 'mkdir -p ' + path.dirname(transport.remotePath) })
|
||||
await this.fastPut({ sftp, ...transport })
|
||||
}
|
||||
resolve()
|
||||
@@ -59,10 +59,10 @@ export class SshClient {
|
||||
let data = null
|
||||
stream.on('close', (code, signal) => {
|
||||
console.log(`[${connectConf.host}][close]:code:${code}, signal:${signal} `)
|
||||
|
||||
if (code === 0) {
|
||||
resolve(data.toString())
|
||||
} else {
|
||||
reject(data.toString())
|
||||
data = data ? data.toString() : null
|
||||
resolve(data)
|
||||
}
|
||||
conn.end()
|
||||
}).on('data', (ret) => {
|
||||
@@ -70,7 +70,7 @@ export class SshClient {
|
||||
data = ret
|
||||
}).stderr.on('data', (err) => {
|
||||
console.log(`[${connectConf.host}][error]: ` + err)
|
||||
data = err
|
||||
reject(new Error(err.toString()))
|
||||
stream.close()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -45,6 +45,7 @@ export class UploadCertToHost extends AbstractHostPlugin {
|
||||
async execute ({ cert, props, context }) {
|
||||
const { crtPath, keyPath, accessProvider } = props
|
||||
const connectConf = this.getAccessProvider(accessProvider)
|
||||
console.log('connectConf', connectConf)
|
||||
const sshClient = new SshClient()
|
||||
await sshClient.uploadFiles({
|
||||
connectConf,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/plugin-tencent",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
{
|
||||
"name": "@certd/plugin-tencent",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@certd/api": "^0.1.15",
|
||||
"@certd/api": "^0.1.16",
|
||||
"dayjs": "^1.9.7",
|
||||
"kubernetes-client": "^9.0.0",
|
||||
"lodash-es": "^4.17.20",
|
||||
"tencentcloud-sdk-nodejs": "^4.0.44"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/certd": "^0.1.15",
|
||||
"@certd/certd": "^0.1.16",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^7.15.0",
|
||||
"eslint-config-standard": "^16.0.2",
|
||||
|
||||
@@ -6,7 +6,7 @@ import logger from 'koa-logger'
|
||||
import Static from 'koa-static'
|
||||
import fs from 'fs'
|
||||
import _ from 'lodash-es'
|
||||
|
||||
import './install.js'
|
||||
const app = new Koa()
|
||||
|
||||
// error handler
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import Router from 'koa-router'
|
||||
import { accessProviderRegistry } from '@certd/api'
|
||||
import DefaultAccessProviders from '@certd/access-providers'
|
||||
import _ from 'lodash-es'
|
||||
import { Ret } from '../models/Ret.js'
|
||||
const router = Router()
|
||||
router.prefix('/access-providers')
|
||||
|
||||
DefaultAccessProviders.install()
|
||||
|
||||
router.get('/list', function (ctx, next) {
|
||||
const list = []
|
||||
_.forEach(accessProviderRegistry.collection, item => {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import Router from 'koa-router'
|
||||
import { dnsProviderRegistry } from '@certd/api'
|
||||
import DefaultDnsProviders from '@certd/dns-providers'
|
||||
import _ from 'lodash-es'
|
||||
import { Ret } from '../models/Ret.js'
|
||||
const router = Router()
|
||||
router.prefix('/dns-providers')
|
||||
|
||||
DefaultDnsProviders.install()
|
||||
|
||||
router.get('/list', function (ctx, next) {
|
||||
const list = []
|
||||
_.forEach(dnsProviderRegistry.collection, item => {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import Router from 'koa-router'
|
||||
import { pluginRegistry } from '@certd/api'
|
||||
import DefaultPlugins from '@certd/plugins'
|
||||
import _ from 'lodash-es'
|
||||
import { Ret } from '../models/Ret.js'
|
||||
const router = Router()
|
||||
router.prefix('/plugins')
|
||||
|
||||
DefaultPlugins.install()
|
||||
|
||||
router.get('/list', function (ctx, next) {
|
||||
const list = []
|
||||
_.forEach(pluginRegistry.collection, item => {
|
||||
|
||||
8
packages/ui/certd-server/install.js
Normal file
8
packages/ui/certd-server/install.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import PluginAliyun from '@certd/plugin-aliyun'
|
||||
import PluginTencent from '@certd/plugin-tencent'
|
||||
import PluginHost from '@certd/plugin-host'
|
||||
|
||||
// 安装默认插件和授权提供者
|
||||
PluginAliyun.install()
|
||||
PluginTencent.install()
|
||||
PluginHost.install()
|
||||
654
packages/ui/certd-server/package-lock.json
generated
654
packages/ui/certd-server/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/server",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -10,11 +10,11 @@
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/access-providers": "^0.1.13",
|
||||
"@certd/api": "^0.1.15",
|
||||
"@certd/dns-providers": "^0.1.13",
|
||||
"@certd/executor": "^0.1.15",
|
||||
"@certd/plugins": "^0.1.13",
|
||||
"@certd/api": "^0.1.16",
|
||||
"@certd/executor": "^0.1.16",
|
||||
"@certd/plugin-aliyun": "^0.1.16",
|
||||
"@certd/plugin-host": "^0.1.16",
|
||||
"@certd/plugin-tencent": "^0.1.16",
|
||||
"compressing": "^1.5.1",
|
||||
"debug": "^4.1.1",
|
||||
"fs-extra": "^9.1.0",
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
"author": "greper",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@certd/executor": "^0.1.11"
|
||||
"@certd/executor": "^0.1.15",
|
||||
"@certd/plugin-aliyun": "^0.1.15",
|
||||
"@certd/plugin-host": "^0.1.15",
|
||||
"@certd/plugin-tencent": "^0.1.15"
|
||||
}
|
||||
}
|
||||
|
||||
2
packages/ui/certd-ui/package-lock.json
generated
2
packages/ui/certd-ui/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/certd-ui",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/certd-ui",
|
||||
"version": "0.1.15",
|
||||
"version": "0.1.16",
|
||||
"private": false,
|
||||
"scripts": {
|
||||
"dev": "vue-cli-service serve",
|
||||
|
||||
33
packages/ui/certd-ui/src/utils/util.common.js
Normal file
33
packages/ui/certd-ui/src/utils/util.common.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import _ from 'lodash-es'
|
||||
export default {
|
||||
arrayToMap (array) {
|
||||
if (!array) {
|
||||
return {}
|
||||
}
|
||||
if (!_.isArray(array)) {
|
||||
return array
|
||||
}
|
||||
const map = {}
|
||||
for (const item of array) {
|
||||
if (item.key) {
|
||||
map[item.key] = item
|
||||
}
|
||||
}
|
||||
return map
|
||||
},
|
||||
mapToArray (map) {
|
||||
if (!map) {
|
||||
return []
|
||||
}
|
||||
if (_.isArray(map)) {
|
||||
return map
|
||||
}
|
||||
const array = []
|
||||
for (const key in map) {
|
||||
const item = map[key]
|
||||
item.key = key
|
||||
array.push(item)
|
||||
}
|
||||
return array
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ import TaskForm from './components/task-form'
|
||||
import exportsApi from '../../api/api.exports'
|
||||
import _ from 'lodash-es'
|
||||
import DContainer from '../../components/d-container'
|
||||
|
||||
import commonUtil from '@/utils/util.common'
|
||||
function useDeploy (options) {
|
||||
const deployAdd = () => {
|
||||
options.deploy.push({
|
||||
@@ -248,6 +248,9 @@ export default {
|
||||
const route = useRoute()
|
||||
console.log('route', route)
|
||||
const optionParams = route.params.options ? JSON.parse(route.params.options) : {}
|
||||
if (optionParams.accessProviders) {
|
||||
optionParams.accessProviders = commonUtil.mapToArray(optionParams.accessProviders)
|
||||
}
|
||||
const optionsDefault = {
|
||||
cert: {
|
||||
csr: {
|
||||
|
||||
@@ -79,24 +79,22 @@ const defaultOptions = {
|
||||
},
|
||||
{
|
||||
deployName: '流程2-部署到nginx服务器',
|
||||
disabled: true,
|
||||
disabled: false,
|
||||
tasks: [
|
||||
{
|
||||
taskName: '上传证书到服务器',
|
||||
type: 'uploadCertToHost',
|
||||
props:{
|
||||
accessProvider: 'aliyun-linux',
|
||||
upload: [
|
||||
{ from: '{certPath}', to: '/xxx/xxx/xxx.cert.pem' },
|
||||
{ from: '{keyPath}', to: '/xxx/xxx/xxx.key' }
|
||||
]
|
||||
accessProvider: 'aliyun-ssh',
|
||||
crtPath: '/root/certd-test/cert.pem',
|
||||
keyPath: '/root/certd-test/cert.key'
|
||||
}
|
||||
},
|
||||
{
|
||||
taskName: '重启linux',
|
||||
type: 'hostShellExecute',
|
||||
props:{
|
||||
accessProvider: 'aliyun-linux',
|
||||
accessProvider: 'aliyun-ssh',
|
||||
script: ['ls']
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user