1
1
const _ = require ( 'lodash' ) ;
2
- const CFError = require ( 'cf-errors' ) ;
3
2
const { sendHttpRequest } = require ( './helper' ) ;
4
3
const Pipeline = require ( '../entities/Pipeline' ) ;
5
4
@@ -18,6 +17,8 @@ const getAll = async (options) => {
18
17
name : options . name ,
19
18
limit : options . limit ,
20
19
page : options . page - 1 ,
20
+ repoOwner : options . repoOwner ,
21
+ repoName : options . repoName ,
21
22
} ;
22
23
const RequestOptions = {
23
24
url : '/api/pipelines' ,
@@ -36,62 +37,6 @@ const getAll = async (options) => {
36
37
return pipelines ;
37
38
} ;
38
39
39
- /**
40
- * will return all pipelines by repository owner/name
41
- * @param repoOwner
42
- * @param repoName
43
- * @returns {Promise<*> }
44
- */
45
- const getAllByRepo = async ( options ) => {
46
- const qs = {
47
- name : options . name ,
48
- limit : options . limit ,
49
- page : options . page - 1 ,
50
- } ;
51
- const RequestOptions = {
52
- url : `/api/services/${ encodeURIComponent ( options . repoOwner ) } /${ encodeURIComponent ( options . repoName ) } ` ,
53
- qs,
54
- method : 'GET' ,
55
- } ;
56
-
57
- const result = await sendHttpRequest ( RequestOptions ) ;
58
- const pipelines = [ ] ;
59
-
60
- _ . forEach ( result , ( pipeline ) => {
61
- const data = _extractFieldsForPipelineEntity ( pipeline ) ;
62
- pipelines . push ( new Pipeline ( data ) ) ;
63
- } ) ;
64
-
65
- return pipelines ;
66
-
67
- /* TODO:ask itai about this issue
68
- _.forEach(pipelines, (pipeline) => {
69
- delete pipeline.account;
70
- });
71
- return pipelines;
72
- */
73
- } ;
74
-
75
- /**
76
- * will a pipeline by its name and repository owner/name
77
- * @param name
78
- * @param repoOwner
79
- * @param repoName
80
- * @returns {Promise<*> }
81
- */
82
- const getPipelineByNameAndRepo = async ( name , repoOwner , repoName ) => {
83
- const pipelines = await getAllByRepo ( {
84
- repoOwner,
85
- repoName,
86
- } ) ;
87
- const currPipeline = _ . find ( pipelines , pipeline => pipeline . info . name . toString ( ) === name ) ;
88
-
89
- if ( ! currPipeline ) {
90
- throw new CFError ( `Pipeline name: ${ name } wasn't found under repository: ${ repoOwner } /${ repoName } ` ) ;
91
- } else {
92
- return currPipeline ;
93
- }
94
- } ;
95
40
96
41
const getPipelineById = async ( id ) => {
97
42
const options = {
@@ -172,8 +117,6 @@ const patchPipelineByNameAndRepo = async (name, repoOwner, repoName, pipeline) =
172
117
173
118
174
119
module . exports = {
175
- getPipelineByNameAndRepo,
176
- getAllByRepo,
177
120
runPipelineById,
178
121
patchPipelineById,
179
122
patchPipelineByNameAndRepo,
0 commit comments