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

service: --params flag retrieves service instance params #2141

Merged
merged 6 commits into from
Feb 19, 2021

Conversation

FelisiaM
Copy link
Member

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/176964913

The labels on this github issue will be updated when the story is started.

@@ -97,6 +93,26 @@ func (actor Actor) GetServiceInstanceDetails(serviceInstanceName string, spaceGU
return serviceInstanceDetails, Warnings(warnings), nil
}

func (actor Actor) GetServiceInstanceParameters(serviceInstanceName string, spaceGUID string) (ServiceInstanceDetails, Warnings, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like a GetServiceInstanceParameters() function should return ServiceInstanceParameters rather than ServiceInstanceDetails

actor/v7action/service_instance_details.go Show resolved Hide resolved
Expect(fakeCloudControllerClient.GetServiceInstanceParametersArgsForCall(0)).To(Equal(serviceInstanceGUID))
})

When("getting the parameters fails with a V3UnexpectedResponseError", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have a specific code path for a V3UnexpectedResponseError

}`
})

It("returns a BadRequestError", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say ServiceInstanceParametersFetchNotSupportedError?

command/v7/service_command.go Show resolved Hide resolved
cmd.UI.DisplayNewline()

data, err := json.Marshal(cmd.serviceInstance.Parameters.Value)
data, err := json.MarshalIndent(cmd.serviceInstance.Parameters.Value, "", " ")
if err != nil {
panic(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I wrote this originally. What do you think about it? The reasoning is that since the parameters were once JSON, it's impossible for the Marshal to return an error - since errors would be because of types that cannot be marshalled. However looking at it again, it looks like a code small. I wonder if there's a better way to encapsulate it? Or just return the error so that the code looks "normal" even though there will never be an error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - What about just ignoring the error. We are confident that it is JSON and there are tests around the result.

@@ -738,6 +653,101 @@ var _ = Describe("service command", func() {
})
})

When("the --params flag is specified", func() {
const (
parameters = `{"foo":"bar"}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

Eventually(helpers.CF(serviceCommand, serviceInstanceName)).Should(Say(`status:\s+create succeeded`))
})

FIt("reports the service instance parameters JSON", func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to run ginkgo blur

@@ -33,8 +33,7 @@ type SharedStatus struct {
}

type ServiceInstanceParameters struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better?:

type ServiceInstanceParameters types.JSONObject

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just use the types.JSONObject type...

}

return ServiceInstanceParameters{Value: params}, warnings
return ServiceInstanceParameters{Value: params}, warnings, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is just one line, I'd move it into the switch statement, and then there's no need for a return at the end of the function.

@FelisiaM FelisiaM requested a review from blgm February 18, 2021 15:30
@blgm blgm force-pushed the v8_show_si_params_173917704 branch from 5d2548b to 57b5c03 Compare February 18, 2021 17:51
@blgm blgm force-pushed the v8_show_si_params_173917704 branch from 57b5c03 to d954c1b Compare February 19, 2021 10:56
@FelisiaM FelisiaM merged commit 316824e into master Feb 19, 2021
@FelisiaM FelisiaM deleted the v8_show_si_params_173917704 branch February 19, 2021 11:47
@blgm blgm restored the v8_show_si_params_173917704 branch February 21, 2021 18:08
@moleske moleske deleted the v8_show_si_params_173917704 branch August 24, 2023 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants