-
Notifications
You must be signed in to change notification settings - Fork 244
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
Adds odo catalog list services -o json
#2066
Adds odo catalog list services -o json
#2066
Conversation
7d79b39
to
29791e1
Compare
Ready for reviewing! @dharmit @kadel @girishramnani Unfortunately for tests, I can't test against service catalog... any ideas @amitkrout ? See my commented out test! |
/retest all |
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.
Code looks good to me. But I feel like having the MachineReadableSuccessOutput
function be a part of machineoutput
package.
pkg/service/service.go
Outdated
@@ -397,3 +399,21 @@ func isRequired(required []string, name string) bool { | |||
} | |||
return false | |||
} | |||
|
|||
// MachineReadableSuccessOutput prints out machine readable output | |||
func MachineReadableSuccessOutput(services []occlient.Service) { |
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.
Since the function is dealing with machine output, wouldn't it be helpful to keep it under the machineoutput
package?
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.
No, as each output will be different.. Or else we'll run into an issue where in the machineout package, we will have multiple functions with different names :(
For example, It'd probably be named ServiceCatalogList or something along those lines, IMO doesn't make sense. But I could be wrong.
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 agree with the function name point you raised. To purely counter that point, we have adopted similar approach for auto-completion where everything lives under pkg/odo/util/completion/completionhandlers.go
.
Besides that, I think, there's scope of avoiding duplication of code by putting it under machineoutput
package. For example, we have renamed Success
and Error
structs in that package to GenericSuccess
and GenericError
respectively.
@kadel can you please share your thoughts?
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.
Create a separate test file cmd_catalog_test.go
under integration package
29791e1
to
890707c
Compare
You have a good point on putting the functions under Ready for another review 👍 |
@@ -37,6 +37,13 @@ var _ = Describe("odo service command tests", func() { | |||
}) | |||
}) | |||
|
|||
Context("checking machine readable output for service catalog", func() { |
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.
+1, This is a good place to validate instead of creating a separate test file.
Context("checking machine readable output for service catalog", func() { | ||
It("should succeed listing catalog components", func() { | ||
// Since service catalog is constantly changing, we simply check to see if this command passes.. rather than checking the JSON each time. | ||
helper.CmdShouldPass("odo", "catalog", "list", "services", "-o", "json") |
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.
Instead of matching the whole json can you match the basic key value pair like "kind": "ServiceList"
and atleast one "items": [
you mentioned in pr description.
|
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.
Remove file - tests/integration/json_test.go
64fd950
to
c3d9add
Compare
c3d9add
to
4411845
Compare
Updated based on your comments @amitkrout |
4411845
to
0782f24
Compare
It("should succeed listing catalog components", func() { | ||
// Since service catalog is constantly changing, we simply check to see if this command passes.. rather than checking the JSON each time. | ||
output := helper.CmdShouldPass("odo", "catalog", "list", "services", "-o", "json") | ||
Expect(output).To(ContainSubstring("CatalogListServices")) |
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.
+1
/retest |
Adds the ability to list catalog services and output to json. The format is as follows: ```json { "kind": "ServiceList", "apiVersion": "odo.openshift.io/v1alpha1", "metadata": { "creationTimestamp": null }, "items": [ { "name": "cakephp-mysql-persistent", "hidden": false, "planList": [ "default" ] }, ] } ```
0782f24
to
5dfde44
Compare
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amitkrout The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Looks good |
/retest Please review the full test history for this PR and help us cut down flakes. |
Adds the ability to list catalog services and output to json.
The format is as follows:
Closes #1357