-
Notifications
You must be signed in to change notification settings - Fork 94
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
Update SLAS Commands #282
base: master
Are you sure you want to change the base?
Update SLAS Commands #282
Conversation
This endpoint is only available for internal service users.
- Fix up argument names
-Refactor options - Add help text - Update all client commands - Update API docs - Remove internal APIs
@@ -276,7 +276,7 @@ You are now ready to use the tool by running the main command `sfcc-ci`. | |||
|
|||
Use `sfcc-ci --help` or just `sfcc-ci` to get started and see the full list of commands available: | |||
|
|||
```bash | |||
```txt |
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.
@@ -978,121 +977,84 @@ callback | (Function) | Callback function executed as a result. The err | |||
|
|||
APIs available in `require('sfcc').slas`: | |||
|
|||
`tenant.add(tenantId, shortcode, description, merchantName, contact, emailAddress, fileName)` | |||
`tenant.add({shortcode, tenant, file})` |
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.
These many argument style interfaces are error prone and very hard to change in a backwards compatible way.
I've moved all the interfaces to accepting objects with named attributes.
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 understand. Please see the dicusssion for the original intent and the suggestion in last line of combining best of both worlds
Thanks John for the contribution. Really appreciate your work here:
To be quite honest - I don't think we should remove it. It is a documented production API, that has to work. The CLI usability is questionable, but for JS APIs dealing with the implicite dependency between on-demand-sandboxes and slas, it is be useful
I wouldn't do it in commandline either, but I thought it might be useful if you build CI tools with python or bash scripts
See 2
Yep, that's indeed not working. I will see if we can flatten the info to fit in a table. But for now we can remove it
WRT to --file. I think @tobiaslohr had an interesting comment on the original PR. We can pipe a file into the command vs -- file sfcc-ci slas:client:add < my_file.txt or sfcc-ci slas:client:add {"clientID":"123"} would be equivalent, combining the efecitiveness of a file with the flexibility of just issueing a one line command |
lib/slas.js
Outdated
@@ -1,18 +1,22 @@ | |||
const fetch = require('node-fetch'); |
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.
Thanks very useful changes in that module. Appreciate you fixing my sloppy copy and paste errors
I'll make an update for add the stdin based file input to client/tenant add. @hnestmann / @tobiaslohr – one question ... to operate I think its very easy to trip into this and not have your AM Client setup right. I also imagine this means you need at least two AM clients, as I'd imagine some of the old APIs not accepting JWTs. Have we considered "shipping" a API Client with the App? eg. including a set of well known API Client values that are configured correctly for use with |
@johnboxall Thanks a lot for your contribution! Very much appreciated!!
Thanks for raising this. Yes, we've considered this already and we've also discussed this with the Salesforce Product Team. I see 2 main challenges with this:
Thoughts? I suggest we open a separate issue for this to have a forum to discuss. |
Good points @tobiaslohr – I think it is possible to work around both of these concerns. I agree, let's ship that discussion to a separate issue. With respect to this PR, before I merge, we also need to resolve an issue with I'm going to attempt to swap the code over to the existing Thanks! |
- Also throw an exception if the token available isn't a JWT. - And prettier format just to make a giant diff
@tobiaslohr / @hnestmann I added unit tests. They're not the best, but significantly better than nothing! I think there is a more you could improve here (eg. adding stdin handling for tenants/clients) but if its okay, I'd love to merge this incremental improvement which fixes blocking bugs in these commands. Let me know if there is any feedback you would like addressed. 🙌 |
@johnboxall Awesome, thanks a lot! |
General feedback:
|
On the discussion regarding reading the object details as JSON (e.g. inline or stored in a file) vs. passing the object details as multiple arguments to the command I feel that we should support both. It may be error prone to pass the properties as multiple arguments as you outlined @johnboxall, however as we support this with other commands and there is an alternative, you always have the choice. There is even a path with a hybrid approach (which is partially implemented by On top there even are ideas for setup commands and provide a wizard like step by step process via the CLI, which would be most suited for less advanced users, see #283 |
slas:client:delete [options] Deletes a SLAS client from a given tenant | ||
|
||
Environment: | ||
slas:tenant:add [options] Add or update SLAS a tenant. |
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.
As described in #282 (comment), I'd suggest to rename to :create
, instead of :add
, to follow existing patterns.
slas:client:delete [options] Deletes a SLAS client from a given tenant | ||
|
||
Environment: | ||
slas:tenant:add [options] Add or update SLAS a tenant. |
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.
As described in #282 (comment), I'd suggest to leave slas:tenant:list
|
||
Environment: | ||
slas:tenant:add [options] Add or update SLAS a tenant. | ||
slas:tenant:get [options] Get a SLAS tenant. |
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.
As described in #282 (comment), I'd suggest to use slas:tenant:list --tenant <tenant>
instead of sfcc-ci slas:tenant:get --tenant <tenant>
to retrieve details of a single tenant.
Environment: | ||
slas:tenant:add [options] Add or update SLAS a tenant. | ||
slas:tenant:get [options] Get a SLAS tenant. | ||
slas:client:add [options] Add or update a SLAS client for a tenant |
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.
As described in #282 (comment), I'd suggest to rename to :create
, instead of :add
, to follow existing patterns.
slas:tenant:add [options] Add or update SLAS a tenant. | ||
slas:tenant:get [options] Get a SLAS tenant. | ||
slas:client:add [options] Add or update a SLAS client for a tenant | ||
slas:client:get [options] Get a SLAS client for a tenant. |
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.
As described in #282 (comment), I'd suggest to use slas:client:list --tenant <tenant> --clientid <clientid>
instead of sfcc-ci slas:client:get --tenant <tenant> --clientid <clientid>
to retrieve details of a single client.
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.
Consider changes suggested in #282 (comment) and #282 (comment)
Makes sense!
Yup.
Make sense.
I'm not sure I agree with this design decision, but that doesn't matter. If its an existing pattern, sure lets add them back, but I have no way to validate the output as I don't personally have the required super duper staff permission.
That's fine, I'd only mention that the SLAS client object has been accreting fields lately, and we'd potentially setting ourselves up for a bunch of iterative work over time adding all the properties. As discussed in Slack, I'm 100% (maybe even 110%) a-okay with you driving the implementation of the changes you feel are required. |
This is an opinionated fix for #265.
slas:tenant:list
. Its backing API requires a staff only / internal role today.slas:tenant:add
. Generally I removed options that I felt would be frustrating to set on the command line. Instead, I'd like to encourage folks to use the--file
based interface. I also tried to code this such that you could provide only atenant
and it would work.slas:tenant:delete
. Its backing API requires a staff only / internal role today.slas:client:add
. I think setting client options via command line is setting yourself up to fail. Instead, we force folks to pass a--file
.slas:client:(get|list)
– there is no way to display a SLAS client (or clients!) as a table.Personally, I'd vote for making all these changes, as I think the smaller interface surface gives us lots of room to grow.
While making these changes I ran into a # of limitations of Commander@2:
--description
.-
for an option (make a normal pattern of saying--file -
and accepting STDIN impossible)Generally where possible, I've tried to follow the existing patterns in the repo.
❤️ ❤️ ❤️
cc @hnestmann & @tobiaslohr