-
Notifications
You must be signed in to change notification settings - Fork 617
Add BTP CLI #5473
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
Add BTP CLI #5473
Conversation
…as response format, - additional tests
…n, - enable verbose setting,
…rvice instance checks
nayyer28
left a comment
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.
lgtm!
pkg/btp/executor.go
Outdated
| /* | ||
| @param timeout : in seconds | ||
| @param pollInterval : in seconds | ||
| @param negativeCheck : set to false if you whant to check the negation of the response of `cmdCheck` |
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.
| @param negativeCheck : set to false if you whant to check the negation of the response of `cmdCheck` | |
| @param negativeCheck : set to false if you want to check the negation of the response of `cmdCheck` |
|
Maybe you could consider some naming changes. I noticed the following things:
Could you add unit tests for the rest of the files? (checkFunctions.go & command_builder.go). Maybe that was your plan anyway, as this is still a draft |
…ency; add BTP command builder and mock executor
pkg/btputils/structures.go
Outdated
| @@ -0,0 +1,118 @@ | |||
| package btputils | |||
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.
Looks good 👍. One small thing: I would move structures.go to the btp package.I think it does not make sense to create a whole package just for some structures
DanielMieg
left a comment
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.
see comment
|
|
We were just about to request an option to create service bindings/instances on the BTP without CF and then found this PR. |
pkg/btp/commandBuilder.go
Outdated
| if len(b.params) > 0 { | ||
| cmd += " " + strings.Join(b.params, " ") | ||
| } | ||
| return cmd, nil |
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 see this command is put together with spaces. How is this executed? Not in a shell right? As I know it we should pass these as a list to an executor, to prevent command injections. Check other such commands e.g. https://github.com/SAP/jenkins-library/blob/master/pkg/npm/npm.go#L129
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.
You are right.
Now we will only use Array of string in the builder (no more concatenations)
…for command scripts
o-liver
left a comment
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.
Looks good to me. Only minor suggestions made, take it or leave.
pkg/btp/executor_test.go
Outdated
| "btp check": `dummy | ||
| dummy | ||
|
|
||
| OK`, |
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 such a weird string?
| "btp check": `dummy | |
| dummy | |
| OK`, | |
| "btp check": "OK", |
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.
corrected 👍🏾
| StdoutReturn: map[string]string{ | ||
| "btp login .*": "Authentication successful", | ||
| "btp get services/binding": fmt.Sprintf(` | ||
| { | ||
| "id": "xxxx", | ||
| "name": "%s", | ||
| "ready": true | ||
| }`, btpConfig.BindingName), | ||
| }, |
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 json some extra spaces should not matter:
| StdoutReturn: map[string]string{ | |
| "btp login .*": "Authentication successful", | |
| "btp get services/binding": fmt.Sprintf(` | |
| { | |
| "id": "xxxx", | |
| "name": "%s", | |
| "ready": true | |
| }`, btpConfig.BindingName), | |
| }, | |
| StdoutReturn: map[string]string{ | |
| "btp login .*": "Authentication successful", | |
| "btp get services/binding": fmt.Sprintf(` | |
| { | |
| "id": "xxxx", | |
| "name": "%s", | |
| "ready": true | |
| }`, btpConfig.BindingName), | |
| }, |
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.
corrected 👍🏾
pkg/btp/services_test.go
Outdated
| { | ||
| "id": "xxxx", | ||
| "name": "%s", | ||
| "ready": true | ||
| }`, btpConfig.BindingName), |
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.
same as above
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.
corrected 👍🏾
pkg/btp/services_test.go
Outdated
| { | ||
| "error": "BadRequest", | ||
| "description": "Could not find such binding" | ||
| }`), |
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.
again a json string, which could be indented nicer
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.
corrected 👍🏾
|
/it |
|
/it-go |
|



Pull Request Description
Objective
This pull request introduces functions to facilitate the use of the BTP CLI. The key functionalities added include:
Key Improvements
CommandBuilderhas been developed to streamline script creation, ensuring efficient command handling.Run): Enables concurrent task execution without blocking the main process.RunSync): Incorporates a polling mechanism to verify the success of BTP actions at regular intervals.Synchronous Execution
Currently, BTP actions do not support direct synchronous execution. To address this, a
polling mechanismhas been implemented to continuously check the status of actions, ensuring they are completed successfully.Checklist