cloudfoundry/go-cfclient

CF API V3 support

haraldfuchs opened this issue · 7 comments

In our code, we're using the ListServicesByQuery, ListServicePlansByQuery, and CreateServiceInstance methods, which are implemented by calling CF API V2. Since we'll drop this API version soon, I'd like to know if there are CF API V3 versions of those methods planned.

sneal commented

We don't have anything currently planned to explicitly add support for all v3 endpoints and types. We've been accepting PRs as consumers of the library add them.

There's a serious bug in almost all files - here's an example:

res, err := c.DoRequest(r)
if err != nil {
return ServiceInstance{}, err
}

defer res.Body.Close()
if res.StatusCode != http.StatusAccepted && res.StatusCode != http.StatusCreated {
return ServiceInstance{}, errors.Wrapf(err, "Error creating service, response code: %d", res.StatusCode)
}

By the time errors.Wrapf is called it's clear that err is nil because of the previous if err != nil { clause. If you call errors.Wrapf with nil as a first argument, it will return nil. This means that whenever the Cloud Controller returns an unexpected status code, the error message will be lost, and no error will be returned to the caller.

sneal commented

Aw yes, you're correct. Would you mind creating a new GitHub issue for this? In service_instances.go on any non GET this is a problem, therefore it's likely a problem on every v2 PUT/POST/DELETE.

While not really pertinent to this specific problem, the errors.Wrap calls should be replaced with Go's extended error support

We don't have anything currently planned to explicitly add support for all v3 endpoints and types. We've been accepting PRs as consumers of the library add them.

Would you continue accept PR's with new V3 endpoints implementation ?
I'm planing to implement /v3/service_offerings

sneal commented

@uriyger Absolutely. There is a v3 branch under active development, however I'd recommend adding to the existing v2/v3 code base on master.

sneal commented

Fixed via #320