forked from screwdriver-cd/scm-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
136 lines (115 loc) · 3.87 KB
/
index.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
'use strict';
/* eslint-disable no-underscore-dangle */
const Joi = require('joi');
const dataSchema = require('screwdriver-data-schema');
class ScmBase {
/**
* Constructor for Scm
* @method constructor
* @param {Object} config Configuration
* @return {ScmBase}
*/
constructor(config) {
this.config = config;
}
/**
* Reload configuration
* @method configure
* @param {Object} config Configuration
*/
configure(config) {
this.config = config;
}
/**
* Format the scmUrl for the specific source control
* @method formatScmUrl
* @param {String} scmUrl Scm Url to format properly
*/
formatScmUrl() {
throw new Error('formatScmUrl not implemented');
}
/**
* Get a users permissions on a repository
* @method getPermissions
* @param {Object} config Configuration
* @param {String} config.scmUrl The scmUrl to get permissions on
* @param {String} config.token The token used to authenticate to the SCM
* @return {Promise}
*/
getPermissions(config) {
const result = Joi.validate(config, dataSchema.plugins.scm.getPermissions);
if (result.error) {
return Promise.reject(result.error);
}
return this._getPermissions(config);
}
_getPermissions() {
return Promise.reject('Not implemented');
}
/**
* Get a commit sha for a specific repo#branch
* @method getCommitSha
* @param {Object} config Configuration
* @param {String} config.scmUrl The scmUrl to get commit sha of
* @param {String} config.token The token used to authenticate to the SCM
* @return {Promise}
*/
getCommitSha(config) {
const result = Joi.validate(config, dataSchema.plugins.scm.getCommitSha);
if (result.error) {
return Promise.reject(result.error);
}
return this._getCommitSha(config);
}
_getCommitSha() {
return Promise.reject('Not implemented');
}
/**
* Update the commit status for a given repo and sha
* @method get
* @param {Object} config Configuration
* @param {String} config.scmUrl The scmUrl to get permissions on
* @param {String} config.sha The sha to apply the status to
* @param {String} config.buildStatus The build status used for figuring out the commit status to set
* @param {String} config.token The token used to authenticate to the SCM
* @return {Promise}
*/
updateCommitStatus(config) {
const result = Joi.validate(config, dataSchema.plugins.scm.updateCommitStatus);
if (result.error) {
return Promise.reject(result.error);
}
return this._updateCommitStatus(config);
}
_updateCommitStatus() {
return Promise.reject('Not implemented');
}
/**
* Fetch content of a file from an scm repo
* @method getFile
* @param {Object} config Configuration
* @param {String} config.scmUrl The scmUrl to get permissions on
* @param {String} config.path The file in the repo to fetch
* @param {String} config.token The token used to authenticate to the SCM
* @return {Promise}
*/
getFile(config) {
const result = Joi.validate(config, dataSchema.plugins.scm.getFile);
if (result.error) {
return Promise.reject(result.error);
}
return this._getFile(config);
}
_getFile() {
return Promise.reject('Not implemented');
}
/**
* Return statistics on the executor
* @method stats
* @return {Object} object Hash containing metrics for the executor
*/
stats() {
return {};
}
}
module.exports = ScmBase;