Skip to content

Commit 3bc1b67

Browse files
- Registry file location works locally.
1 parent f58fb16 commit 3bc1b67

File tree

7 files changed

+53
-3
lines changed

7 files changed

+53
-3
lines changed

.vscode/launch.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@
153153
"set global \"a.b\"=1;",
154154
"set global \"$.auth.google.sub\"='krimmer@stackql.io';",
155155
"select JSON_EXTRACT(saml.samlIdentity, '$.username') as saml_username from github.scim.saml_ids saml where saml.org = 'dummyorg';",
156-
"select kind, name, maximumCardsPerInstance from google.compute.acceleratorTypes where project = 'defective-response-content-project' and zone = 'australia-southeast1-a' order by name desc;"
156+
"select kind, name, maximumCardsPerInstance from google.compute.acceleratorTypes where project = 'defective-response-content-project' and zone = 'australia-southeast1-a' order by name desc;",
157+
"registry pull google;"
157158
],
158-
"default": "show providers;"
159+
"default": "registry pull google;"
159160
},
160161
{
161162
"type": "pickString",
@@ -197,6 +198,16 @@
197198
"-tags=sqlite_stackql"
198199
]
199200
},
201+
{
202+
"type": "pickString",
203+
"id": "appRoot",
204+
"description": "Extra Build Flags for debug; cannot place elsewhere",
205+
"default": "${workspaceFolder}",
206+
"options": [
207+
"${workspaceFolder}",
208+
"${workspaceFolder}/test/tmp/.vscode.debug.stackql",
209+
]
210+
},
200211
{
201212
"type": "pickString",
202213
"id": "concurrencyLimit",
@@ -393,6 +404,7 @@
393404
"--dataflow.dependency.max=${input:dataflowDependencyMax}",
394405
"--dataflow.components.max=${input:dataflowComponentsMax}",
395406
"--http.log.enabled=${input:httpLogEnabled}",
407+
"--approot=${input:appRoot}",
396408
"${input:queryString}"
397409
],
398410
},

internal/stackql/cmd/exec.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ stackql exec -i iqlscripts/create-disk.iql --credentialsfilepath /mnt/c/tmp/stac
5252
var err error
5353
var rdr io.Reader
5454

