-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(apps): make db --environment optional, auto-select branch server-side #1735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ | |
| {Name: "app-id", Desc: "Miaoda app id", Required: true}, | ||
| {Name: "file", Desc: "local data file (.csv/.json), relative to cwd", Required: true}, | ||
| {Name: "table", Desc: "target table (default: file name without extension)"}, | ||
| }, dbEnvFlags("dev", []string{"dev", "online"}, "target db environment (default dev; use online for the online environment, or for an app whose DB is not multi-env)")...), | ||
| }, dbEnvFlags("", []string{"dev", "online"}, "target db environment; leave unset to auto-select (multi-env app uses dev, single-env uses online), or pass dev/online")...), | ||
| Validate: func(ctx context.Context, rctx *common.RuntimeContext) error { | ||
| if _, err := requireAppID(rctx.Str("app-id")); err != nil { | ||
| return err | ||
|
|
@@ -76,7 +76,7 @@ | |
| return common.NewDryRunAPI(). | ||
| POST(appDataImportPath(appID)). | ||
| Desc("Import data file into Miaoda app table (multipart upload)"). | ||
| Params(map[string]interface{}{"env": dbEnv(rctx), "table": importTableName(rctx)}). | ||
| Params(dbEnvParams(rctx, map[string]interface{}{"table": importTableName(rctx)})). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n -C3 'env|environment' shortcuts/apps/apps_db_data_import_test.goRepository: larksuite/cli Length of output: 2062 🏁 Script executed: #!/bin/bash
sed -n '1,260p' shortcuts/apps/apps_db_data_import_test.goRepository: larksuite/cli Length of output: 6382 Add an assertion for the default 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| Body(map[string]interface{}{"file_name": fileName, "file": "<contents of --file>"}) | ||
| }, | ||
| Execute: func(ctx context.Context, rctx *common.RuntimeContext) error { | ||
|
|
@@ -100,10 +100,14 @@ | |
| fd.AddField("file_name", fileName) | ||
| fd.AddFile("file", bytes.NewReader(content)) | ||
|
|
||
| importQuery := larkcore.QueryParams{"table": []string{table}} | ||
| if env := dbEnv(rctx); env != "" { | ||
| importQuery["env"] = []string{env} | ||
| } | ||
| resp, err := rctx.DoAPI(&larkcore.ApiReq{ | ||
| HttpMethod: http.MethodPost, | ||
| ApiPath: appDataImportPath(appID), | ||
| QueryParams: larkcore.QueryParams{"env": []string{dbEnv(rctx)}, "table": []string{table}}, | ||
| QueryParams: importQuery, | ||
| Body: fd, | ||
| }, larkcore.WithFileUpload()) | ||
| if err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ | |
| HasFormat: true, | ||
| Flags: append([]common.Flag{ | ||
| {Name: "app-id", Desc: "Miaoda app id", Required: true}, | ||
| }, dbEnvFlags("dev", []string{"dev", "online"}, "target db environment (default dev; use online for the online environment, or for an app whose DB is not multi-env)")...), | ||
| }, dbEnvFlags("", []string{"dev", "online"}, "target db environment; leave unset to auto-select (multi-env app uses dev, single-env uses online), or pass dev/online")...), | ||
| Validate: func(ctx context.Context, rctx *common.RuntimeContext) error { | ||
| if _, err := requireAppID(rctx.Str("app-id")); err != nil { | ||
| return err | ||
|
|
@@ -41,14 +41,14 @@ | |
| return common.NewDryRunAPI(). | ||
| GET(appDbQuotaPath(appID)). | ||
| Desc("Get Miaoda app database storage usage"). | ||
| Params(map[string]interface{}{"env": dbEnv(rctx)}) | ||
| Params(dbEnvParams(rctx, map[string]interface{}{})) | ||
| }, | ||
| Execute: func(ctx context.Context, rctx *common.RuntimeContext) error { | ||
| appID, err := requireAppID(rctx.Str("app-id")) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| data, err := rctx.CallAPITyped("GET", appDbQuotaPath(appID), map[string]interface{}{"env": dbEnv(rctx)}, nil) | ||
| data, err := rctx.CallAPITyped("GET", appDbQuotaPath(appID), dbEnvParams(rctx, map[string]interface{}{}), nil) | ||
|
Comment on lines
+44
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
fd -a 'apps_db_quota_get.*test.*\.go'
rg -n -C3 'env|environment' shortcuts/apps/apps_db_quota_get_test.go 2>/dev/nullRepository: larksuite/cli Length of output: 151 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Files matching apps_db_quota_get test patterns:\n'
fd -a 'apps_db_quota_get' shortcuts 2>/dev/null || true
printf '\nAll tests under shortcuts/apps related to db quota:\n'
fd -a 'db_quota' shortcuts/apps 2>/dev/null || true
printf '\nDirect listing of relevant files:\n'
git ls-files 'shortcuts/apps/*quota*' 'shortcuts/apps/*dryrun*' 'shortcuts/apps/*db*test*.go'Repository: larksuite/cli Length of output: 930 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the exact file and nearby tests, then inspect just the relevant slices.
git ls-files 'shortcuts/apps/*.go' | rg 'apps_db_(quota|get|execute|table_list).*test|apps_db_quota_get\.go|apps_db_execute_dryrun_test\.go|apps_db_table_list_dryrun_test\.go'Repository: larksuite/cli Length of output: 268 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
root = Path('.')
matches = []
for p in root.rglob('*.go'):
s = p.as_posix()
if 'shortcuts/apps/' in s and ('quota' in s or 'dryrun' in s or 'table_list' in s or 'execute' in s):
matches.append(s)
for s in sorted(matches):
print(s)
PYRepository: larksuite/cli Length of output: 470 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'apps_db_quota_get.go outline:\n'
ast-grep outline shortcuts/apps/apps_db_quota_get.go --view expanded || true
printf '\nRelevant test file outlines:\n'
ast-grep outline shortcuts/apps/apps_db_execute_test.go --view expanded || true
printf '\n---\n'
ast-grep outline shortcuts/apps/apps_db_table_list_test.go --view expanded || true
printf '\nSearch for quota path/env parameter usage:\n'
rg -n 'appDbQuotaPath|dbEnvParams|env' shortcuts/apps/apps_db_quota_get.go shortcuts/apps/apps_db_execute_test.go shortcuts/apps/apps_db_table_list_test.go shortcuts/apps/*.goRepository: larksuite/cli Length of output: 50370 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Read apps_db_quota_get.go around the Execute function:\n'
cat -n shortcuts/apps/apps_db_quota_get.go | sed -n '1,120p'
printf '\nRead relevant slices from db execute/table list tests:\n'
cat -n shortcuts/apps/apps_db_execute_test.go | sed -n '1,260p'
printf '\n---\n'
cat -n shortcuts/apps/apps_db_table_list_test.go | sed -n '1,260p'Repository: larksuite/cli Length of output: 26313 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Find all tests asserting env omission/default behavior in shortcuts/apps:\n'
rg -n -C 2 'omitempty|omit.*env|env parameter|Params\(dbEnvParams|dbEnvParams\(' shortcuts/apps/*test.go
printf '\nFind any direct tests for apps_db_quota_get command:\n'
rg -n -C 3 'quota-get|db_quota|get quota|appDbQuotaPath' shortcuts/apps/*test.go shortcuts/apps/*.goRepository: larksuite/cli Length of output: 12824 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Show the current implementation and nearby tests in small slices.
cat -n shortcuts/apps/apps_db_quota_get.go | sed -n '1,120p'
printf '\n--- apps_db_execute_test.go ---\n'
cat -n shortcuts/apps/apps_db_execute_test.go | sed -n '1,220p'
printf '\n--- apps_db_table_list_test.go ---\n'
cat -n shortcuts/apps/apps_db_table_list_test.go | sed -n '1,220p'Repository: larksuite/cli Length of output: 23339 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 3 'dbEnvParams|appDbQuotaPath|quota-get|db-quota-get|env' shortcuts/apps/apps_db_execute_test.go shortcuts/apps/apps_db_table_list_test.go shortcuts/apps/apps_db_quota_get.go shortcuts/apps/*test.goRepository: larksuite/cli Length of output: 50370 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the db quota tests directly; focus on the two AppsDBQuotaGet cases.
cat -n shortcuts/apps/apps_db_env_recovery_quota_test.go | sed -n '297,360p'
printf '\nSearch for env omission assertions in quota tests:\n'
rg -n -C 2 'Params\["env"\]|omit|absent|not send|db-quota-get|AppsDBQuotaGet' shortcuts/apps/apps_db_env_recovery_quota_test.goRepository: larksuite/cli Length of output: 4779 Add a dry-run check for 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| if err != nil { | ||
| return withAppsHint(err, appIDListHint) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.