Skip to content

Commit

Permalink
Fix: env0_agent_values data source doesn't fetch values (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Aug 16, 2023
1 parent 2b8ddd5 commit 86031f3
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions client/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package http
//go:generate mockgen -destination=client_mock.go -package=http . HttpClientInterface

import (
"reflect"

"github.com/go-resty/resty/v2"
)

Expand Down Expand Up @@ -76,11 +78,22 @@ func (client *HttpClient) Put(path string, request interface{}, response interfa
}

func (client *HttpClient) Get(path string, params map[string]string, response interface{}) error {
result, err := client.request().
SetQueryParams(params).
SetResult(response).
Get(path)
return client.httpResult(result, err)
request := client.request().SetQueryParams(params)

responseType := reflect.TypeOf(response)

if responseType.Kind() == reflect.Ptr && responseType.Elem().Kind() == reflect.String {
responseStrPtr := response.(*string)

result, err := request.Get(path)
if err == nil {
*responseStrPtr = string(result.Body())
}

return client.httpResult(result, err)
} else {
return client.httpResult(request.SetResult(response).Get(path))
}
}

func (client *HttpClient) Delete(path string, params map[string]string) error {
Expand Down

0 comments on commit 86031f3

Please sign in to comment.