-
Notifications
You must be signed in to change notification settings - Fork 68
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
CLI arguments made order invariant #81
CLI arguments made order invariant #81
Conversation
cli/README.md
Outdated
@@ -17,17 +17,17 @@ docker run -it --rm soluto/kamus-cli encrypt <arguments> | |||
``` | |||
Or, using kubectl: | |||
``` | |||
kubectl run -it --rm --restart=Never kamus-cli --image=soluto/kamus-cli -- encrypt <arguments> | |||
kubectl run -it --rm --restart=Never kamus-cli --image=**soluto**/kamus-cli -- encrypt <arguments> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the **
addition?
cli/index.js
Outdated
.argument('<namespace>', 'Deployment namespace') | ||
.action(encrypt) | ||
.action(encrypt) | ||
.option('--secret <data>','Data to encrypt', prog.REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the arguments global options, and not only for the encrypt commands - correct? Isn't it weird?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it makes the arguments global. I chained another command
method and didn't see that arguments in the second command help.
Only arguments or options that are set before the first command
method are global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if what you're saying is true - all these:
.option('--kamus-url <url>', 'Kamus URL', prog.REQUIRED)
Should move up before the first command...
.option('--auth-tenant <id>', 'Azure tenant id', regexGuid) | ||
.option('--auth-application <id>', 'Azure application id', regexGuid) | ||
.option('--auth-resource <name>', 'Azure resource name', prog.STRING) | ||
.option('--kamus-url <url>', 'Kamus URL', prog.REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep it shorter - kamus-url
cli/index.js
Outdated
.argument('<namespace>', 'Deployment namespace') | ||
.action(encrypt) | ||
.action(encrypt) | ||
.option('--secret <data>','Data to encrypt', prog.REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if what you're saying is true - all these:
.option('--kamus-url <url>', 'Kamus URL', prog.REQUIRED)
Should move up before the first command...
.post('/api/v1/encrypt', { data, ['service-account']: serviceAccount, namespace}) | ||
.reply(200, '123ABC'); | ||
}); | ||
|
||
it('Should return encrypted data', async () => { | ||
await encrypt({data, serviceAccount, namespace, kamusApiUrl}, logger); | ||
await encrypt(null, {data, serviceAccount, namespace, kamusUrl}, logger); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why null is added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caporal
calls the action
with 3 parameters: args, options, logger.
I removed the first parameter by mistake because we don't actually use it. But the order matters.
Closes #77