Skip to content

Commit 2193f55

Browse files
author
Oleg Sucharevich
authored
Contexts (#218)
* update cli commands to create git contexts
1 parent f154a37 commit 2193f55

File tree

5 files changed

+31
-45
lines changed

5 files changed

+31
-45
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const command = new Command({
2828
required: true,
2929
})
3030
.option('username', {
31-
describe: 'username that has permissions to use app password',
31+
describe: 'username that has permissions to use application password',
3232
alias: 'u',
3333
required: true,
3434
});
@@ -45,8 +45,6 @@ const command = new Command({
4545
type: 'git.bitbucket',
4646
data: {
4747
sharingPolicy: argv.sharingPolicy,
48-
host: 'bitbucket.org',
49-
useSSL: true,
5048
auth: {
5149
type: 'basic',
5250
username: argv.username,

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const {
77
} = require('../../../../../../../logic/index').api;
88

99
const LINK = 'https://github.com/settings/tokens';
10-
10+
const DEFAULT_API_HOST = 'api.github.com';
11+
const DEFAULT_API_PREFIX = '/';
1112

1213
const command = new Command({
1314
command: 'github <name>',
@@ -27,18 +28,16 @@ const command = new Command({
2728
alias: 't',
2829
required: true,
2930
})
30-
.option('use-ssl', {
31-
describe: 'Connect to the git host using ssl',
32-
choices: [true, false],
33-
type: 'boolean',
34-
alias: 's',
35-
default: true,
36-
required: true,
37-
})
3831
.option('host', {
3932
describe: 'Host name of your github (without protocol)',
4033
alias: 'h',
41-
default: 'github.com',
34+
default: DEFAULT_API_HOST,
35+
required: true,
36+
})
37+
.option('api', {
38+
describe: 'Prefix of the api on the given host',
39+
alias: 'a',
40+
default: DEFAULT_API_PREFIX,
4241
required: true,
4342
});
4443
return yargs;
@@ -54,17 +53,21 @@ const command = new Command({
5453
type: 'git.github',
5554
data: {
5655
sharingPolicy: argv.sharingPolicy,
57-
host: argv.host || 'github.com',
58-
useSSL: Boolean(argv.useSSL) || true,
5956
auth: {
6057
type: 'basic',
61-
username: 'x-oauth-basic',
6258
password: argv.accessToken,
6359
},
6460
},
6561
},
6662
};
6763

64+
if (argv.apiPathPrefix !== DEFAULT_API_PREFIX) {
65+
data.spec.data.auth.apiPathPrefix = argv.apiPathPrefix;
66+
}
67+
68+
if (argv.host !== DEFAULT_API_HOST) {
69+
data.spec.data.auth.apiHost = argv.host;
70+
}
6871

6972
if (!data.metadata.name || !data.spec.type) {
7073
throw new CFError('Name and type must be provided');

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
} = require('../../../../../../../logic/index').api;
88

99
const LINK = 'https://gitlab.com/profile/personal_access_tokens';
10+
const DEFAULT_API_URL = 'https://gitlab.com/api/v4/';
1011

1112

1213
const command = new Command({
@@ -27,18 +28,10 @@ const command = new Command({
2728
alias: 't',
2829
required: true,
2930
})
30-
.option('use-ssl', {
31-
describe: 'Connect to the git host using ssl',
32-
choices: [true, false],
33-
type: 'boolean',
34-
alias: 's',
35-
default: true,
36-
required: true,
37-
})
38-
.option('host', {
39-
describe: 'Host name of your gitlab (without protocol)',
40-
alias: 'h',
41-
default: 'gitlab.com',
31+
.option('api-url', {
32+
describe: 'URL of the api',
33+
alias: 'a',
34+
default: 'https://gitlab.com/api/v4/',
4235
required: true,
4336
});
4437
return yargs;
@@ -54,17 +47,18 @@ const command = new Command({
5447
type: 'git.gitlab',
5548
data: {
5649
sharingPolicy: argv.sharingPolicy,
57-
host: argv.host || 'gitlab.com',
58-
useSSL: Boolean(argv.useSSL) || true,
5950
auth: {
6051
type: 'basic',
61-
username: 'oauth2',
6252
password: argv.accessToken,
6353
},
6454
},
6555
},
6656
};
6757

58+
if (argv.apiUrl !== DEFAULT_API_URL) {
59+
data.spec.data.auth.apiURL = argv.apiUrl;
60+
}
61+
6862

6963
if (!data.metadata.name || !data.spec.type) {
7064
throw new CFError('Name and type must be provided');

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

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,9 @@ const command = new Command({
3131
alias: 'p',
3232
required: true,
3333
})
34-
.option('host', {
35-
describe: 'Host name of your stash (without protocol, may include port)',
36-
alias: 'h',
37-
required: true,
38-
})
39-
.option('use-ssl', {
40-
describe: 'Connect to the git host using ssl',
41-
choices: [true, false],
42-
type: 'boolean',
43-
alias: 's',
44-
default: true,
34+
.option('api-url', {
35+
describe: 'URL of the api',
36+
alias: 'a',
4537
required: true,
4638
});
4739
return yargs;
@@ -57,12 +49,11 @@ const command = new Command({
5749
type: 'git.stash',
5850
data: {
5951
sharingPolicy: argv.sharingPolicy,
60-
host: argv.host || 'stash.com',
61-
useSSL: Boolean(argv.useSSL) || true,
6252
auth: {
6353
type: 'basic',
6454
username: argv.username,
6555
password: argv.password,
56+
apiURL: argv.apiUrl,
6657
},
6758
},
6859
},

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.8.73",
3+
"version": "0.8.74",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)