Skip to content

Commit 3ce99dd

Browse files
Merge pull request #67 from stackql/feature/interface-flexibility-compact
enhanced-parameters
2 parents ca2e798 + bb341c9 commit 3ce99dd

File tree

24 files changed

+14785
-23255
lines changed

24 files changed

+14785
-23255
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ jobs:
142142
uses: actions/checkout@v2
143143

144144
- name: API sprawl check
145-
run: ./cicd/scripts/hack/check_api_growth.sh
145+
run: |
146+
if ./cicd/scripts/hack/check_api_growth.sh; then
147+
echo "API sprawl check passed"
148+
else
149+
echo "API sprawl check failed - please review for details"
150+
exit 1
151+
fi
146152
147153
- name: Setup system dependencies
148154
run: |

anysdk/addressable.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ func newAddressableServerVariable(name string, s Schema, isRequired bool) Addres
6868
}
6969
}
7070

71+
func newAddressableContextVariable(name string, s Schema, isRequired bool) Addressable {
72+
return &namedSchema{
73+
s: s,
74+
name: name,
75+
location: LocationContext,
76+
isRequired: isRequired,
77+
}
78+
}
79+
7180
type Addressable interface {
7281
ConditionIsValid(lhs string, rhs interface{}) bool
7382
GetLocation() string

anysdk/client.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/stackql/any-sdk/pkg/client"
1414
"github.com/stackql/any-sdk/pkg/dto"
1515
"github.com/stackql/any-sdk/pkg/internaldto"
16+
"github.com/stackql/any-sdk/pkg/latetranslator"
1617
"github.com/stackql/any-sdk/pkg/netutils"
1718
"github.com/stackql/any-sdk/pkg/requesttranslate"
1819
)
@@ -24,12 +25,14 @@ var (
2425
)
2526

2627
type anySdkHttpClient struct {
27-
client *http.Client
28+
client *http.Client
29+
lateTranslator latetranslator.LateTranslator
2830
}
2931

3032
func newAnySdkHttpClient(client *http.Client) client.AnySdkClient {
3133
return &anySdkHttpClient{
32-
client: client,
34+
client: client,
35+
lateTranslator: latetranslator.NewNaiveLateTranslator(),
3336
}
3437
}
3538

@@ -120,7 +123,11 @@ func (hc *anySdkHttpClient) Do(designation client.AnySdkDesignation, argList cli
120123
if !isHttpRequest {
121124
return nil, fmt.Errorf("could not cast first argument to http.Request")
122125
}
123-
httpResponse, httpResponseErr := hc.client.Do(httpReq)
126+
translatedRequest, translationErr := hc.lateTranslator.Translate(httpReq)
127+
if translationErr != nil {
128+
return nil, translationErr
129+
}
130+
httpResponse, httpResponseErr := hc.client.Do(translatedRequest)
124131
if httpResponseErr != nil {
125132
return nil, httpResponseErr
126133
}
@@ -129,19 +136,25 @@ func (hc *anySdkHttpClient) Do(designation client.AnySdkDesignation, argList cli
129136
}
130137

131138
type anySdkHTTPClientConfigurator struct {
132-
runtimeCtx dto.RuntimeCtx
133-
authUtil auth_util.AuthUtility
134-
providerName string
139+
runtimeCtx dto.RuntimeCtx
140+
authUtil auth_util.AuthUtility
141+
providerName string
142+
defaultClient *http.Client
135143
}
136144

137145
func NewAnySdkClientConfigurator(
138146
rtCtx dto.RuntimeCtx,
139147
provName string,
148+
defaultClient *http.Client,
140149
) client.AnySdkClientConfigurator {
150+
if defaultClient == nil {
151+
defaultClient = http.DefaultClient
152+
}
141153
return &anySdkHTTPClientConfigurator{
142-
runtimeCtx: rtCtx,
143-
authUtil: auth_util.NewAuthUtility(),
144-
providerName: provName,
154+
runtimeCtx: rtCtx,
155+
authUtil: auth_util.NewAuthUtility(defaultClient),
156+
providerName: provName,
157+
defaultClient: defaultClient,
145158
}
146159
}
147160

@@ -246,7 +259,7 @@ func (cc *anySdkHTTPClientConfigurator) Auth(
246259
}
247260
return newAnySdkHttpClient(httpClient), nil
248261
case dto.AuthNullStr:
249-
httpClient := netutils.GetHTTPClient(cc.runtimeCtx, http.DefaultClient)
262+
httpClient := netutils.GetHTTPClient(cc.runtimeCtx, cc.defaultClient)
250263
return newAnySdkHttpClient(httpClient), nil
251264
}
252265
return nil, fmt.Errorf("could not infer auth type")

0 commit comments

Comments
 (0)