Skip to content

Commit

Permalink
CAPI call migration from v2 to v3
Browse files Browse the repository at this point in the history
The CAPI v2 is deprecated and will be deactivated in the cf-deployment. Therefore an update is needed to use the newer CAPI v3.
  • Loading branch information
chombium committed Jan 13, 2025
1 parent f32e12b commit 707414d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/rlp-gateway/internal/auth/capi_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *CAPIClient) IsAuthorized(sourceID, token string) bool {
return true
}

uri = fmt.Sprintf("%s/v2/service_instances/%s", c.externalCapi, sourceID)
uri = fmt.Sprintf("%s/v3/service_instances/%s", c.externalCapi, sourceID)
req, err = http.NewRequest(http.MethodGet, uri, nil)
if err != nil {
log.Printf("failed to build authorize service instance access request: %s", err)
Expand Down Expand Up @@ -149,7 +149,7 @@ func (c *CAPIClient) AvailableSourceIDs(token string) []string {
sourceIDs = append(sourceIDs, v.Guid)
}

req, err = http.NewRequest(http.MethodGet, c.externalCapi+"/v2/service_instances", nil)
req, err = http.NewRequest(http.MethodGet, c.externalCapi+"/v3/service_instances", nil)
if err != nil {
log.Printf("failed to build authorize service instance access request: %s", err)
return nil
Expand All @@ -169,7 +169,7 @@ func (c *CAPIClient) AvailableSourceIDs(token string) []string {
}(resp)

if resp.StatusCode != http.StatusOK {
log.Printf("CAPI request failed (/v2/service_instances): %d", resp.StatusCode)
log.Printf("CAPI request failed (/v3/service_instances): %d", resp.StatusCode)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions src/rlp-gateway/internal/auth/capi_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var _ = Describe("CAPIClient", func() {
r = capiClient.requests[1]

Expect(r.Method).To(Equal(http.MethodGet))
Expect(r.URL.String()).To(Equal("http://external.capi.com/v2/service_instances/some-id"))
Expect(r.URL.String()).To(Equal("http://external.capi.com/v3/service_instances/some-id"))
Expect(r.Header.Get("Authorization")).To(Equal("some-token"))
})

Expand Down Expand Up @@ -121,7 +121,7 @@ var _ = Describe("CAPIClient", func() {

servicesReq := capiClient.requests[1]
Expect(servicesReq.Method).To(Equal(http.MethodGet))
Expect(servicesReq.URL.String()).To(Equal("http://external.capi.com/v2/service_instances"))
Expect(servicesReq.URL.String()).To(Equal("http://external.capi.com/v3/service_instances"))
Expect(servicesReq.Header.Get("Authorization")).To(Equal("some-token"))
})

Expand Down

0 comments on commit 707414d

Please sign in to comment.