Skip to content

CR-20133 -- fix docs #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/interface/cli/commands/context/context.sdk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const request = require('requestretry');

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


const DEFAULT_RESPONSE = request.__defaultResponse();

describe('context commands', () => {
Expand Down Expand Up @@ -80,7 +79,13 @@ describe('context commands', () => {
describe('s3', () => {
it('should handle creation', async () => {
const cmd = require('./create/helm-repo/types/s3.cmd');
const argv = { name: 'some name', bucket: 'some bucket' };
const argv = {
name: 'some name',
bucket: 'some bucket',
'aws-access-key-id': 'test-id',
'aws-secret-access-key': 'test-secret',
'aws-default-region': 'test-region',
};
await cmd.handler(argv);
await verifyResponsesReturned([DEFAULT_RESPONSE]); // eslint-disable-line
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,14 @@ const command = new Command({
builder: (yargs) => {
yargs
.option(AWS.keyId.cliFlag, {
describe: 'Amazon access key id',
default: process.env[AWS.keyId.awsEnvVar],
required: true,
describe: `Amazon access key id [default: ${AWS.keyId.awsEnvVar} env]`,

})
.option(AWS.secretKey.cliFlag, {
describe: 'Amazon access secret key with permissions to the bucket',
default: process.env[AWS.secretKey.awsEnvVar],
required: true,
describe: `Amazon access secret key with permissions to the bucket [default: ${AWS.secretKey.awsEnvVar} env]`,
})
.option(AWS.region.cliFlag, {
describe: 'Amazon default region',
default: process.env[AWS.region.awsEnvVar],
required: true,
describe: `Amazon default region [default: ${AWS.region.awsEnvVar} env]`,
})
.option('bucket', {
describe: 'Name of the bucket',
Expand All @@ -58,6 +53,25 @@ const command = new Command({
return yargs;
},
handler: async (argv) => {
const awsKeyId = argv[AWS.keyId.cliFlag] || process.env[AWS.keyId.awsEnvVar];
const awsSecretKey = argv[AWS.secretKey.cliFlag] || process.env[AWS.secretKey.awsEnvVar];
const awsRegion = argv[AWS.region.cliFlag] || process.env[AWS.region.awsEnvVar];
if (!awsKeyId) {
throw new CFError({
message: `Either ${AWS.keyId.awsEnvVar} env, or --${AWS.keyId.cliFlag} option is required`,
});
}
if (!awsSecretKey) {
throw new CFError({
message: `Either ${AWS.secretKey.awsEnvVar} env, or --${AWS.secretKey.cliFlag} option is required`,
});
}
if (!awsRegion) {
throw new CFError({
message: `Either ${AWS.region.awsEnvVar} env, or --${AWS.region.cliFlag} option is required`,
});
}

let bucket = '';
if (argv.bucket.startsWith('s3://')) {
({ bucket } = argv);
Expand All @@ -76,9 +90,9 @@ const command = new Command({
data: {
repositoryUrl: bucket,
variables: {
[AWS.keyId.awsEnvVar]: argv[AWS.keyId.cliFlag],
[AWS.secretKey.awsEnvVar]: argv[AWS.secretKey.cliFlag],
[AWS.region.awsEnvVar]: argv[AWS.region.cliFlag],
[AWS.keyId.awsEnvVar]: awsKeyId,
[AWS.secretKey.awsEnvVar]: awsSecretKey,
[AWS.region.awsEnvVar]: awsRegion,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.84.9",
"version": "0.84.10",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down