Documentation
¶
Overview ¶
S9.T03 — `nself backup drill` cobra wiring.
This file adds a single subcommand under the existing `backupCmd` parent (defined in backup_ops.go). The command is intentionally thin — all orchestration lives in internal/backup.Drill so the same logic powers the scripts/dr-drill.sh weekly cron + future Admin UI buttons.
Package commands: controller + project subcommands for B46 multi-tenant master controller.
CLI surface:
nself controller start | stop | status | init nself project create --slug <slug> --domain <domain> nself project delete --slug <slug> [--force] nself project list nself project status --slug <slug> nself project migrate --slug <slug> nself project shell --slug <slug> nself project rotate-credentials --slug <slug>
Feature flag: NSELF_FLAG_MULTI_TENANT_CONTROLLER must be true. When OFF, all commands print 503 Multi-tenant controller not enabled.
Package commands implements CLI commands for the nSelf binary. This file adds 'nself deploy web' which builds Vercel/web apps locally and deploys the prebuilt output — eliminating Vercel Build CPU charges (~$43/mo).
Why prebuilt: 'vercel deploy --prebuilt' skips remote build compute entirely; Vercel just serves the already-built .vercel/output directory. Local or ops-box builds are free; Vercel Build CPU is not.
Usage:
nself deploy web [app…] # build+deploy all apps (or listed subset) nself deploy web --prod # promote to production nself deploy web nchat org # subset by name nself deploy web --dry-run # print commands without running nself deploy web --token=<tok> # explicit Vercel token (else VERCEL_TOKEN)
P88 Sprint 05: `nself doctor --ai` first-run wizard. Tickets: T-05-01 (wizard), T-05-02 (headless), T-05-03 (idempotency).
Package commands — security.go ¶
`nself security` provides server-level security operations: audit, setup, and status. These commands inspect the host environment (firewall, fail2ban, SSH config) and the running stack for common hardening gaps. They are intentionally non-destructive by default — `setup` requires `--apply` to make changes, otherwise it prints what would be done.
Index ¶
- Variables
- func ApplyCommandGroups()
- func Execute() error
- func RegisterControllerCommands(root *cobra.Command)
- func ResolveLegacyDeployHost(target string) (string, bool)
- type AdminConnection
- type AdminProject
- type BackupListResult
- type Bundle
- type ConfigGetResult
- type ConfigSetResult
- type ConfigShowResult
- type DeployServerInfo
- type DeployStatusResult
- type DoctorResult
- type EnvListResult
- type ExecResult
- type FunctionInfo
- type LogSummary
- type LogVolume
- type LogsOptions
- type LogsResult
- type MigrateStatusResult
- type MigrationStatusEntry
- type PluginInstallResult
- type PluginListEntry
- type PluginListResult
- type ServiceListResult
Constants ¶
This section is empty.
Variables ¶
var RootCmd = &cobra.Command{ Use: "nself", Short: "nSelf CLI - Serverless hosting, anywhere", Long: `nSelf CLI empowers you to deploy a fully-featured, production-ready backend to any hosting provider with absolute simplicity. The Golden Path: nself init # Generate your pristine .env configuration nself build # Compose your infrastructure nself start # Boot your stack`, RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, SilenceUsage: true, SilenceErrors: true, }
RootCmd represents the base command when called without any subcommands
Functions ¶
func ApplyCommandGroups ¶ added in v1.3.0
func ApplyCommandGroups()
ApplyCommandGroups registers the groups and assigns each command to one. Called from Execute() rather than init(): every command's own init() must have run and registered it on RootCmd before assignments can be applied, and init() ordering within a package is by filename, which is not something to depend on.
Exported so the doc generators in tools/ produce the same grouping the binary shows; they walk RootCmd directly and never call Execute. Idempotent — safe to call more than once.
func Execute ¶
func Execute() error
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main().
func RegisterControllerCommands ¶ added in v1.0.12
RegisterControllerCommands attaches controller + project commands to the root command.
func ResolveLegacyDeployHost ¶ added in v1.2.1
ResolveLegacyDeployHost returns the NSELF_DEPLOY_HOST_<TARGET> (or legacy <TARGET>_DEPLOY_HOST) value for target, mirroring the lookup already used by runDeploy's remote push path.
Types ¶
type AdminConnection ¶ added in v1.0.6
type AdminConnection struct {
Name string `json:"name"`
Host string `json:"host"`
User string `json:"user"`
Port int `json:"port"`
LocalPort int `json:"local_port"`
RemotePort int `json:"remote_port"`
}
AdminConnection represents a saved remote admin connection.
type AdminProject ¶ added in v1.0.6
type AdminProject struct {
ID string `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Host string `json:"host"`
SSHUser string `json:"ssh_user"`
URL string `json:"url"`
}
AdminProject represents a project in the multi-project config.
type BackupListResult ¶ added in v1.3.0
type BackupListResult struct {
Backups []backup.BackupEntry `json:"backups"`
}
BackupListResult wraps backup.List's slice.
type ConfigGetResult ¶ added in v1.3.0
type ConfigGetResult struct {
Key string `json:"key"`
Value string `json:"value"`
Redacted bool `json:"redacted"`
}
ConfigGetResult is the structured output of the nself_config_get tool.
type ConfigSetResult ¶ added in v1.3.0
type ConfigSetResult struct {
Key string `json:"key"`
File string `json:"file"`
Created bool `json:"created"`
}
ConfigSetResult is the structured output of the nself_config_set tool.
type ConfigShowResult ¶ added in v1.3.0
type ConfigShowResult struct {
EnvFile string `json:"env_file"`
Values map[string]string `json:"values"`
}
ConfigShowResult is the structured output of the nself_config_show tool.
type DeployServerInfo ¶ added in v1.3.0
type DeployServerInfo struct {
Env string `json:"env"`
Server string `json:"server"`
Role string `json:"role"`
Host string `json:"host,omitempty"`
}
DeployServerInfo is one entry from the control-plane inventory.
type DeployStatusResult ¶ added in v1.3.0
type DeployStatusResult struct {
LocalState string `json:"local_state"`
Servers []DeployServerInfo `json:"servers,omitempty"`
Note string `json:"note"`
}
DeployStatusResult is the structured output of the nself_deploy_status tool.
type DoctorResult ¶ added in v1.3.0
type DoctorResult struct {
Checks []doctor.CheckResult `json:"checks"`
}
DoctorResult wraps doctor.DeepChecks' slice in a top-level object, since the MCP output-schema contract requires an object at the root.
type EnvListResult ¶ added in v1.3.0
EnvListResult wraps env.List's slice. Only names + active flag + file path are exposed — no values, so there is nothing here that needs redaction.
type ExecResult ¶ added in v1.3.0
type ExecResult struct {
Command string `json:"command"`
Output string `json:"output"`
Success bool `json:"success"`
}
ExecResult is the structured output of every re-exec'd lifecycle tool (build/start/stop/restart).
type FunctionInfo ¶ added in v1.0.11
type FunctionInfo struct {
Name string `json:"name"`
Status string `json:"status"`
URL string `json:"url"`
Dir string `json:"dir"`
}
FunctionInfo describes a deployed function.
type LogSummary ¶
type LogSummary struct {
Service string
TotalLines int
ErrorCount int
WarnCount int
TopErrors []string // up to 5 most frequent error messages (deduped)
LastLine string
}
LogSummary holds per-service log analysis results.
func CollectLogSummary ¶
func CollectLogSummary(ctx context.Context, workdir string, service string, maxLines int) (*LogSummary, error)
CollectLogSummary fetches and analyses recent logs for a single service.
type LogVolume ¶
type LogVolume struct {
Service string
LinesPerMin float64
BytesPerMin float64
ErrorRate float64 // errors / total lines in sample window
}
LogVolume holds per-service log volume sample data.
type LogsOptions ¶
type LogsOptions struct {
Search string
Grep string // regex pattern for --grep
Errors bool
Level string // debug|info|warn|error
Compact bool
Quiet bool
Tail int
Follow bool
Since string // relative (1h, 30m) or absolute RFC3339
Until string // relative or absolute RFC3339
JSON bool // structured JSON output per line
NoColor bool
Plain bool // disable highlighting for piping
Service []string
}
LogsOptions holds parsed flag values for log filtering and formatting.
type LogsResult ¶ added in v1.3.0
type LogsResult struct {
Service string `json:"service,omitempty"`
Lines int `json:"lines"`
Output string `json:"output"`
}
LogsResult is the structured output of the nself_logs tool.
type MigrateStatusResult ¶ added in v1.3.0
type MigrateStatusResult struct {
Migrations []MigrationStatusEntry `json:"migrations"`
}
MigrateStatusResult wraps the migration status slice.
type MigrationStatusEntry ¶ added in v1.3.0
type MigrationStatusEntry struct {
Name string `json:"name"`
Applied bool `json:"applied"`
AppliedAt time.Time `json:"applied_at,omitempty"`
}
MigrationStatusEntry mirrors database.MigrationStatus with JSON tags — that type has none, since it's only ever printed as a table today.
type PluginInstallResult ¶ added in v1.3.0
type PluginInstallResult struct {
Name string `json:"name"`
Installed bool `json:"installed"`
Message string `json:"message,omitempty"`
}
PluginInstallResult is the structured output of the nself_plugin_install tool.
type PluginListEntry ¶ added in v1.3.0
type PluginListEntry struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
Category string `json:"category,omitempty"`
Installed bool `json:"installed"`
Running bool `json:"running"`
PublishStatus string `json:"publish_status,omitempty"`
}
PluginListEntry mirrors plugin.PluginInfo with JSON tags.
type PluginListResult ¶ added in v1.3.0
type PluginListResult struct {
Plugins []PluginListEntry `json:"plugins"`
}
PluginListResult wraps the plugin list slice.
type ServiceListResult ¶ added in v1.3.0
ServiceListResult wraps service.PS's slice in a top-level object.
Source Files
¶
- account.go
- account_devices.go
- account_licenses.go
- account_login.go
- account_logout.go
- account_status.go
- account_team.go
- account_transfer.go
- admin.go
- admin_connect.go
- admin_connect_helpers.go
- admin_projects.go
- admin_projects_storage.go
- aliases.go
- backup_config_status.go
- backup_create_list.go
- backup_drill.go
- backup_key_stream.go
- backup_ops.go
- backup_restore.go
- backup_resume_schedule.go
- backup_verify_prune.go
- browser.go
- build.go
- bundle.go
- bundle_info.go
- bundle_install_remove.go
- bundle_list.go
- ci.go
- ci_forgejo.go
- ci_serve.go
- clean.go
- completion.go
- config.go
- config_export_import.go
- config_helpers.go
- config_list_validate.go
- config_set.go
- config_show_get.go
- controller.go
- controller_commands.go
- db.go
- db_admin.go
- db_audit.go
- db_audit_ops.go
- db_backup.go
- db_commands_ext.go
- db_drift.go
- db_hasura.go
- db_hasura_git.go
- db_helpers.go
- db_lint.go
- db_migrate.go
- db_pgbouncer.go
- db_pitr.go
- db_pitr_ops.go
- db_remote.go
- db_remote_exec.go
- db_remote_version.go
- db_rls.go
- db_schema.go
- db_seed.go
- db_seed_ext.go
- deploy.go
- deploy_diagnostics.go
- deploy_env_resolve.go
- deploy_environments.go
- deploy_health_remote.go
- deploy_inventory.go
- deploy_lifecycle.go
- deploy_output.go
- deploy_remote.go
- deploy_run.go
- deploy_strategies.go
- deploy_web.go
- deploy_web_helpers.go
- deploy_web_run.go
- dev.go
- dispatch.go
- dns.go
- doctor.go
- doctor_ai.go
- doctor_ai_client.go
- doctor_ai_health.go
- doctor_ai_output.go
- doctor_ai_wizard_local.go
- doctor_ai_wizard_verify.go
- doctor_checks_config.go
- doctor_checks_env.go
- doctor_checks_license.go
- doctor_checks_plugins.go
- doctor_checks_routes.go
- doctor_health_report.go
- doctor_homebrew.go
- doctor_install_check.go
- doctor_sysinfo_linux.go
- doctor_sysinfo_unix.go
- env.go
- env_explain.go
- env_target.go
- env_target_crud.go
- env_target_probe.go
- exec.go
- feature.go
- flag.go
- flag_mutate.go
- flag_query.go
- functions.go
- functions_delete.go
- functions_deploy.go
- functions_invoke.go
- functions_list.go
- functions_logs.go
- generate.go
- groups.go
- health.go
- health_handlers.go
- help_topics.go
- init.go
- init_presets.go
- init_run.go
- init_templates.go
- install.go
- legacy_spellings.go
- license.go
- license_grace.go
- license_keys.go
- license_migrate.go
- license_migrate_actions.go
- license_migrate_api.go
- license_revoke.go
- license_simulate.go
- license_status.go
- license_tail.go
- license_validate.go
- login.go
- logout.go
- logs.go
- logs_filter.go
- logs_metrics.go
- logs_reports.go
- logs_stream.go
- maintenance.go
- man.go
- mcp.go
- mcp_auth.go
- mcp_exec.go
- mcp_prompts.go
- mcp_resources.go
- mcp_sentry.go
- mcp_sentry_status.go
- mcp_tools_core.go
- mcp_tools_data.go
- mcp_tools_mutate.go
- mcp_tools_ops.go
- migrate.go
- migrate_env_order.go
- migrate_firebase.go
- migrate_from_bash.go
- migrate_from_v099.go
- migrate_generate.go
- migrate_supabase.go
- migrate_watch.go
- migrate_watch_scan.go
- oauth_refresh.go
- ops.go
- pitr.go
- plugin.go
- plugin_audit.go
- plugin_compat_check.go
- plugin_debug.go
- plugin_dev.go
- plugin_info.go
- plugin_install.go
- plugin_install_graph.go
- plugin_install_thirdparty.go
- plugin_install_upsell.go
- plugin_lifecycle.go
- plugin_link.go
- plugin_logs.go
- plugin_marketplace.go
- plugin_marketplace_cmds.go
- plugin_new.go
- plugin_outdated.go
- plugin_query.go
- plugin_search.go
- plugin_submit.go
- plugin_test_cmd.go
- project_cmd_core.go
- project_cmd_ops.go
- promote.go
- release.go
- release_check.go
- release_check_gates.go
- release_common.go
- release_deploy_steps.go
- release_git.go
- release_rollback.go
- release_status.go
- reset.go
- restart.go
- restart_strategies.go
- root.go
- root_source_guard.go
- secrets.go
- secrets_audit.go
- secrets_core.go
- secrets_edit_rotate.go
- secrets_schedule.go
- security.go
- security_checks_certs_keys.go
- security_checks_system.go
- security_commands.go
- self_heal.go
- service.go
- service_add_upgrade.go
- service_configure.go
- service_enable_disable.go
- service_lifecycle.go
- service_list.go
- ssl.go
- ssl_add.go
- ssl_install.go
- ssl_renewal.go
- ssl_setup.go
- start.go
- start_embedded_cgo.go
- start_health.go
- start_preflight.go
- start_urls.go
- status.go
- status_print.go
- stop.go
- telemetry.go
- template.go
- template_list_info.go
- template_publish_update.go
- template_registry.go
- trust.go
- trust_config.go
- trust_status.go
- trust_status_detailed.go
- trust_undo.go
- uninstall.go
- update.go
- update_binary_ops.go
- update_images.go
- update_release_api.go
- update_selfupdate.go
- upgrade.go
- upgrade_binary.go
- upgrade_cmd.go
- urls.go
- urls_build.go
- urls_diff.go
- urls_display.go
- verify_sbom.go
- version.go