Documentation
¶
Index ¶
- func AppCmd() *cobra.Command
- func AppDeployCmd() *cobra.Command
- func AppDeployValidateCmd() *cobra.Command
- func AppGetCmd() *cobra.Command
- func AppListCmd() *cobra.Command
- func BackupCmd() *cobra.Command
- func BackupDBCmd() *cobra.Command
- func CacheCmd() *cobra.Command
- func CachePurgeURLCmd() *cobra.Command
- func ConfigCmd() *cobra.Command
- func ConfigEnvvarCmd() *cobra.Command
- func ConfigEnvvarDeleteCmd() *cobra.Command
- func ConfigEnvvarGetAllCmd() *cobra.Command
- func ConfigEnvvarGetCmd() *cobra.Command
- func ConfigEnvvarListCmd() *cobra.Command
- func ConfigEnvvarSetCmd() *cobra.Command
- func ConfigSoftwareCmd() *cobra.Command
- func ConfigSoftwareGetCmd() *cobra.Command
- func ConfigSoftwareUpdateCmd() *cobra.Command
- func DBCmd() *cobra.Command
- func DBPhpmyadminCmd() *cobra.Command
- func DevEnvCmd() *cobra.Command
- func ExportCmd() *cobra.Command
- func ExportSQLCmd() *cobra.Command
- func ImportCmd() *cobra.Command
- func ImportMediaAbortCmd() *cobra.Command
- func ImportMediaCmd() *cobra.Command
- func ImportMediaStatusCmd() *cobra.Command
- func ImportSQLCmd() *cobra.Command
- func ImportSQLStatusCmd() *cobra.Command
- func ImportValidateFilesCmd() *cobra.Command
- func ImportValidateSQLCmd() *cobra.Command
- func LoginCmd() *cobra.Command
- func LogoutCmd() *cobra.Command
- func LogsCmd() *cobra.Command
- func NewDefensiveModeCmd() *cobra.Command
- func NewEdgeWorkersCmd() *cobra.Command
- func NewUpdateCmd(runner UpdateRunner) *cobra.Command
- func NewWhoamiCmd() *cobra.Command
- func ResolveLocalSlug(cmd *cobra.Command) (string, error)
- func ResolveSlug(cmd *cobra.Command) (string, error)
- func RunAppGet(cmd *cobra.Command, args []string) error
- func RunWhoami(deps WhoamiDeps) error
- func SearchReplaceCmd() *cobra.Command
- func SetConfig(c Config)
- func SetWPYes(v bool)
- func SlowlogsCmd() *cobra.Command
- func SyncCmd() *cobra.Command
- func WPCmd() *cobra.Command
- type Config
- type UpdateRunner
- type WhoamiDeps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppCmd ¶
AppCmd returns the `vip app` parent command. Subcommands and the wildcard dispatcher are wired in main.go (so the wildcard sees the final subcommand list).
--format is registered on the parent because `vip app <name>` dispatches via WithWildcardCommand — cobra parses flags against the matched command (appCmd), so the parent must own --format for RunAppGet to read it.
func AppDeployCmd ¶
AppDeployCmd returns `vip app deploy <file>`.
Node parity: src/bin/vip-app-deploy.ts. Custom Deployment authenticates with WPVIP_DEPLOY_TOKEN — never the keychain token — for both the access-validation and start-deploy mutations (custom-deploy.ts:56, vip-app-deploy.ts:216). No appctx resolution: --app/--env raw values go straight into ValidateCustomDeployAccess.
func AppDeployValidateCmd ¶
AppDeployValidateCmd returns `vip app deploy validate <file>`.
Node parity: src/bin/vip-app-deploy-validate.ts. Local-only: file gates + archive-structure validation, no network and no deploy token.
func AppGetCmd ¶
AppGetCmd is a non-registered cobra command that exists to document the `vip app <name>` form. Its execution path runs through appctx.WithWildcardCommand on the `vip app` parent (wired in root.go), not through the cobra dispatch tree. We keep this factory so help text + the --format flag are bound somewhere accessible for unit tests; production `--format` lives on the appCmd parent (see AppCmd).
func AppListCmd ¶
AppListCmd returns the `vip app list` command.
Wraps the genqlient AppList query. Empty results and fetch errors both print to stdout and exit 0 to match Node's vip-app-list.js behavior (see Automattic/vip-cli src/bin/vip-app-list.js).
func BackupCmd ¶
BackupCmd returns the `vip backup` parent. Children attach in root.go; the parent itself just prints help (Node: src/bin/vip-backup.ts).
func BackupDBCmd ¶
BackupDBCmd returns `vip backup db`.
Node parity: src/bin/vip-backup-db.ts + src/commands/backup-db.ts. Triggers a database backup (unless one is already running) and polls the db_backup job until its in-progress lock clears.
func CacheCmd ¶
CacheCmd returns the `vip cache` parent. Subcommands are attached in root.go; the parent itself just prints help.
func CachePurgeURLCmd ¶
CachePurgeURLCmd returns `vip cache purge-url [URLs...]`.
Node parity: src/bin/vip-cache-purge-url.js. Variadic positional URLs OR --from-file=<path>; --from-file fully REPLACES positional args when set (after readFromFile().trim(), Node does `urls = value.split('\n').map(...)`, overwriting whatever positional `urls` came in). No prompt — cache purge is a benign no-op when targeting URLs that aren't currently cached.
func ConfigCmd ¶
ConfigCmd returns the `vip config` parent. Subcommands (currently just `envvar`) are attached in root.go so the test harness can opt into the subtree it needs without dragging the others.
func ConfigEnvvarCmd ¶
ConfigEnvvarCmd returns the `vip config envvar` parent. Leaf commands list / get / get-all attach in root.go.
func ConfigEnvvarDeleteCmd ¶
ConfigEnvvarDeleteCmd returns `vip config envvar delete <VARIABLE_NAME>`.
Mutation wrapper around deleteEnvironmentVariable. Interactive flow when --skip-confirmation is absent (Node parity, src/bin/vip-config-envvar-delete.js):
- Production prod-gate: confirms against env name + app name (only on prod).
- ValidateName: rejects malformed names with the Node-parity error text.
- Text input: user must type the variable name exactly ("Type FOO to confirm deletion:").
- Yes/no: "Are you sure? Deletion is permanent" (red+bold).
- promptForReloadManifest: "Apply this environment variable update now?".
All interactive gates short-circuit to no-op under --skip-confirmation OR VIP_NON_INTERACTIVE=1 (parity scenarios use one or the other). Decline at any gate prints a Node-parity cancel line to stdout + exits 0; the mutation does not fire.
func ConfigEnvvarGetAllCmd ¶
ConfigEnvvarGetAllCmd returns `vip config envvar get-all`. Wraps the GetEnvironmentVariablesWithValues genqlient query. Empty results print the Node-parity yellow stdout message + exit 0. Column order matches Node's formatData output: <key>, value.
func ConfigEnvvarGetCmd ¶
ConfigEnvvarGetCmd returns `vip config envvar get <VARIABLE_NAME>`.
Single-name fetch is implemented client-side (envvar.Get filters the get-all result) because the schema exposes no per-name query — see envvar/envvar.go. Node parity: src/bin/vip-config-envvar-get.js uppercases the argument and prints a yellow not-found stdout message + exit 0 when the variable is missing.
func ConfigEnvvarListCmd ¶
ConfigEnvvarListCmd returns `vip config envvar list`. Wraps the GetEnvironmentVariables genqlient query. Empty results print Node's "There are no environment variables" yellow message and exit 0; the key column varies by format (name | key | id) to match Node parity.
func ConfigEnvvarSetCmd ¶
ConfigEnvvarSetCmd returns `vip config envvar set <VARIABLE_NAME>`.
Mutation wrapper around addEnvironmentVariable (server-side upsert). Production confirms inline because the prompt message interpolates the variable name + app name dynamically.
Deferred (interactive-only) behavior — see commit message:
- promptForReloadManifest after the mutation succeeds.
- Value-echo confirmation when --from-file is used.
Both are bypassed when --skip-confirmation is set or VIP_NON_INTERACTIVE=1, which covers the parity scenarios in M6.
func ConfigSoftwareCmd ¶
ConfigSoftwareCmd returns the `vip config software` parent. Subcommands (`get` now, `update` in Task 7) are attached here.
func ConfigSoftwareGetCmd ¶
ConfigSoftwareGetCmd returns the `vip config software get` leaf command.
func ConfigSoftwareUpdateCmd ¶
ConfigSoftwareUpdateCmd returns the `vip config software update` leaf command.
func DBCmd ¶
DBCmd returns the `vip db` parent. Leaf subcommands attach in root.go; the parent itself does nothing on its own (cobra prints help by default).
func DBPhpmyadminCmd ¶
DBPhpmyadminCmd returns `vip db phpmyadmin`. Node parity: src/bin/vip-db-phpmyadmin.ts + src/commands/phpmyadmin.ts. The actual three-op enable+poll+generate flow lives in internal/phpmyadmin; this command just resolves --print / --silent and dispatches.
func DevEnvCmd ¶
DevEnvCmd returns the real `vip dev-env` command tree (23 leaves). dev-env is auth-bypassed EXCEPT `sync` (which calls the VIP platform — see internal/auth/bypass.go).
func ExportCmd ¶
ExportCmd returns the `vip export` parent. Children attach in root.go; the parent itself just prints help (Node: src/bin/vip-export.js).
func ExportSQLCmd ¶
ExportSQLCmd returns `vip export sql`.
Node parity: src/bin/vip-export-sql.js + src/commands/export-sql.ts. Full exports ride the latest db_backup (optionally regenerating it); the --table/--site-id/--wpcli-command/--config-file options switch to the live-backup-copy (partial export) flow.
func ImportCmd ¶
ImportCmd returns the `vip import` parent. Children attach in root.go; the parent itself just prints help.
M6b adds validate-sql; later milestones will add sql + media + the file validators.
func ImportMediaAbortCmd ¶
ImportMediaAbortCmd returns `vip import media abort`.
Node parity: src/bin/vip-import-media-abort.js. requireConfirm gates the mutation; GraphQL errors print and exit 0 (js:103-108).
func ImportMediaCmd ¶
ImportMediaCmd returns `vip import media <file|url>`.
Node parity: src/bin/vip-import-media.js. URL or local archive (.tar.gz/.tgz/.zip); local archives upload via internal/upload and the platform fetches the resulting presigned GetObject URL. Invalid input prints a red error block and exits 0 (js:158-176).
func ImportMediaStatusCmd ¶
ImportMediaStatusCmd returns `vip import media status`.
Node parity: src/bin/vip-import-media-status.js. saveErrorLog defaults to "prompt" here (js:55) — unlike the main import command where it defaults empty.
func ImportSQLCmd ¶
ImportSQLCmd returns `vip import sql <file|url>`.
Node parity: src/bin/vip-import-sql.js (852 LOC). Flow: gates → (local) SQL validation → playbook → type-the-domain confirm → optional skip-backup double confirm → optional in-place confirm → progress phase (search-replace, upload / URL passthrough, StartImport mutation) → status polling (internal/siteimport).
func ImportSQLStatusCmd ¶
ImportSQLStatusCmd returns `vip import sql status`.
Node parity: src/bin/vip-import-sql-status.js (73 LOC). Re-enters the shared status poller with ReturnMissingJobImmediately=true so a quiet environment reports "No import job found" instead of polling forever.
func ImportValidateFilesCmd ¶
ImportValidateFilesCmd returns `vip import validate-files <folder>`.
Node parity: src/bin/vip-import-validate-files.js. Always exits 0 — findings are informational. Needs GraphQL only for the validation config (mediaImportConfig); no app/env context.
func ImportValidateSQLCmd ¶
ImportValidateSQLCmd returns `vip import validate-sql <FILE>`.
Node parity: src/bin/vip-import-validate-sql.js (24 lines) → src/lib/validations/sql.ts validate(). Local-only: no GraphQL, no appctx middleware. validate() runs with isImport=false and skipChecks=DEV_ENV_SPECIFIC_CHECKS (useStatement + siteHomeUrlLando), matching what we register in internal/sqlvalidation.
func LoginCmd ¶
LoginCmd returns `vip login`. Node parity: src/bin/vip.js runLoginFlow (the flow lives in internal/auth/login.go and is already tested). login is on the auth-bypass list, so it builds its own Store + tracker.
func LogoutCmd ¶
LogoutCmd returns `vip logout`. logout is on the auth-bypass list, so it loads and purges vip-next's token itself. Server-side invalidation is best-effort and never uses the read-only Node-token fallback; local purge and elevated-cache clear always run.
func LogsCmd ¶
LogsCmd returns `vip logs`. Wraps logsapi.RecentLogs for one-shot fetches and threads --follow through internal/polling.Loop (server-hinted backoff with min/max clamping). Node parity:
- "Invalid type/limit/format" error wording matches src/bin/vip-logs.js.
- Empty result prints "No logs found" to stderr + exit 0.
- Tab characters in messages are replaced with 4 spaces for table format output (Node's printLogs: message.replace(/\t/g, ' ')).
func NewDefensiveModeCmd ¶
NewDefensiveModeCmd returns the `defensive-mode` parent with all three subcommands attached. M4: root's --app/--env flags (alias-aware) replace the M3 numeric ID placeholders; WithAppContext + WithEnvContext middleware resolve them into the cmd.Context() AppEnv via GraphQL.
func NewEdgeWorkersCmd ¶
func NewUpdateCmd ¶
func NewUpdateCmd(runner UpdateRunner) *cobra.Command
func NewWhoamiCmd ¶
NewWhoamiCmd returns a cobra.Command that wraps RunWhoami.
func ResolveLocalSlug ¶
ResolveLocalSlug is ResolveSlug without the @app.env guard, for the one dev-env leaf where an alias is meaningful: `dev-env sync sql` uses @app.env to name the PLATFORM environment it exports from, and resolves the LOCAL target separately. Node models this by destructuring app/env out of the options before calling getEnvironmentName (vip-dev-env-sync-sql.js:98).
func ResolveSlug ¶
ResolveSlug determines which EXISTING environment a command targets, matching the Node getEnvironmentName resolution order (dev-environment-cli.ts:146-192):
- --slug, if set (lowercased by Node's processSlug — dev-environment-cli.ts:979 — which every dev-env bin registers as the option's parse function).
- An @app.env alias: REJECTED with Node's message. allowAppEnv is set by `dev-env create` alone (vip-dev-env-create.js:95); every other dev-env command refuses it rather than guessing a local environment — this is a guard on destructive commands, so it must fire before anything else.
- The slug from a discovered .wpvip/vip-dev-env.yml, announced with Node's "Using environment X from Y" line.
- The sole environment, when exactly one exists.
- Interactive: prompt to select from the existing environments.
- Otherwise: a clear "specify --slug" error (wrapping ErrNonInteractive).
Steps 5 and 6 are vip-next's replacement for Node's "More than one environment found" error / DEFAULT_SLUG fallback.
func RunAppGet ¶
RunAppGet is the wildcard dispatcher target. Wired by root.go via appctx.WithWildcardCommand(appCmd, commands.RunAppGet).
Behaviorally mirrors Node's vip-app.js: not-found and fetch-error paths print to stdout and exit 0; numeric arg → app(id:); non-numeric → apps(name:).
func RunWhoami ¶
func RunWhoami(deps WhoamiDeps) error
func SearchReplaceCmd ¶
SearchReplaceCmd returns `vip search-replace <file>`. Node parity: src/bin/vip-search-replace.js. Reuses internal/searchreplace.Run (built for import sql). Unlike the import path, standalone defaults output to STDOUT.
func SetConfig ¶
func SetConfig(c Config)
SetConfig stores runtime config (called by main.go after token validation, or by tests). See the pkgConfig comment re: t.Parallel().
func SlowlogsCmd ¶
SlowlogsCmd returns `vip slowlogs`. Mirrors LogsCmd's shape — same 1..5000 limit ceiling — with the slowlog row schema (timestamp, rowsSent, rowsExamined, queryTime, requestUri, query), and no `text` format (Node parity — vip-slowlogs.ts uses formatData only).
Note: Node's vip-slowlogs.ts declares `followLogs` but does not expose a `--follow` flag. We add it as a Go-side extension because the polling primitive is the same as `vip logs` and there's no downside to surfacing it — `getRecentSlowlogs` already accepts an `after` cursor in the Node lib.
func SyncCmd ¶
SyncCmd returns `vip sync`.
Node parity: src/bin/vip-sync.js. Production targets are rejected by WithChildEnvContext; --skip-confirmation (or a "yes" at the "Are you sure..." prompt) is required before the mutation fires.
Rendering split:
- TTY stderr: in-place frame rendering via internal/tui.MultiLineRenderer with a Node-parity braille spinner advanced on a background ticker. See sync_render.go for the renderer + spinner glue.
- Non-TTY (CI, pipes, parity scenarios): one per-transition stdout line, unchanged from the pre-spinner behavior so the M6 parity scenarios keep passing without modification.
VIP_SYNC_INTERVAL_MS overrides the 5s default poll interval. Used by the parity scenarios to keep the test wall-clock under a second.
Types ¶
type Config ¶
type Config struct {
APIHost string
Token string
// Middleware is the ordered (outermost first) gql.Middleware stack that
// handlers should attach to gql.Client instances. Wired by main.go.
// Per the M3 contract: error → rechallenge → retry → transport.
Middleware []gql.Middleware
// M4 additions:
// GQLClient is the genqlient client wrapped around the same middleware
// chain (via gql.HTTPClientWithMiddleware). Handlers and appctx
// middleware share this single client.
GQLClient graphql.Client
// Tracker emits telemetry events. Never nil in production — main.go
// constructs telemetry.NewDefault(), which returns a disabled tracker
// rather than nil when DO_NOT_TRACK / test env signals opt-out.
Tracker *telemetry.Tracker
// AppCtxConfig is consumed by appctx.WithAppContext to resolve --app
// against the GraphQL API.
AppCtxConfig appctx.AppContextConfig
}
Config holds runtime values that main.go injects before cobra dispatches.
type UpdateRunner ¶
Source Files
¶
- app.go
- app_deploy.go
- app_deploy_validate.go
- app_get.go
- app_list.go
- backup.go
- backup_db.go
- cache.go
- cache_purge_url.go
- config.go
- config_envvar.go
- config_envvar_delete.go
- config_envvar_get.go
- config_envvar_get_all.go
- config_envvar_list.go
- config_envvar_set.go
- config_software.go
- config_software_update.go
- db.go
- db_phpmyadmin.go
- defensive_mode.go
- defensive_mode_configure.go
- defensive_mode_disable.go
- defensive_mode_enable.go
- devenv.go
- devenv_create_appinfo.go
- devenv_data.go
- devenv_envvar.go
- devenv_exec.go
- devenv_lifecycle.go
- devenv_logs.go
- devenv_resolve.go
- devenv_sync.go
- devenv_sync_sites.go
- devenv_telemetry.go
- devenv_update.go
- edge_workers.go
- edge_workers_flags.go
- edge_workers_local.go
- edge_workers_mutation.go
- edge_workers_read.go
- export.go
- export_sql.go
- format_env.go
- import.go
- import_media.go
- import_media_abort.go
- import_media_confirm.go
- import_media_status.go
- import_sql.go
- import_sql_status.go
- import_validate_files.go
- import_validate_sql.go
- login.go
- logout.go
- logs.go
- nodeflag_aliases.go
- progress_renderer.go
- searchreplace.go
- slowlogs.go
- sqlreport.go
- sync.go
- sync_confirm.go
- sync_render.go
- update.go
- whoami.go
- wp.go