Skip to content

Commit

Permalink
fix(cf) handle pagination correctly
Browse files Browse the repository at this point in the history
* Golang Unmarshal does not clear the previously used struct instance, which is passed by reference. Therefore, it is required to create new struct and pass it's reference to Unmarshal in each iteration of loop for commans that expect paginated result from CF.
* Update CHANGELOG.md
* Fix #63
  • Loading branch information
micellius committed Dec 24, 2023
1 parent dd2059e commit b4bcc26
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Handle CloudFoundry `v3` API pagination correctly ([#63](https://github.com/SAP/cf-html5-apps-repo-cli-plugin/issues/63))

## [1.4.7] - 2023-03-02
### Added
- Support `-di '*'` for `html5-list` command to list html5 applications available via all
Expand Down
1 change: 1 addition & 0 deletions clients/delete_service_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func DeleteServiceInstance(cliConnection plugin.CliConnection, serviceInstanceGU
responseBytes = []byte(strings.Join(responseStrings, ""))
if len(responseBytes) > 0 {
log.Tracef("Response is not empty, maybe error: %+v\n", responseStrings)
errorResponse = models.CFErrorResponse{}
err = json.Unmarshal(responseBytes, &errorResponse)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions clients/delete_service_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func DeleteServiceKey(cliConnection plugin.CliConnection, serviceKeyGUID string,
responseBytes = []byte(strings.Join(responseStrings, ""))
if len(responseBytes) > 0 {
log.Tracef("Response is not empty, maybe error: %+v\n", responseStrings)
errorResponse = models.CFErrorResponse{}
err = json.Unmarshal(responseBytes, &errorResponse)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions clients/get_service_instance_by_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetServiceInstanceByName(cliConnection plugin.CliConnection, spaceGUID stri
return models.CFServiceInstance{}, err
}

responseObject = models.CFResponse{}
err = json.Unmarshal([]byte(strings.Join(responseStrings, "")), &responseObject)
if err != nil {
return models.CFServiceInstance{}, err
Expand Down
1 change: 1 addition & 0 deletions clients/get_service_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func GetServiceInstances(cliConnection plugin.CliConnection, spaceGUID string, s
return nil, err
}

responseObject = models.CFResponse{}
err = json.Unmarshal([]byte(strings.Join(responseStrings, "")), &responseObject)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions clients/get_service_instances_by_name_prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func GetServiceInstancesByNamePrefix(cliConnection plugin.CliConnection, spaceGU
return serviceInstances, err
}

responseObject = models.CFResponse{}
err = json.Unmarshal([]byte(strings.Join(responseStrings, "")), &responseObject)
if err != nil {
return serviceInstances, err
Expand Down
1 change: 1 addition & 0 deletions clients/get_service_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func GetServiceKeys(cliConnection plugin.CliConnection, serviceInstanceGUID stri
return nil, err
}

responseObject = models.CFResponse{}
err = json.Unmarshal([]byte(strings.Join(responseStrings, "")), &responseObject)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions clients/get_service_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func GetServicePlans(cliConnection plugin.CliConnection, serviceGUID string) ([]
return nil, err
}

responseObject = models.CFResponse{}
err = json.Unmarshal([]byte(strings.Join(responseStrings, "")), &responseObject)
if err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions clients/get_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func GetServices(cliConnection plugin.CliConnection) ([]models.CFService, error)
return nil, err
}

responseObject = models.CFResponse{}
err = json.Unmarshal([]byte(strings.Join(responseStrings, "")), &responseObject)
if err != nil {
return nil, err
Expand Down

0 comments on commit b4bcc26

Please sign in to comment.