-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtemplate.js
106 lines (93 loc) · 2.48 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
'use strict';
const Joi = require('joi');
const mutate = require('../lib/mutate');
const Template = require('../config/template');
const scmUri = Joi.reach(require('./pipeline').base, 'scmUri');
const MODEL = {
id: Joi
.number().integer().positive()
.description('Identifier of this template')
.example(123345),
labels: Joi
.array()
.items(Joi.string())
.description('Labels for template')
.example(['stable', 'latest', 'beta']),
config: Template.config,
name: Template.name,
version: Template.version,
description: Template.description,
maintainer: Template.maintainer,
scmUri
};
module.exports = {
/**
* All the available properties of Template
*
* @property base
* @type {Joi}
*/
base: Joi.object(MODEL).label('Template'),
/**
* Properties for template that will come back during a GET request
*
* @property get
* @type {Joi}
*/
get: Joi.object(mutate(MODEL, [
'id', 'labels', 'config', 'name', 'version', 'description', 'maintainer', 'scmUri'
], [])).label('Get Template'),
/**
* Properties for template that will be passed during a CREATE request
*
* @property create
* @type {Joi}
*/
create: Joi.object(mutate(MODEL, [
'config', 'name', 'version', 'description', 'maintainer'
], ['labels'])).label('Create Template'),
/**
* Properties for template that will be passed during a UPDATE requeste
*
* @property update
* @type {Joi}
*/
update: Joi.object(mutate(MODEL, [], ['labels']))
.label('Update Template'),
/**
* List of fields that determine a unique row
*
* @property keys
* @type {Array}
*/
keys: ['name', 'version'],
/**
* List of all fields in the model
* @property allKeys
* @type {Array}
*/
allKeys: Object.keys(MODEL),
/**
* List of indexes to create in the datastore
*
* @property indexes
* @type {Array}
*/
indexes: ['name'],
/**
* Primary column to sort queries by.
* This defines queries to optionally sort a query result set by version.
* Each range key matches up with an element in the indexes property
*
* @property rangeKeys
* @type {Array}
*/
rangeKeys: ['version'],
/**
* Tablename to be used in the datastore
*
* @property tableName
* @type {String}
*/
tableName: 'templates'
};