Skip to content

Commit 9f8b573

Browse files
ziv-codefreshitai-codefresh
authored andcommitted
Fix images and pipelines (#58)
1 parent 0287e39 commit 9f8b573

File tree

3 files changed

+10
-71
lines changed

3 files changed

+10
-71
lines changed

lib/interface/cli/commands/pipeline/get.cmd.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,12 @@ const command = new Command({
4747

4848
let pipelines;
4949
// TODO:need to decide for one way for error handeling
50-
if (id && repoOwner && repoName) {
51-
pipelines = await pipeline.getPipelineByNameAndRepo(id, repoOwner, repoName);
52-
} else if (id) {
50+
if (id) {
5351
pipelines = await pipeline.getPipelineById(id);
54-
} else if (repoOwner && repoName) {
55-
pipelines = await pipeline.getAllByRepo({
56-
repoOwner,
57-
repoName,
58-
name,
59-
limit,
60-
page,
61-
});
6252
} else {
6353
pipelines = await pipeline.getAll({
54+
repoOwner,
55+
repoName,
6456
name,
6557
limit,
6658
page,

lib/logic/api/image.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ const getAll = async (options) => {
5757
let addedCfCrTag = false;
5858
_.forEach(image.tags, (tag) => {
5959
// in case we are filtering by registries, ignore the image if it is not from the registires list
60-
if ((options.filterRegistries && options.filterRegistries.indexOf(tag.registry) === -1) || _.isEqual(tag.tag, 'volume')) {
60+
if (options.filterRegistries && options.filterRegistries.indexOf(tag.registry) === -1) {
61+
return;
62+
}
63+
if (_.isEqual(tag.tag, 'volume')) {
64+
addedCfCrTag = true;
6165
return;
6266
}
6367
if (DEFAULTS.CODEFRESH_REGISTRIES.indexOf(tag.registry) !== -1) {

lib/logic/api/pipeline.js

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const _ = require('lodash');
2-
const CFError = require('cf-errors');
32
const { sendHttpRequest } = require('./helper');
43
const Pipeline = require('../entities/Pipeline');
54

@@ -18,6 +17,8 @@ const getAll = async (options) => {
1817
name: options.name,
1918
limit: options.limit,
2019
page: options.page - 1,
20+
repoOwner: options.repoOwner,
21+
repoName: options.repoName,
2122
};
2223
const RequestOptions = {
2324
url: '/api/pipelines',
@@ -36,62 +37,6 @@ const getAll = async (options) => {
3637
return pipelines;
3738
};
3839

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-
};
9540

9641
const getPipelineById = async (id) => {
9742
const options = {
@@ -172,8 +117,6 @@ const patchPipelineByNameAndRepo = async (name, repoOwner, repoName, pipeline) =
172117

173118

174119
module.exports = {
175-
getPipelineByNameAndRepo,
176-
getAllByRepo,
177120
runPipelineById,
178121
patchPipelineById,
179122
patchPipelineByNameAndRepo,

0 commit comments

Comments
 (0)