Skip to content

Commit

Permalink
Add special message for invalid secret name
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickreimer committed Nov 13, 2019
1 parent 04a3a44 commit d6d0025
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cmds/secrets_cmds/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ exports.handler = async args => {
error.message == 'has already been taken'
) {
messages.secretAlreadyExists(args.name, args.value, deployKey);
} else if (error.code == 'FORMAT' && error.field == 'key') {
messages.secretKeyInvalid();
} else {
log.error(`${humanizeField(error.field)} ${error.message}`);
}
Expand Down
20 changes: 19 additions & 1 deletion src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,22 @@ const secretAlreadyExists = (name, value, key) => {
console.error('');
};

module.exports = { authRequired, secretAlreadyExists };
const secretKeyInvalid = () => {
log.error('Name is invalid');
console.error('');

// prettier-ignore
console.error(stripIndent`
Secret names can contain letters, numbers, and dashes.
You should typically use kebab-case.
${chalk.yellow.bold('-- Examples -----------------------------------------------')}
${chalk.gray('mailchimp-api-key')}
${chalk.gray('stripe-secret-key')}
`);

console.error('');
};

module.exports = { authRequired, secretAlreadyExists, secretKeyInvalid };

0 comments on commit d6d0025

Please sign in to comment.