Skip to content

Commit 2c58bd8

Browse files
CR-20133 -- fix docs (#837)
1 parent 1ec341d commit 2c58bd8

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

lib/interface/cli/commands/context/context.sdk.spec.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const request = require('requestretry');
66

77
jest.mock('../../../../logic/entities/Context');
88

9-
109
const DEFAULT_RESPONSE = request.__defaultResponse();
1110

1211
describe('context commands', () => {
@@ -80,7 +79,13 @@ describe('context commands', () => {
8079
describe('s3', () => {
8180
it('should handle creation', async () => {
8281
const cmd = require('./create/helm-repo/types/s3.cmd');
83-
const argv = { name: 'some name', bucket: 'some bucket' };
82+
const argv = {
83+
name: 'some name',
84+
bucket: 'some bucket',
85+
'aws-access-key-id': 'test-id',
86+
'aws-secret-access-key': 'test-secret',
87+
'aws-default-region': 'test-region',
88+
};
8489
await cmd.handler(argv);
8590
await verifyResponsesReturned([DEFAULT_RESPONSE]); // eslint-disable-line
8691
});

lib/interface/cli/commands/context/create/helm-repo/types/s3.cmd.js

+26-12
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,14 @@ const command = new Command({
3737
builder: (yargs) => {
3838
yargs
3939
.option(AWS.keyId.cliFlag, {
40-
describe: 'Amazon access key id',
41-
default: process.env[AWS.keyId.awsEnvVar],
42-
required: true,
40+
describe: `Amazon access key id [default: ${AWS.keyId.awsEnvVar} env]`,
41+
4342
})
4443
.option(AWS.secretKey.cliFlag, {
45-
describe: 'Amazon access secret key with permissions to the bucket',
46-
default: process.env[AWS.secretKey.awsEnvVar],
47-
required: true,
44+
describe: `Amazon access secret key with permissions to the bucket [default: ${AWS.secretKey.awsEnvVar} env]`,
4845
})
4946
.option(AWS.region.cliFlag, {
50-
describe: 'Amazon default region',
51-
default: process.env[AWS.region.awsEnvVar],
52-
required: true,
47+
describe: `Amazon default region [default: ${AWS.region.awsEnvVar} env]`,
5348
})
5449
.option('bucket', {
5550
describe: 'Name of the bucket',
@@ -58,6 +53,25 @@ const command = new Command({
5853
return yargs;
5954
},
6055
handler: async (argv) => {
56+
const awsKeyId = argv[AWS.keyId.cliFlag] || process.env[AWS.keyId.awsEnvVar];
57+
const awsSecretKey = argv[AWS.secretKey.cliFlag] || process.env[AWS.secretKey.awsEnvVar];
58+
const awsRegion = argv[AWS.region.cliFlag] || process.env[AWS.region.awsEnvVar];
59+
if (!awsKeyId) {
60+
throw new CFError({
61+
message: `Either ${AWS.keyId.awsEnvVar} env, or --${AWS.keyId.cliFlag} option is required`,
62+
});
63+
}
64+
if (!awsSecretKey) {
65+
throw new CFError({
66+
message: `Either ${AWS.secretKey.awsEnvVar} env, or --${AWS.secretKey.cliFlag} option is required`,
67+
});
68+
}
69+
if (!awsRegion) {
70+
throw new CFError({
71+
message: `Either ${AWS.region.awsEnvVar} env, or --${AWS.region.cliFlag} option is required`,
72+
});
73+
}
74+
6175
let bucket = '';
6276
if (argv.bucket.startsWith('s3://')) {
6377
({ bucket } = argv);
@@ -76,9 +90,9 @@ const command = new Command({
7690
data: {
7791
repositoryUrl: bucket,
7892
variables: {
79-
[AWS.keyId.awsEnvVar]: argv[AWS.keyId.cliFlag],
80-
[AWS.secretKey.awsEnvVar]: argv[AWS.secretKey.cliFlag],
81-
[AWS.region.awsEnvVar]: argv[AWS.region.cliFlag],
93+
[AWS.keyId.awsEnvVar]: awsKeyId,
94+
[AWS.secretKey.awsEnvVar]: awsSecretKey,
95+
[AWS.region.awsEnvVar]: awsRegion,
8296
},
8397
},
8498
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.84.9",
3+
"version": "0.84.10",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)