Skip to content
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

Merged
merged 10 commits into from
Jan 17, 2019
Merged

CLI arguments made order invariant #81

merged 10 commits into from
Jan 17, 2019

Conversation

AleF83
Copy link
Contributor

@AleF83 AleF83 commented Jan 15, 2019

Closes #77

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>
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

@AleF83 AleF83 Jan 16, 2019

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.

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@shaikatz shaikatz merged commit 9494dd3 into Soluto:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants