Skip to content

Commit 1192ed0

Browse files
github-flask-migration (#479)
Summary: - Bare bones TLS for `flask`. - Added robot keyword to run `github` mocks. - Response bodies as `json` / `jinja` templates. - Added `http` logging for `graphql` functionality.
1 parent 2332590 commit 1192ed0

24 files changed

+2500
-2100
lines changed

.vscode/launch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
"show methods in azure.dev_center.customization_tasks;",
153153
"set global \"a.b\"=1;",
154154
"set global \"$.auth.google.sub\"='krimmer@stackql.io';",
155+
"select JSON_EXTRACT(saml.samlIdentity, '$.username') as saml_username from github.scim.saml_ids saml where saml.org = 'dummyorg';"
155156
],
156157
"default": "show providers;"
157158
},
@@ -315,6 +316,16 @@
315316
"options": [
316317
"{\"keyFilePath\": \"${workspaceFolder}/test/server/mtls/credentials/pg_server_key.pem\", \"certFilePath\": \"${workspaceFolder}/test/server/mtls/credentials/pg_server_cert.pem\", \"clientCAs\": [\"\"]}"
317318
]
319+
},
320+
{
321+
"type": "pickString",
322+
"id": "httpLogEnabled",
323+
"description": "http log enabled",
324+
"default": "false",
325+
"options": [
326+
"true",
327+
"false"
328+
]
318329
}
319330
],
320331
"configurations": [
@@ -380,6 +391,7 @@
380391
"--export.alias=${input:exportAliasString}",
381392
"--dataflow.dependency.max=${input:dataflowDependencyMax}",
382393
"--dataflow.components.max=${input:dataflowComponentsMax}",
394+
"--http.log.enabled=${input:httpLogEnabled}",
383395
"${input:queryString}"
384396
],
385397
},

internal/stackql/dto/runtime_ctx.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,60 @@ func (rc *RuntimeCtx) Set(key string, val string) error {
189189
}
190190
return retVal
191191
}
192+
193+
func (rc RuntimeCtx) Copy() RuntimeCtx {
194+
return RuntimeCtx{
195+
APIRequestTimeout: rc.APIRequestTimeout,
196+
AuthRaw: rc.AuthRaw,
197+
CABundle: rc.CABundle,
198+
AllowInsecure: rc.AllowInsecure,
199+
CacheKeyCount: rc.CacheKeyCount,
200+
CacheTTL: rc.CacheTTL,
201+
ConfigFilePath: rc.ConfigFilePath,
202+
CPUProfile: rc.CPUProfile,
203+
CSVHeadersDisable: rc.CSVHeadersDisable,
204+
Delimiter: rc.Delimiter,
205+
DryRunFlag: rc.DryRunFlag,
206+
ErrorPresentation: rc.ErrorPresentation,
207+
ExecutionConcurrencyLimit: rc.ExecutionConcurrencyLimit,
208+
HTTPLogEnabled: rc.HTTPLogEnabled,
209+
HTTPMaxResults: rc.HTTPMaxResults,
210+
HTTPPageLimit: rc.HTTPPageLimit,
211+
HTTPProxyHost: rc.HTTPProxyHost,
212+
HTTPProxyPassword: rc.HTTPProxyPassword,
213+
HTTPProxyPort: rc.HTTPProxyPort,
214+
HTTPProxyScheme: rc.HTTPProxyScheme,
215+
HTTPProxyUser: rc.HTTPProxyUser,
216+
IndirectDepthMax: rc.IndirectDepthMax,
217+
DataflowComponentsMax: rc.DataflowComponentsMax,
218+
DataflowDependencyMax: rc.DataflowDependencyMax,
219+
InfilePath: rc.InfilePath,
220+
LogLevelStr: rc.LogLevelStr,
221+
OutfilePath: rc.OutfilePath,
222+
OutputFormat: rc.OutputFormat,
223+
ApplicationFilesRootPath: rc.ApplicationFilesRootPath,
224+
ApplicationFilesRootPathMode: rc.ApplicationFilesRootPathMode,
225+
PGSrvAddress: rc.PGSrvAddress,
226+
PGSrvLogLevel: rc.PGSrvLogLevel,
227+
PGSrvPort: rc.PGSrvPort,
228+
PGSrvRawTLSCfg: rc.PGSrvRawTLSCfg,
229+
ExportAlias: rc.ExportAlias,
230+
ProviderStr: rc.ProviderStr,
231+
RegistryRaw: rc.RegistryRaw,
232+
SessionCtxRaw: rc.SessionCtxRaw,
233+
SQLBackendCfgRaw: rc.SQLBackendCfgRaw,
234+
DBInternalCfgRaw: rc.DBInternalCfgRaw,
235+
NamespaceCfgRaw: rc.NamespaceCfgRaw,
236+
StoreTxnCfgRaw: rc.StoreTxnCfgRaw,
237+
GCCfgRaw: rc.GCCfgRaw,
238+
ACIDCfgRaw: rc.ACIDCfgRaw,
239+
QueryCacheSize: rc.QueryCacheSize,
240+
TemplateCtxFilePath: rc.TemplateCtxFilePath,
241+
TestWithoutAPICalls: rc.TestWithoutAPICalls,
242+
UseNonPreferredAPIs: rc.UseNonPreferredAPIs,
243+
VarList: rc.VarList,
244+
VerboseFlag: rc.VerboseFlag,
245+
ViperCfgFileName: rc.ViperCfgFileName,
246+
WorkOffline: rc.WorkOffline,
247+
}
248+
}

internal/stackql/handler/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ func (hc *standardHandlerContext) LogHTTPResponseMap(target interface{}) {
326326
//nolint:nestif // ignore nested if
327327
if hc.runtimeContext.HTTPLogEnabled {
328328
switch target := target.(type) {
329-
case map[string]interface{}, []interface{}:
329+
case []map[string]interface{}, map[string]interface{}, []interface{}:
330330
b, err := json.MarshalIndent(target, "", " ")
331331
if err != nil {
332332
//nolint:errcheck // ignore error on output stream
@@ -525,7 +525,7 @@ func GetHandlerCtx(
525525
sessionCtxMutex: &sync.Mutex{},
526526
providersMapMutex: &sync.Mutex{},
527527
rawQuery: cmdString,
528-
runtimeContext: runtimeCtx,
528+
runtimeContext: runtimeCtx.Copy(),
529529
providers: providers,
530530
authContexts: inputBundle.GetAuthContexts(),
531531
registry: reg,

internal/stackql/primitivebuilder/graphql_single_select_acquire.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ func (ss *GraphQLSingleSelectAcquire) Build() error {
153153
}
154154
for {
155155
response, err := graphQLReader.Read()
156+
ss.handlerCtx.LogHTTPResponseMap(response)
156157
if len(response) > 0 {
157158
if !housekeepingDone && ss.insertPreparedStatementCtx != nil {
158159
_, err = ss.handlerCtx.GetSQLEngine().Exec(ss.insertPreparedStatementCtx.GetGCHousekeepingQueries())

0 commit comments

Comments
 (0)