55+
flagErr := dependentFlagHandler(&runtimeCtx)
56+
iqlerror.PrintErrorAndExitOneIfError(flagErr)
57+
5558
if runtimeCtx.CPUProfile != "" {
5659
var f *os.File
5760
f, err = os.Create(runtimeCtx.CPUProfile)

internal/stackql/cmd/registry.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ var registryCmd = &cobra.Command{
4545

4646
var rdr io.Reader
4747

48+
flagErr := dependentFlagHandler(&runtimeCtx)
49+
iqlerror.PrintErrorAndExitOneIfError(flagErr)
50+
4851
usagemsg := cmd.Long + "\n\n" + cmd.UsageString()
4952
if len(args) < 1 {
5053
iqlerror.PrintErrorAndExitOneWithMessage(usagemsg)

internal/stackql/cmd/root.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ WHERE project = 'my-project' AND zone = 'us-west1-b';`,
8383
},
8484
}
8585

86+
func dependentFlagHandler(rc *dto.RuntimeCtx) error {
87+
inferredReqistryRaw := fmt.Sprintf(
88+
`{ "url": "%s", "localDocRoot": "%s", "verifyConfig": { "nopVerify": true } }`,
89+
defaultRegistryURLString,
90+
strings.ReplaceAll(path.Join(runtimeCtx.ApplicationFilesRootPath), `\`, `\\`),
91+
)
92+
if rc.RegistryRaw == "" {
93+
setErr := rc.Set(
94+
dto.RegistryRawKey,
95+
inferredReqistryRaw,
96+
)
97+
if setErr != nil {
98+
return setErr
99+
}
100+
}
101+
return nil
102+
}
103+
86104
// Execute adds all child commands to the root command and sets flags appropriately.
87105
// This is called by main.main(). It only needs to happen once to the rootCmd.
88106
func Execute() error {
@@ -118,7 +136,13 @@ func init() {
118136
rootCmd.PersistentFlags().Uint32Var(&runtimeCtx.ApplicationFilesRootPathMode, dto.ApplicationFilesRootPathModeKey, config.GetDefaultProviderCacheDirFileMode(), "Application config and cache file mode")
119137
rootCmd.PersistentFlags().StringVar(&runtimeCtx.ViperCfgFileName, dto.ViperCfgFileNameKey, config.GetDefaultViperConfigFileName(), "Config filename")
120138
rootCmd.PersistentFlags().StringVar(&runtimeCtx.AuthRaw, dto.AuthCtxKey, "", `auth contexts keyvals in json form, eg: '{ "google": { "credentialsfilepath": "/path/to/google/sevice/account/key.json", "type": "service_account" }, "okta": { "credentialsenvvar": "OKTA_SECRET_KEY", "type": "api_key" } }'`)
121-
rootCmd.PersistentFlags().StringVar(&runtimeCtx.RegistryRaw, dto.RegistryRawKey, fmt.Sprintf(`{ "url": "%s", "localDocRoot": "%s", "verifyConfig": { "nopVerify": true } }`, defaultRegistryURLString, strings.ReplaceAll(path.Join(runtimeCtx.ApplicationFilesRootPath), `\`, `\\`)), fmt.Sprintf(`openapi registry context keyvals in json form, eg: '{ "url": "%s" }'.`, defaultRegistryURLString))
139+
rootCmd.PersistentFlags().StringVar(
140+
&runtimeCtx.RegistryRaw,
141+
dto.RegistryRawKey,
142+
"",
143+
fmt.Sprintf(`openapi registry context keyvals in json form, eg: '{ "url": "%s" }'.`, defaultRegistryURLString),
144+
)
145+
fmt.Fprintf(os.Stderr, "Init: RegistryRaw: %s\n", runtimeCtx.RegistryRaw) //nolint:forbidigo // legacy
122146
rootCmd.PersistentFlags().BoolVar(&runtimeCtx.HTTPLogEnabled, dto.HTTPLogEnabledKey, false, "Display http request info in terminal")
123147
rootCmd.PersistentFlags().IntVar(&runtimeCtx.HTTPMaxResults, dto.HTTPMaxResultsKey, -1, "Max results per http request, any number <=0 results in no limitation")
124148
rootCmd.PersistentFlags().IntVar(&runtimeCtx.HTTPPageLimit, dto.HTTPPAgeLimitKey, 20, "Max pages of results that will be returned per resource, any number <=0 results in no limitation") //nolint:mnd // TODO: investigate

internal/stackql/cmd/shell.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ var shellCmd = &cobra.Command{
111111
//nolint:revive // acceptable for now
112112
Run: func(command *cobra.Command, args []string) {
113113

114+
flagErr := dependentFlagHandler(&runtimeCtx)
115+
iqlerror.PrintErrorAndExitOneIfError(flagErr)
116+
114117
cd := presentation.NewPresentationDriver(runtimeCtx)
115118

116119
outfile, _ := writer.GetDecoratedOutputWriter(runtimeCtx.OutfilePath, cd)

internal/stackql/cmd/srv.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var srvCmd = &cobra.Command{
3939
`,
4040
//nolint:revive // acceptable for now
4141
Run: func(cmd *cobra.Command, args []string) {
42+
flagErr := dependentFlagHandler(&runtimeCtx)
43+
iqlerror.PrintErrorAndExitOneIfError(flagErr)
4244
inputBundle, err := entryutil.BuildInputBundle(runtimeCtx)
4345
iqlerror.PrintErrorAndExitOneIfError(err)
4446
handlerCtx, err := entryutil.BuildHandlerContextNoPreProcess(runtimeCtx, queryCache, inputBundle)

internal/stackql/handler/handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7+
"os"
78
"path"
89
"strings"
910
"sync"
@@ -462,6 +463,8 @@ func getRegistry(runtimeCtx dto.RuntimeCtx) (anysdk.RegistryAPI, error) {
462463
if err != nil {
463464
return nil, err
464465
}
466+
fmt.Fprintf(os.Stderr, "App root path: %s\n", runtimeCtx.ApplicationFilesRootPath)
467+
fmt.Fprintf(os.Stderr, "Registry LocalDocRoot: %s\n", rc.LocalDocRoot)
465468
if rc.LocalDocRoot == "" {
466469
if strings.HasPrefix(rc.RegistryURL, "file:") {
467470
rc.LocalDocRoot = path.Clean(path.Join(strings.TrimPrefix(rc.RegistryURL, "file:"), ".."))

0 commit comments

Comments
 (0)