Skip to content

Commit 1d93d51

Browse files
- All tests pass.
1 parent c7a823b commit 1d93d51

File tree

6 files changed

+162
-124
lines changed

6 files changed

+162
-124
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
"description": "Auth Input arg String",
198198
"default": "{}",
199199
"options": [
200-
"{ \"azure\": { \"type\": \"azure_default\" }, \"digitalocean\": { \"type\": \"bearer\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/digitalocean-key.txt\" }, \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/stackql-security-reviewer.json\" }, \"googleadmin\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/ryuk-it-query.json\" }, \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/okta-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"SSWS \" }, \"github\": { \"type\": \"basic\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/github-key.txt\" }, \"aws\": { \"type\": \"aws_signing_v4\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/aws-secret-key.txt\", \"keyID\": \"AKIA376P4FQSS2ONB2NS\" }, \"netlify\": { \"type\": \"api_key\", \"valuePrefix\": \"Bearer \", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/netlify-token.txt\" }, \"k8s\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/k8s-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"Bearer \" }, \"sumologic\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/sumologic-token.txt\", \"type\": \"basic\" } }",
200+
"{ \"local_openssl\": { \"type\": \"null_auth\"}, \"azure\": { \"type\": \"azure_default\" }, \"digitalocean\": { \"type\": \"bearer\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/digitalocean-key.txt\" }, \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/stackql-security-reviewer.json\" }, \"googleadmin\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/ryuk-it-query.json\" }, \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/okta-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"SSWS \" }, \"github\": { \"type\": \"basic\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/github-key.txt\" }, \"aws\": { \"type\": \"aws_signing_v4\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/aws-secret-key.txt\", \"keyID\": \"AKIA376P4FQSS2ONB2NS\" }, \"netlify\": { \"type\": \"api_key\", \"valuePrefix\": \"Bearer \", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/netlify-token.txt\" }, \"k8s\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/k8s-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"Bearer \" }, \"sumologic\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/sumologic-token.txt\", \"type\": \"basic\" } }",
201201
"{ \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/google/functional-test-dummy-sa-key.json\" }, \"googleadmin\": { \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/google/functional-test-dummy-sa-key.json\" },s \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/okta/api-key.txt\", \"type\": \"api_key\", \"valuePrefix\": \"SSWS \" }, \"github\": { \"type\": \"basic\", \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/okta/api-key.txt\" }, \"aws\": { \"type\": \"aws_signing_v4\", \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/aws/functional-test-dummy-aws-key.txt\", \"keyID\": \"AKIA376P4FQSS2ONB2NS\" }, \"netlify\": { \"type\": \"api_key\", \"valuePrefix\": \"Bearer \", \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/netlify/netlify-token.txt\" }, \"k8s\": { \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/k8s/k8s-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"Bearer \" }, \"sumologic\": { \"credentialsfilepath\": \"${workspaceFolder}/test/assets/credentials/dummy/sumologic/sumologic-token.txt\", \"type\": \"basic\" } }",
202202
"{ \"pgi\": { \"type\": \"sql_data_source::postgres\", \"sqlDataSource\": { \"dsn\": \"postgres://stackql:[email protected]:8432\" } }, \"azure\": { \"type\": \"azure_default\" }, \"google\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/stackql-security-reviewer.json\" }, \"okta\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/okta-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"SSWS \" }, \"github\": { \"type\": \"basic\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/github-key.txt\" }, \"aws\": { \"type\": \"aws_signing_v4\", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/aws-secret-key.txt\", \"keyID\": \"AKIA376P4FQSS2ONB2NS\" }, \"netlify\": { \"type\": \"api_key\", \"valuePrefix\": \"Bearer \", \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/netlify-token.txt\" }, \"k8s\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/k8s-token.txt\", \"type\": \"api_key\", \"valuePrefix\": \"Bearer \" }, \"sumologic\": { \"credentialsfilepath\": \"${workspaceFolder}/cicd/keys/integration/sumologic-token.txt\", \"type\": \"basic\" } }",
203203
"{ \"digitalocean\": { \"username_var\": \"DUMMY_DIGITALOCEAN_USERNAME\", \"password_var\": \"DUMMY_DIGITALOCEAN_PASSWORD\", \"type\": \"bearer\" }, \"azure\": {\"type\": \"api_key\", \"valuePrefix\": \"Bearer \", \"credentialsenvvar\": \"AZ_ACCESS_TOKEN\"} }",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/spf13/cobra v1.4.0
2020
github.com/spf13/pflag v1.0.5
2121
github.com/spf13/viper v1.10.1
22-
github.com/stackql/any-sdk v0.1.2-alpha12
22+
github.com/stackql/any-sdk v0.1.2-alpha20
2323
github.com/stackql/go-suffix-map v0.0.1-alpha01
2424
github.com/stackql/psql-wire v0.1.1-alpha07
2525
github.com/stackql/stackql-parser v0.0.14-alpha05

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
482482
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
483483
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
484484
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
485-
github.com/stackql/any-sdk v0.1.2-alpha12 h1:VtC9tpU7Pwo/tMkv0SqVxrIwdfmQZGXCApij1729oXo=
486-
github.com/stackql/any-sdk v0.1.2-alpha12/go.mod h1:4jYKpPoX2GWEK+qBnlGLvr8SUfndiYwHMIkg1dn9tFM=
485+
github.com/stackql/any-sdk v0.1.2-alpha20 h1:NoL6WJfPmnCZbK+pahAWRWuAvD9H2xDKoKDgvrmFm84=
486+
github.com/stackql/any-sdk v0.1.2-alpha20/go.mod h1:4jYKpPoX2GWEK+qBnlGLvr8SUfndiYwHMIkg1dn9tFM=
487487
github.com/stackql/go-suffix-map v0.0.1-alpha01 h1:TDUDS8bySu41Oo9p0eniUeCm43mnRM6zFEd6j6VUaz8=
488488
github.com/stackql/go-suffix-map v0.0.1-alpha01/go.mod h1:QAi+SKukOyf4dBtWy8UMy+hsXXV+yyEE4vmBkji2V7g=
489489
github.com/stackql/psql-wire v0.1.1-alpha07 h1:LQWVUlx4Bougk6dztDNG5tmXxpIVeeTSsInTj801xCs=

internal/stackql/primitivebuilder/generic_http_stream_input.go

Lines changed: 155 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"fmt"
55

66
"github.com/stackql/any-sdk/anysdk"
7+
"github.com/stackql/any-sdk/pkg/client"
78
"github.com/stackql/any-sdk/pkg/constants"
9+
"github.com/stackql/any-sdk/pkg/local_template_executor"
810
"github.com/stackql/any-sdk/pkg/logging"
911
"github.com/stackql/stackql-parser/go/vt/sqlparser"
1012
"github.com/stackql/stackql/internal/stackql/acid/binlog"
@@ -201,131 +203,175 @@ func (gh *genericHTTPStreamInput) Build() error {
201203
if prErr != nil {
202204
return internaldto.NewErroneousExecutorOutput(prErr)
203205
}
206+
protocolType, protocolTypeErr := pr.GetProtocolType()
207+
if protocolTypeErr != nil {
208+
return internaldto.NewErroneousExecutorOutput(protocolTypeErr)
209+
}
204210
interestingMaps, mapsErr := gh.getInterestingMaps(actionPrimitive)
205211
if mapsErr != nil {
206212
return internaldto.NewErroneousExecutorOutput(mapsErr)
207213
}
208-
httpPreparator := anysdk.NewHTTPPreparator(
209-
pr,
210-
svc,
211-
m,
212-
interestingMaps.getParameterMap(),
213-
nil,
214-
nil,
215-
logging.GetLogger(),
216-
)
217-
httpArmoury, httpErr := httpPreparator.BuildHTTPRequestCtx()
218-
if httpErr != nil {
219-
return internaldto.NewErroneousExecutorOutput(httpErr)
220-
}
214+
paramMap := interestingMaps.getParameterMap()
215+
params := paramMap[0]
216+
switch protocolType {
217+
case client.LocalTemplated:
218+
inlines := m.GetInline()
219+
if len(inlines) == 0 {
220+
return internaldto.NewErroneousExecutorOutput(fmt.Errorf("no inlines found"))
221+
}
222+
executor := local_template_executor.NewLocalTemplateExecutor(
223+
inlines[0],
224+
inlines[1:],
225+
nil,
226+
)
227+
resp, err := executor.Execute(
228+
map[string]any{"parameters": params},
229+
)
230+
if err != nil {
231+
return internaldto.NewErroneousExecutorOutput(err)
232+
}
233+
var backendMessages []string
234+
stdOut, stdOutExists := resp.GetStdOut()
235+
if stdOutExists {
236+
backendMessages = append(backendMessages, stdOut.String())
237+
}
238+
stdErr, stdErrExists := resp.GetStdErr()
239+
if stdErrExists {
240+
backendMessages = append(backendMessages, stdErr.String())
241+
}
242+
backendMessages = append(backendMessages, "OK")
243+
return internaldto.NewExecutorOutput(
244+
nil,
245+
nil,
246+
nil,
247+
internaldto.NewBackendMessages(backendMessages),
248+
nil,
249+
)
250+
case client.HTTP:
251+
httpPreparator := anysdk.NewHTTPPreparator(
252+
pr,
253+
svc,
254+
m,
255+
paramMap,
256+
nil,
257+
nil,
258+
logging.GetLogger(),
259+
)
260+
httpArmoury, httpErr := httpPreparator.BuildHTTPRequestCtx()
261+
if httpErr != nil {
262+
return internaldto.NewErroneousExecutorOutput(httpErr)
263+
}
221264

222-
tableName, _ := tbl.GetTableName()
265+
tableName, _ := tbl.GetTableName()
223266

224-
// var reversalParameters []map[string]interface{}
225-
// TODO: Implement reversal operations:
226-
// - depending upon reversal operation, collect sequence of HTTP operations.
227-
// - for each HTTP operation, collect context and store in *some object*
228-
// then attach to reversal graph for later retrieval and execution
229-
var nullaryExecutors []func() internaldto.ExecutorOutput
230-
for _, r := range httpArmoury.GetRequestParams() {
231-
req := r
232-
isSkipResponse := responseAnalysisErr != nil
233-
polyHandler := execution.NewStandardPolyHandler(
234-
handlerCtx,
235-
)
236-
nullaryEx := func() internaldto.ExecutorOutput {
237-
pp := execution.NewProcessorPayload(
238-
req,
239-
execution.NewNilMethodElider(),
240-
provider,
241-
m,
242-
tableName,
243-
rtCtx,
244-
authCtx,
245-
outErrFile,
246-
polyHandler,
247-
"",
248-
nil,
249-
isSkipResponse,
250-
true,
251-
isAwait,
252-
gh.isUndo,
253-
gh.isMutation,
254-
"",
267+
// var reversalParameters []map[string]interface{}
268+
// TODO: Implement reversal operations:
269+
// - depending upon reversal operation, collect sequence of HTTP operations.
270+
// - for each HTTP operation, collect context and store in *some object*
271+
// then attach to reversal graph for later retrieval and execution
272+
var nullaryExecutors []func() internaldto.ExecutorOutput
273+
for _, r := range httpArmoury.GetRequestParams() {
274+
req := r
275+
isSkipResponse := responseAnalysisErr != nil
276+
polyHandler := execution.NewStandardPolyHandler(
277+
handlerCtx,
255278
)
256-
processor := execution.NewProcessor(pp)
257-
processorResponse := processor.Process()
258-
processorErr := processorResponse.GetError()
259-
singletonBody := processorResponse.GetSingletonBody()
260-
reversalStrem := processorResponse.GetReversalStream()
261-
for {
262-
rev, isRevExistent := reversalStrem.Next()
263-
if !isRevExistent {
264-
break
279+
nullaryEx := func() internaldto.ExecutorOutput {
280+
pp := execution.NewProcessorPayload(
281+
req,
282+
execution.NewNilMethodElider(),
283+
provider,
284+
m,
285+
tableName,
286+
rtCtx,
287+
authCtx,
288+
outErrFile,
289+
polyHandler,
290+
"",
291+
nil,
292+
isSkipResponse,
293+
true,
294+
isAwait,
295+
gh.isUndo,
296+
gh.isMutation,
297+
"",
298+
)
299+
processor := execution.NewProcessor(pp)
300+
processorResponse := processor.Process()
301+
processorErr := processorResponse.GetError()
302+
singletonBody := processorResponse.GetSingletonBody()
303+
reversalStrem := processorResponse.GetReversalStream()
304+
for {
305+
rev, isRevExistent := reversalStrem.Next()
306+
if !isRevExistent {
307+
break
308+
}
309+
revErr := gh.appendReversalData(rev)
310+
if revErr != nil {
311+
return internaldto.NewErroneousExecutorOutput(revErr)
312+
}
265313
}
266-
revErr := gh.appendReversalData(rev)
267-
if revErr != nil {
268-
return internaldto.NewErroneousExecutorOutput(revErr)
314+
// if processorResponse.IsFailed() && !gh.isAwait {
315+
// processorErr = fmt.Errorf(processorResponse.GetFailedMessage())
316+
// }
317+
return gh.decorateOutput(
318+
internaldto.NewExecutorOutput(
319+
nil,
320+
singletonBody,
321+
nil,
322+
internaldto.NewBackendMessages(processorResponse.GetSuccessMessages()),
323+
processorErr,
324+
),
325+
tableName,
326+
)
327+
}
328+
329+
nullaryExecutors = append(nullaryExecutors, nullaryEx)
330+
}
331+
resultSet := internaldto.NewErroneousExecutorOutput(fmt.Errorf("no executions detected"))
332+
if !isAwait {
333+
for _, ei := range nullaryExecutors {
334+
execInstance := ei
335+
aPrioriMessages := resultSet.GetMessages()
336+
resultSet = execInstance()
337+
resultSet.AppendMessages(aPrioriMessages)
338+
if resultSet.GetError() != nil {
339+
return resultSet
269340
}
270341
}
271-
// if processorResponse.IsFailed() && !gh.isAwait {
272-
// processorErr = fmt.Errorf(processorResponse.GetFailedMessage())
273-
// }
274-
return gh.decorateOutput(
275-
internaldto.NewExecutorOutput(
276-
nil,
277-
singletonBody,
278-
nil,
279-
internaldto.NewBackendMessages(processorResponse.GetSuccessMessages()),
280-
processorErr,
281-
),
282-
tableName,
283-
)
342+
return resultSet
284343
}
285-
286-
nullaryExecutors = append(nullaryExecutors, nullaryEx)
287-
}
288-
resultSet := internaldto.NewErroneousExecutorOutput(fmt.Errorf("no executions detected"))
289-
if !isAwait {
290-
for _, ei := range nullaryExecutors {
291-
execInstance := ei
292-
aPrioriMessages := resultSet.GetMessages()
293-
resultSet = execInstance()
294-
resultSet.AppendMessages(aPrioriMessages)
344+
for _, eI := range nullaryExecutors {
345+
execInstance := eI
346+
dependentInsertPrimitive := primitive.NewGenericPrimitive(
347+
nil,
348+
nil,
349+
nil,
350+
primitive_context.NewPrimitiveContext(),
351+
)
352+
//nolint:revive // no big deal
353+
err = dependentInsertPrimitive.SetExecutor(func(pc primitive.IPrimitiveCtx) internaldto.ExecutorOutput {
354+
return execInstance()
355+
})
356+
if err != nil {
357+
return internaldto.NewErroneousExecutorOutput(err)
358+
}
359+
execPrim, execErr := composeAsyncMonitor(handlerCtx, dependentInsertPrimitive, prov, m, commentDirectives)
360+
if execErr != nil {
361+
return internaldto.NewErroneousExecutorOutput(execErr)
362+
}
363+
resultSet = execPrim.Execute(pc)
295364
if resultSet.GetError() != nil {
296365
return resultSet
297366
}
298367
}
299-
return resultSet
300-
}
301-
for _, eI := range nullaryExecutors {
302-
execInstance := eI
303-
dependentInsertPrimitive := primitive.NewGenericPrimitive(
304-
nil,
305-
nil,
306-
nil,
307-
primitive_context.NewPrimitiveContext(),
368+
return gh.decorateOutput(
369+
resultSet,
370+
tableName,
308371
)
309-
//nolint:revive // no big deal
310-
err = dependentInsertPrimitive.SetExecutor(func(pc primitive.IPrimitiveCtx) internaldto.ExecutorOutput {
311-
return execInstance()
312-
})
313-
if err != nil {
314-
return internaldto.NewErroneousExecutorOutput(err)
315-
}
316-
execPrim, execErr := composeAsyncMonitor(handlerCtx, dependentInsertPrimitive, prov, m, commentDirectives)
317-
if execErr != nil {
318-
return internaldto.NewErroneousExecutorOutput(execErr)
319-
}
320-
resultSet = execPrim.Execute(pc)
321-
if resultSet.GetError() != nil {
322-
return resultSet
323-
}
372+
default:
373+
return internaldto.NewErroneousExecutorOutput(fmt.Errorf("unsupported protocol type: %v", protocolType))
324374
}
325-
return gh.decorateOutput(
326-
resultSet,
327-
tableName,
328-
)
329375
}
330376
err = actionPrimitive.SetExecutor(ex)
331377
if err != nil {
@@ -341,4 +387,5 @@ func (gh *genericHTTPStreamInput) Build() error {
341387
gh.root = gh.dependencyNode
342388

343389
return nil
390+
344391
}

test/registry/src/local_openssl/v0.1.0/provider.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ providerServices:
1313
title: openssl Key Management
1414
version: v0.1.0
1515
openapi: 3.0.3
16+
config:
17+
auth:
18+
type: "null_auth"

test/registry/src/local_openssl/v0.1.0/services/keys.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,30 +209,18 @@ resources:
209209
key_out_file:
210210
in: inline
211211
required: true
212-
schema:
213-
type: string
214212
cert_out_file:
215213
in: inline
216214
required: true
217-
schema:
218-
type: string
219215
config_file:
220216
in: inline
221217
required: true
222-
schema:
223-
type: string
224218
days:
225219
in: inline
226220
required: false
227-
schema:
228-
type: integer
229-
default: 365
230221
executable:
231222
in: inline
232223
required: false
233-
schema:
234-
type: string
235-
default: openssl
236224
response:
237225
mediaType: application/json
238226
openAPIDocKey: '200'

0 commit comments

Comments
 (0)