go-cfclient icon indicating copy to clipboard operation
go-cfclient copied to clipboard

CF API V3 support

Open haraldfuchs opened this issue 3 years ago • 6 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.

haraldfuchs avatar Aug 09 '22 08:08 haraldfuchs

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.

sneal avatar Aug 10 '22 20:08 sneal

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.

haraldfuchs avatar Aug 12 '22 12:08 haraldfuchs

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

sneal avatar Aug 12 '22 13:08 sneal

done

haraldfuchs avatar Aug 15 '22 11:08 haraldfuchs

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

uriyger avatar Oct 24 '22 11:10 uriyger

@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 avatar Oct 24 '22 20:10 sneal

Fixed via #320

sneal avatar Nov 09 '22 21:11 sneal