Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/kubevela.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const slugify = require("slugify");
const mathutils = require("./math");
const _ = require("lodash");
const transliterate = require('transliteration').transliterate;

module.exports = {
json: (doc) =>{
let object = _.clone(doc)
object['title'] = transliterate(object['title'])
object['variables'] = _.map(doc['variables'], (v)=>{

return {
'key': slugify(v['name'].replaceAll('/','_'),'_'),
'key': slugify(transliterate(v['name']).replaceAll("\s+"," ").replaceAll('/','_'),'_'),
'path': '/'+v['name'],
'type': 'float',
'meaning': v['name'].split('/').pop(),
Expand Down
2 changes: 2 additions & 0 deletions lib/metric_model.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const slugify = require("slugify");
const _ = require("lodash");
const yaml = require('yaml');
const {transliterate} = require("transliteration");

module.exports = {
yaml: (doc) => {
let object = _.cloneDeep(doc);
object['title'] = transliterate(object['title'])
let componentsForAppSpecComp = [];
let componentsForAppWideScope = [];

Expand Down
22 changes: 22 additions & 0 deletions modules/application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,28 @@ module.exports = {
throw self.apos.error(error.name, error.message);
}
},
async ':uuid/uuid/debug'(req) {

const uuid = req.params.uuid;

// let errorResponses = self.validateDocument(updateData, true) || [];
// if (errorResponses.length > 0) {
// throw self.apos.error('required', 'Validation failed', { error: errorResponses });
// }
const currentUser = req.user;
const adminOrganization = currentUser.organization;

const existingApp = await self.apos.doc.db.findOne({uuid: uuid, organization: adminOrganization});
if (!existingApp) {
throw self.apos.error('notfound', 'Application not found');
}

try {
await self.apos.modules.exn.send_application_dsl(uuid)
} catch (error) {
throw self.apos.error(error.name, error.message);
}
},
async ':uuid/uuid/undeploy'(req) {
const uuid = req.params.uuid;
const currentUser = req.user;
Expand Down
24 changes: 24 additions & 0 deletions modules/exn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,30 @@ module.exports = {
})
}
,
async bqa_application_validate(uuid,app) {
return new Promise(async (resolve, reject) => {

const correlation_id = uuidv4()
correlations[correlation_id] = {
'resolve': resolve, 'reject': reject,
};
const req = aposSelf.apos.task.getReq()
const dsl = await aposSelf.apos.modules.application.getDSL(req, uuid)
const message = {
to: sender_bqa_validate_slos.options.target.address,
correlation_id: correlation_id,
message_annotations: {application: uuid},
application_properties: {application: uuid},
body: dsl.json
}
const timer = setTimeout(() => {
reject(new Error(`Promise timed out after ${5000} ms`));
}, 5000);

console.log("[bqa_application_validate] Send ", JSON.stringify( message))
sender_bqa_validate_slos.send(message)
})
},
get_cloud_candidates() {
return new Promise((resolve, reject) => {

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"slugify": "^1.6.6",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
"transliteration": "^2.3.5",
"uuid": "^9.0.1",
"yaml": "^2.3.4"
},
Expand Down