Skip to content

Commit bc2d0d6

Browse files
author
Oleg Sucharevich
authored
allow pass flag --skip-validation to avoid vlidation of git context during saving (#276)
Signed-off-by: Oleg Sucharevich <olegs@codefresh.io>
1 parent 34dd3b4 commit bc2d0d6

File tree

6 files changed

+29
-13
lines changed

6 files changed

+29
-13
lines changed

lib/interface/cli/commands/context/create/git/base.cmd.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ const command = new Command({
1717
title: 'Create Git Context',
1818
},
1919
builder: (yargs) => {
20-
yargs.option('sharing-policy', {
21-
describe: 'Set the sharing policy for git contexts',
22-
choices: ['AccountAdmins', 'AllUsersInAccount'],
23-
default: 'AccountAdmins',
24-
});
20+
yargs
21+
.option('sharing-policy', {
22+
describe: 'Set the sharing policy for git contexts',
23+
choices: ['AccountAdmins', 'AllUsersInAccount'],
24+
default: 'AccountAdmins',
25+
})
26+
.option('skip-validation', {
27+
describe: 'Set to true to skip validation',
28+
type: 'boolean',
29+
default: false,
30+
});
2531
return yargs;
2632
},
2733
handler: async (argv) => {

lib/interface/cli/commands/context/create/git/types/bitbucket.cmd.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ const command = new Command({
5858
if (!data.metadata.name || !data.spec.type) {
5959
throw new CFError('Name and type must be provided');
6060
}
61-
62-
await context.createContext(data);
61+
const opt = {};
62+
if (argv.skipValidation) {
63+
opt.skipValidation = true;
64+
}
65+
await context.createContext(data, opt);
6366
console.log(`Context: ${data.metadata.name} created`);
6467
},
6568
});

lib/interface/cli/commands/context/create/git/types/github.cmd.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ const command = new Command({
7272
if (!data.metadata.name || !data.spec.type) {
7373
throw new CFError('Name and type must be provided');
7474
}
75-
76-
await context.createContext(data);
75+
const opt = {};
76+
if (argv.skipValidation) {
77+
opt.skipValidation = true;
78+
}
79+
await context.createContext(data, opt);
7780
console.log(`Context: ${data.metadata.name} created`);
7881
},
7982
});

lib/interface/cli/commands/context/create/git/types/gitlab.cmd.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ const command = new Command({
6363
if (!data.metadata.name || !data.spec.type) {
6464
throw new CFError('Name and type must be provided');
6565
}
66-
67-
await context.createContext(data);
66+
const opt = {};
67+
if (argv.skipValidation) {
68+
opt.skipValidation = true;
69+
}
70+
await context.createContext(data, opt);
6871
console.log(`Context: ${data.metadata.name} created`);
6972
},
7073
});

lib/logic/api/context.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ const _extractFieldsForContextEntity = context => ({
1212
});
1313

1414

15-
const createContext = async (data) => {
15+
const createContext = async (data, qs) => {
1616
const options = {
1717
url: '/api/contexts/',
1818
method: 'POST',
1919
body: data,
20+
qs,
2021
};
2122

2223
return sendHttpRequest(options);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.10.4",
3+
"version": "0.11.0",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)