Documentation
¶
Overview ¶
Package system 实现 system binder:设置、凭证、资产 CRUD、状态、字体、重启等控制面方法。
同时承载所有 binder 共用的 LangProvider/WindowActivator 接口实现: 语言状态作为唯一可信源在 system 里,其它 binder 持有 *system.System 通过 Lang() 读取。
Index ¶
- func ApplySSHTuning(cfg *bootstrap.AppConfig)
- type AuditLogListResult
- type BugReportInfo
- type ImportFileInfo
- type OpsctlInfo
- type PolicyTestRequest
- type PolicyTestResult
- type SSHConnectionSettings
- type SkillContent
- type SkillTarget
- type System
- func (s *System) ActivateWindow()
- func (s *System) CancelGitHubAuth()
- func (s *System) CancelTest(testID string)
- func (s *System) CheckForUpdate() (*update_svc.UpdateInfo, error)
- func (s *System) Cleanup()
- func (s *System) ClearGitHubToken() error
- func (s *System) ClearWebDAVConfig() error
- func (s *System) CopyPolicyGroup(id string, name string) (*policy_group_entity.PolicyGroup, error)
- func (s *System) CreateAsset(asset *asset_entity.Asset) error
- func (s *System) CreateGroup(group *group_entity.Group) error
- func (s *System) CreatePasswordCredential(name, username, password, description string) (*credential_entity.Credential, error)
- func (s *System) CreatePolicyGroup(pg policy_group_entity.PolicyGroup) (*policy_group_entity.PolicyGroup, error)
- func (s *System) DeleteAsset(id int64) error
- func (s *System) DeleteCredential(id int64) error
- func (s *System) DeleteGroup(id int64, deleteAssets bool) error
- func (s *System) DeletePolicyGroup(id string) error
- func (s *System) DetectOpsctl() OpsctlInfo
- func (s *System) DetectSkills() []SkillTarget
- func (s *System) DownloadAndInstallUpdate(skipChecksum bool) error
- func (s *System) EncryptPassword(plaintext string) (string, error)
- func (s *System) ExecuteImportFile(filePath, password string, opts backup_svc.ImportOptions) (*backup_svc.ImportResult, error)
- func (s *System) ExportData() (string, error)
- func (s *System) ExportSSHPrivateKey(id int64) (bool, error)
- func (s *System) ExportToFile(password string, opts backup_svc.ExportOptions) error
- func (s *System) ExportToGist(password, token, gistID string, opts backup_svc.ExportOptions) (*backup_svc.GistInfo, error)
- func (s *System) ExportToWebDAV(password string, opts backup_svc.ExportOptions) (*backup_svc.WebDAVBackupInfo, error)
- func (s *System) GenerateSSHKey(name, comment, keyType string, keySize int, passphrase, username string) (*credential_entity.Credential, error)
- func (s *System) GetAppVersion() string
- func (s *System) GetAsset(id int64) (*asset_entity.Asset, error)
- func (s *System) GetAssetPassword(assetID int64) (string, error)
- func (s *System) GetAvailableMirrors() []update_svc.MirrorInfo
- func (s *System) GetBugReportInfo() BugReportInfo
- func (s *System) GetCredentialPublicKey(id int64) (string, error)
- func (s *System) GetCredentialUsage(id int64) ([]string, error)
- func (s *System) GetDataDir() string
- func (s *System) GetDebugMode() bool
- func (s *System) GetDefaultPolicy(assetType string) (string, error)
- func (s *System) GetDownloadMirror() string
- func (s *System) GetGitHubToken() (string, error)
- func (s *System) GetGitHubUser(token string) (*backup_svc.GitHubUser, error)
- func (s *System) GetGroup(id int64) (*group_entity.Group, error)
- func (s *System) GetLanguage() string
- func (s *System) GetOpsctlInstallDir() string
- func (s *System) GetPluginReferenceDir() string
- func (s *System) GetSSHConnectionSettings() SSHConnectionSettings
- func (s *System) GetSkillPreview() string
- func (s *System) GetStoredGitHubUser() string
- func (s *System) GetSystemStatus() []status.Entry
- func (s *System) GetUpdateChannel() string
- func (s *System) GetWebDAVConfig() (*WebDAVStoredConfig, error)
- func (s *System) ImportFromGist(gistID, password, token string, opts backup_svc.ImportOptions) (*backup_svc.ImportResult, error)
- func (s *System) ImportFromWebDAV(name, password string, opts backup_svc.ImportOptions) (*backup_svc.ImportResult, error)
- func (s *System) ImportSSHConfigSelected(selectedIndexes []int, overwrite bool) (*import_svc.ImportResult, error)
- func (s *System) ImportSSHKeyFile(name, comment, passphrase, username string) (*credential_entity.Credential, error)
- func (s *System) ImportSSHKeyPEM(name, comment, pemData, passphrase, username string) (*credential_entity.Credential, error)
- func (s *System) ImportSSHKeyPath(name, comment, filePath, passphrase, username string) (*credential_entity.Credential, error)
- func (s *System) ImportTabbySelected(selectedIndexes []int, passphrase string, overwrite bool) (*import_svc.ImportResult, error)
- func (s *System) ImportWindTermSelected(sourceID string, selectedIndexes []int, overwrite bool) (*import_svc.ImportResult, error)
- func (s *System) InstallOpsctl(targetDir string) (string, error)
- func (s *System) InstallSkills() error
- func (s *System) Lang() string
- func (s *System) ListAssets(assetType string, groupID int64) ([]*asset_entity.Asset, error)
- func (s *System) ListAuditLogs(source string, assetID int64, startTime, endTime int64, offset, limit int, ...) (*AuditLogListResult, error)
- func (s *System) ListAuditSessions(startTime int64) ([]audit_repo.SessionInfo, error)
- func (s *System) ListBackupGists(token string) ([]*backup_svc.GistInfo, error)
- func (s *System) ListCredentials() ([]*credential_entity.Credential, error)
- func (s *System) ListCredentialsByType(credType string) ([]*credential_entity.Credential, error)
- func (s *System) ListGroups() ([]*group_entity.Group, error)
- func (s *System) ListPolicyGroups(policyType string) ([]*policy_group_entity.PolicyGroupItem, error)
- func (s *System) ListSystemFonts() ([]string, error)
- func (s *System) ListWebDAVBackups() ([]*backup_svc.WebDAVBackupInfo, error)
- func (s *System) MoveAsset(id int64, direction string) error
- func (s *System) MoveGroup(id int64, direction string) error
- func (s *System) OnSecondInstanceLaunch()
- func (s *System) OpenDirectory(path string) error
- func (s *System) OpenLogsDir() error
- func (s *System) PreviewGistBackup(gistID, password, token string) (*backup_svc.BackupSummary, error)
- func (s *System) PreviewImportFile(filePath, password string) (*backup_svc.BackupSummary, error)
- func (s *System) PreviewSSHConfig() (*import_svc.PreviewResult, error)
- func (s *System) PreviewTabbyConfig() (*import_svc.PreviewResult, error)
- func (s *System) PreviewWindTermConfig() (*import_svc.WindTermPreviewResult, error)
- func (s *System) RenameGroup(id int64, name string) error
- func (s *System) ReorderAsset(id, targetGroupID, beforeID int64) error
- func (s *System) ReorderGroup(id, targetParentID, beforeID int64) error
- func (s *System) RestartApp() error
- func (s *System) SaveGitHubToken(token, user string) error
- func (s *System) SaveWebDAVConfig(in WebDAVSaveInput) error
- func (s *System) SelectImportFile() (*ImportFileInfo, error)
- func (s *System) SelectSQLiteFile() (string, error)
- func (s *System) SetDebugMode(enabled bool) error
- func (s *System) SetDownloadMirror(mirror string) error
- func (s *System) SetLanguage(lang string)
- func (s *System) SetSSHConnectionSettings(in SSHConnectionSettings) error
- func (s *System) SetUpdateChannel(channel string) error
- func (s *System) StartGitHubDeviceFlow() (*backup_svc.DeviceFlowInfo, error)
- func (s *System) Startup(ctx context.Context)
- func (s *System) TestAssetConnection(testID, assetType, configJSON, plainPassword string) error
- func (s *System) TestPolicyRule(req PolicyTestRequest) (*PolicyTestResult, error)
- func (s *System) TestWebDAVConfig(in WebDAVSaveInput) error
- func (s *System) UninstallSkill(key string) error
- func (s *System) UpdateAsset(asset *asset_entity.Asset) error
- func (s *System) UpdateCredential(id int64, name, comment, description, username string) (*credential_entity.Credential, error)
- func (s *System) UpdateCredentialPassphrase(id int64, oldPassphrase, newPassphrase string) error
- func (s *System) UpdateCredentialPassword(id int64, password string) error
- func (s *System) UpdateGroup(group *group_entity.Group) error
- func (s *System) UpdatePolicyGroup(pg policy_group_entity.PolicyGroup) error
- func (s *System) WaitGitHubDeviceAuth(deviceCode string, interval int) (string, error)
- type WebDAVSaveInput
- type WebDAVStoredConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplySSHTuning ¶ added in v1.10.0
ApplySSHTuning 在启动时由 main.go 调用,把持久化配置注入全局连接调优, 使首个连接即采用用户配置。
Types ¶
type AuditLogListResult ¶
type AuditLogListResult struct {
Items []*audit_entity.AuditLog `json:"items"`
Total int64 `json:"total"`
}
AuditLogListResult 审计日志列表结果
type BugReportInfo ¶
type BugReportInfo struct {
Version string `json:"version"`
Commit string `json:"commit"`
OS string `json:"os"`
Arch string `json:"arch"`
OSLabel string `json:"osLabel"`
}
BugReportInfo 用于前端拼接 GitHub Issue 预填 URL 的诊断信息。
type ImportFileInfo ¶
type ImportFileInfo struct {
FilePath string `json:"filePath"`
Encrypted bool `json:"encrypted"`
Summary *backup_svc.BackupSummary `json:"summary,omitempty"`
}
ImportFileInfo 导入文件信息
type OpsctlInfo ¶
type OpsctlInfo struct {
Installed bool `json:"installed"`
Path string `json:"path"`
Version string `json:"version"`
Embedded bool `json:"embedded"` // 桌面端是否内嵌了 opsctl 二进制
}
OpsctlInfo opsctl CLI 检测结果
type PolicyTestRequest ¶
type PolicyTestRequest struct {
PolicyType string `json:"policyType"` // 前端资产 policyType(ssh/database/redis/k8s/etcd/...);经 ResolvePolicyKind 映射到 policyKind
PolicyJSON string `json:"policyJSON"` // JSON 编码的策略结构体(当前编辑状态)
Command string `json:"command"` // 待测试的命令/SQL/Redis命令
AssetID int64 `json:"assetID"` // 资产ID(用于解析资产组链)
GroupID int64 `json:"groupID"` // 资产组ID(用于解析父组链)
}
PolicyTestRequest 策略测试请求
type PolicyTestResult ¶
type PolicyTestResult struct {
Decision string `json:"decision"` // "allow" | "deny" | "need_confirm"
MatchedPattern string `json:"matchedPattern"` // 匹配到的规则
MatchedSource string `json:"matchedSource"` // 匹配来源: "" 当前策略, "default" 默认规则, 或组名
Message string `json:"message"` // 可读说明
}
PolicyTestResult 策略测试结果
type SSHConnectionSettings ¶ added in v1.10.0
type SSHConnectionSettings struct {
KeepAliveIntervalSeconds int `json:"keepAliveIntervalSeconds"` // SSH 空闲保活心跳间隔(秒)
}
SSHConnectionSettings 是前端可读写的 SSH 空闲保活全局默认。TCP_NODELAY / SO_KEEPALIVE / 连接超时不再暴露给用户(恒采用内置默认),故此处只有保活间隔。 返回值已填充默认,所以 UI 永远拿到真实数值(30)而非代表"未设置"的 0。
type SkillContent ¶
type SkillContent struct {
SkillMD string
CommandsMD string
InitMD string
PluginJSON string
MarketplaceJSON string
PluginMarketplaceJSON string
}
SkillContent 内嵌的 skill/plugin 文件内容(由 main.go 通过 go:embed 注入)
type SkillTarget ¶
type SkillTarget struct {
Key string `json:"key"`
Name string `json:"name"`
Installed bool `json:"installed"`
Path string `json:"path"`
}
SkillTarget AI Skill 安装目标
type System ¶
type System struct {
// contains filtered or unexported fields
}
System 控制面 binder:设置、凭证、资产、状态、重启、字体等。 同时是 LangProvider / WindowActivator 实现。
func New ¶
func New(appCtx context.Context, skill SkillContent) *System
New 构造 System binder。appCtx 来自 main.go 的根 context(cancel 后所有 binder 退出)。
func (*System) ActivateWindow ¶
func (s *System) ActivateWindow()
ActivateWindow 把窗口拉到前台(WindowActivator 接口;审批弹窗等场景调用)。
func (*System) CancelGitHubAuth ¶
func (s *System) CancelGitHubAuth()
CancelGitHubAuth 取消 GitHub 授权等待
func (*System) CancelTest ¶
CancelTest 取消正在进行的资产「测试连接」操作。 testID 由前端在调用 Test*Connection 时生成;未匹配到的 ID 静默忽略。
func (*System) CheckForUpdate ¶
func (s *System) CheckForUpdate() (*update_svc.UpdateInfo, error)
CheckForUpdate 检查是否有新版本
func (*System) ClearGitHubToken ¶
ClearGitHubToken 清除保存的 GitHub token
func (*System) ClearWebDAVConfig ¶
ClearWebDAVConfig 清除 WebDAV 备份配置。
func (*System) CopyPolicyGroup ¶
func (s *System) CopyPolicyGroup(id string, name string) (*policy_group_entity.PolicyGroup, error)
CopyPolicyGroup 复制权限组(内置或自定义)
func (*System) CreateAsset ¶
func (s *System) CreateAsset(asset *asset_entity.Asset) error
CreateAsset 创建资产
func (*System) CreateGroup ¶
func (s *System) CreateGroup(group *group_entity.Group) error
CreateGroup 创建分组
func (*System) CreatePasswordCredential ¶
func (s *System) CreatePasswordCredential(name, username, password, description string) (*credential_entity.Credential, error)
CreatePasswordCredential 创建密码凭证
func (*System) CreatePolicyGroup ¶
func (s *System) CreatePolicyGroup(pg policy_group_entity.PolicyGroup) (*policy_group_entity.PolicyGroup, error)
CreatePolicyGroup 创建自定义权限组
func (*System) DeleteCredential ¶
DeleteCredential 删除凭证
func (*System) DeleteGroup ¶
DeleteGroup 删除分组 deleteAssets: true 删除分组下的资产,false 移动到未分组
func (*System) DeletePolicyGroup ¶
DeletePolicyGroup 删除自定义权限组
func (*System) DetectOpsctl ¶
func (s *System) DetectOpsctl() OpsctlInfo
DetectOpsctl 检测 opsctl CLI 是否已安装
func (*System) DetectSkills ¶
func (s *System) DetectSkills() []SkillTarget
DetectSkills 检测所有 AI 工具的 Skill 安装状态
func (*System) DownloadAndInstallUpdate ¶
DownloadAndInstallUpdate 下载并安装更新 更新完成后需要用户重启应用
func (*System) EncryptPassword ¶
EncryptPassword 加密密码,返回加密后的字符串(用于前端保存资产配置)
func (*System) ExecuteImportFile ¶
func (s *System) ExecuteImportFile(filePath, password string, opts backup_svc.ImportOptions) (*backup_svc.ImportResult, error)
ExecuteImportFile 执行文件导入
func (*System) ExportData ¶
ExportData 导出所有资产和分组为 JSON(剪贴板用,不含凭据)
func (*System) ExportSSHPrivateKey ¶ added in v1.9.0
ExportSSHPrivateKey exports an SSH key credential's decrypted private key to a user-selected file.
func (*System) ExportToFile ¶
func (s *System) ExportToFile(password string, opts backup_svc.ExportOptions) error
ExportToFile 导出备份到文件
func (*System) ExportToGist ¶
func (s *System) ExportToGist(password, token, gistID string, opts backup_svc.ExportOptions) (*backup_svc.GistInfo, error)
ExportToGist 加密并上传备份到 Gist
func (*System) ExportToWebDAV ¶
func (s *System) ExportToWebDAV(password string, opts backup_svc.ExportOptions) (*backup_svc.WebDAVBackupInfo, error)
ExportToWebDAV 加密并上传备份到 WebDAV。
func (*System) GenerateSSHKey ¶
func (s *System) GenerateSSHKey(name, comment, keyType string, keySize int, passphrase, username string) (*credential_entity.Credential, error)
GenerateSSHKey 生成新的 SSH 密钥对
func (*System) GetAsset ¶
func (s *System) GetAsset(id int64) (*asset_entity.Asset, error)
GetAsset 获取资产详情
func (*System) GetAssetPassword ¶
GetAssetPassword 获取指定资产的解密密码(用于编辑时回看密码)
func (*System) GetAvailableMirrors ¶
func (s *System) GetAvailableMirrors() []update_svc.MirrorInfo
GetAvailableMirrors 返回可用的下载镜像列表
func (*System) GetBugReportInfo ¶
func (s *System) GetBugReportInfo() BugReportInfo
GetBugReportInfo 返回用于 Bug 反馈模板预填的系统信息。
func (*System) GetCredentialPublicKey ¶
GetCredentialPublicKey 获取 SSH 密钥凭证的公钥(用于复制)
func (*System) GetCredentialUsage ¶
GetCredentialUsage 获取引用此凭证的资产名称列表
func (*System) GetDefaultPolicy ¶
GetDefaultPolicy 获取指定资产类型的默认策略 JSON
func (*System) GetDownloadMirror ¶
GetDownloadMirror 获取当前下载镜像 URL 前缀
func (*System) GetGitHubToken ¶
GetGitHubToken 获取解密后的 GitHub token
func (*System) GetGitHubUser ¶
func (s *System) GetGitHubUser(token string) (*backup_svc.GitHubUser, error)
GetGitHubUser 获取 GitHub 用户信息
func (*System) GetGroup ¶
func (s *System) GetGroup(id int64) (*group_entity.Group, error)
GetGroup 获取单个分组详情
func (*System) GetOpsctlInstallDir ¶
GetOpsctlInstallDir 返回默认安装目录
func (*System) GetPluginReferenceDir ¶
GetPluginReferenceDir 返回应用数据目录下的插件参考目录
func (*System) GetSSHConnectionSettings ¶ added in v1.10.0
func (s *System) GetSSHConnectionSettings() SSHConnectionSettings
GetSSHConnectionSettings 返回当前生效的保活全局默认(默认已填充)。
func (*System) GetSkillPreview ¶
GetSkillPreview 获取 Skill 文件内容预览
func (*System) GetStoredGitHubUser ¶
GetStoredGitHubUser 获取保存的 GitHub 用户名
func (*System) GetSystemStatus ¶
GetSystemStatus 返回启动阶段收集的状态条目(前端设置页主动查询)
func (*System) GetUpdateChannel ¶
GetUpdateChannel 获取当前更新通道
func (*System) GetWebDAVConfig ¶
func (s *System) GetWebDAVConfig() (*WebDAVStoredConfig, error)
GetWebDAVConfig 读取已保存的 WebDAV 配置,password / token 解密后明文回填。
func (*System) ImportFromGist ¶
func (s *System) ImportFromGist(gistID, password, token string, opts backup_svc.ImportOptions) (*backup_svc.ImportResult, error)
ImportFromGist 从 Gist 导入备份
func (*System) ImportFromWebDAV ¶
func (s *System) ImportFromWebDAV(name, password string, opts backup_svc.ImportOptions) (*backup_svc.ImportResult, error)
ImportFromWebDAV 从 WebDAV 导入备份。
func (*System) ImportSSHConfigSelected ¶
func (s *System) ImportSSHConfigSelected(selectedIndexes []int, overwrite bool) (*import_svc.ImportResult, error)
ImportSSHConfigSelected 导入用户选中的 SSH Config 连接
func (*System) ImportSSHKeyFile ¶
func (s *System) ImportSSHKeyFile(name, comment, passphrase, username string) (*credential_entity.Credential, error)
ImportSSHKeyFile 通过文件选择框导入 SSH 密钥
func (*System) ImportSSHKeyPEM ¶
func (s *System) ImportSSHKeyPEM(name, comment, pemData, passphrase, username string) (*credential_entity.Credential, error)
ImportSSHKeyPEM 通过粘贴 PEM 内容导入 SSH 密钥
func (*System) ImportSSHKeyPath ¶ added in v1.9.0
func (s *System) ImportSSHKeyPath(name, comment, filePath, passphrase, username string) (*credential_entity.Credential, error)
ImportSSHKeyPath imports an SSH private key from a user-selected or dropped local file path.
func (*System) ImportTabbySelected ¶
func (s *System) ImportTabbySelected(selectedIndexes []int, passphrase string, overwrite bool) (*import_svc.ImportResult, error)
ImportTabbySelected 导入用户选中的 Tabby 连接
func (*System) ImportWindTermSelected ¶ added in v1.9.0
func (s *System) ImportWindTermSelected(sourceID string, selectedIndexes []int, overwrite bool) (*import_svc.ImportResult, error)
ImportWindTermSelected 导入用户选中的 WindTerm 连接
func (*System) InstallOpsctl ¶
InstallOpsctl 将内嵌的 opsctl 二进制安装到指定目录
func (*System) InstallSkills ¶
InstallSkills 安装 Skill 文件到所有支持的 AI 工具
func (*System) ListAssets ¶
ListAssets 列出资产
func (*System) ListAuditLogs ¶
func (s *System) ListAuditLogs(source string, assetID int64, startTime, endTime int64, offset, limit int, sessionID string) (*AuditLogListResult, error)
ListAuditLogs 查询审计日志
func (*System) ListAuditSessions ¶
func (s *System) ListAuditSessions(startTime int64) ([]audit_repo.SessionInfo, error)
ListAuditSessions 查询审计日志中的会话列表
func (*System) ListBackupGists ¶
func (s *System) ListBackupGists(token string) ([]*backup_svc.GistInfo, error)
ListBackupGists 列出用户的备份 Gist
func (*System) ListCredentials ¶
func (s *System) ListCredentials() ([]*credential_entity.Credential, error)
ListCredentials 列出所有凭证
func (*System) ListCredentialsByType ¶
func (s *System) ListCredentialsByType(credType string) ([]*credential_entity.Credential, error)
ListCredentialsByType 按类型列出凭证
func (*System) ListGroups ¶
func (s *System) ListGroups() ([]*group_entity.Group, error)
ListGroups 列出所有分组
func (*System) ListPolicyGroups ¶
func (s *System) ListPolicyGroups(policyType string) ([]*policy_group_entity.PolicyGroupItem, error)
ListPolicyGroups 列出权限组(内置 + 自定义)
func (*System) ListSystemFonts ¶
ListSystemFonts returns installed font family names for settings font picker.
func (*System) ListWebDAVBackups ¶
func (s *System) ListWebDAVBackups() ([]*backup_svc.WebDAVBackupInfo, error)
ListWebDAVBackups 列出 WebDAV 目录中的 OpsKat 备份。
func (*System) OnSecondInstanceLaunch ¶
func (s *System) OnSecondInstanceLaunch()
OnSecondInstanceLaunch 第二个实例启动时激活当前窗口。
func (*System) OpenDirectory ¶
OpenDirectory 在系统文件管理器中打开指定目录
func (*System) PreviewGistBackup ¶
func (s *System) PreviewGistBackup(gistID, password, token string) (*backup_svc.BackupSummary, error)
PreviewGistBackup 预览 Gist 备份概览
func (*System) PreviewImportFile ¶
func (s *System) PreviewImportFile(filePath, password string) (*backup_svc.BackupSummary, error)
PreviewImportFile 解密并预览备份文件概览
func (*System) PreviewSSHConfig ¶
func (s *System) PreviewSSHConfig() (*import_svc.PreviewResult, error)
PreviewSSHConfig 预览 SSH Config 文件(不写入数据库) 自动检测 ~/.ssh/config,找不到则弹出文件选择框
func (*System) PreviewTabbyConfig ¶
func (s *System) PreviewTabbyConfig() (*import_svc.PreviewResult, error)
PreviewTabbyConfig 预览 Tabby 配置(不写入数据库) 自动检测默认路径,找不到则弹出文件选择框
func (*System) PreviewWindTermConfig ¶ added in v1.9.0
func (s *System) PreviewWindTermConfig() (*import_svc.WindTermPreviewResult, error)
PreviewWindTermConfig 预览 WindTerm 配置(不写入数据库) 用户自行选择 WindTerm profile 下的 terminal/user.sessions 文件
func (*System) RenameGroup ¶
RenameGroup 重命名分组
func (*System) ReorderAsset ¶
ReorderAsset 把资产拖到 targetGroupID 内 beforeID 之前;beforeID==0 表示追加末尾。 跨分组时同步 GroupID。
func (*System) ReorderGroup ¶
ReorderGroup 把分组拖到 targetParentID 下 beforeID 之前;beforeID==0 表示追加末尾。 跨父级时同步 ParentID。禁止拖到自身或自己的子孙下。
func (*System) RestartApp ¶
RestartApp relaunches OpsKat after the current process exits.
func (*System) SaveGitHubToken ¶
SaveGitHubToken 加密保存 GitHub token
func (*System) SaveWebDAVConfig ¶
func (s *System) SaveWebDAVConfig(in WebDAVSaveInput) error
SaveWebDAVConfig 保存 WebDAV 备份配置。按 AuthType 持久化对应字段,并清空其他类型字段以避免历史秘密残留。
func (*System) SelectImportFile ¶
func (s *System) SelectImportFile() (*ImportFileInfo, error)
SelectImportFile 选择备份文件并检测是否加密,返回概览信息
func (*System) SelectSQLiteFile ¶
SelectSQLiteFile 打开原生文件对话框,返回选中的 SQLite 文件绝对路径。 取消选择返回空字符串(不算错误)。前端用于资产创建/编辑时的"浏览…"按钮。
func (*System) SetDebugMode ¶
SetDebugMode 开启/关闭 debug 日志,写入配置并重建全局 logger
func (*System) SetDownloadMirror ¶
SetDownloadMirror 设置下载镜像 mirror 为镜像 URL 前缀(如 "https://ghfast.top/"),空字符串表示直连 GitHub
func (*System) SetSSHConnectionSettings ¶ added in v1.10.0
func (s *System) SetSSHConnectionSettings(in SSHConnectionSettings) error
SetSSHConnectionSettings 校验、持久化并立即应用保活全局默认。已建立的连接保持 其建立时的参数,新连接采用新值。
func (*System) SetUpdateChannel ¶
SetUpdateChannel 设置更新通道
func (*System) StartGitHubDeviceFlow ¶
func (s *System) StartGitHubDeviceFlow() (*backup_svc.DeviceFlowInfo, error)
StartGitHubDeviceFlow 发起 GitHub Device Flow 认证
func (*System) TestAssetConnection ¶ added in v1.9.0
TestAssetConnection 测试一份未保存的资产配置(资产表单「测试连接」)。 testID 配合 CancelTest 中断;assetType 经 conntest 注册表分发到对应 binder 的 tester。 共享信封(i18n ctx + 10s 超时 + testreg 取消)在此统一施加,各 tester 只做解析/解析凭据/拨号。
func (*System) TestPolicyRule ¶
func (s *System) TestPolicyRule(req PolicyTestRequest) (*PolicyTestResult, error)
TestPolicyRule 测试命令/SQL/Redis/K8S/etcd 命令是否匹配当前策略(含资产组继承)
func (*System) TestWebDAVConfig ¶
func (s *System) TestWebDAVConfig(in WebDAVSaveInput) error
TestWebDAVConfig 用入参里的字段测试 WebDAV 目录连通性与写权限。 完全使用入参字段,不再回退到已存配置——前端已回填明文凭据。
func (*System) UninstallSkill ¶ added in v1.9.0
UninstallSkill 卸载指定 AI 工具中的 opsctl Skill/插件。
func (*System) UpdateAsset ¶
func (s *System) UpdateAsset(asset *asset_entity.Asset) error
UpdateAsset 更新资产
func (*System) UpdateCredential ¶
func (s *System) UpdateCredential(id int64, name, comment, description, username string) (*credential_entity.Credential, error)
UpdateCredential 更新凭证
func (*System) UpdateCredentialPassphrase ¶
UpdateCredentialPassphrase 更新 SSH 密钥的 passphrase 需要提供旧的 passphrase 用于解密 PEM
func (*System) UpdateCredentialPassword ¶
UpdateCredentialPassword 更新密码凭证的密码
func (*System) UpdateGroup ¶
func (s *System) UpdateGroup(group *group_entity.Group) error
UpdateGroup 更新分组
func (*System) UpdatePolicyGroup ¶
func (s *System) UpdatePolicyGroup(pg policy_group_entity.PolicyGroup) error
UpdatePolicyGroup 更新自定义权限组
type WebDAVSaveInput ¶
type WebDAVSaveInput struct {
URL string `json:"url"`
AuthType string `json:"authType"`
Username string `json:"username"`
Password string `json:"password"`
Token string `json:"token"`
}
WebDAVSaveInput 是 SaveWebDAVConfig / TestWebDAVConfig 的入参,把鉴权方式与凭据收成一个 struct。
type WebDAVStoredConfig ¶
type WebDAVStoredConfig struct {
URL string `json:"url"`
AuthType string `json:"authType"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Token string `json:"token,omitempty"`
Configured bool `json:"configured"`
ExportDefaultsConfigured bool `json:"exportDefaultsConfigured"`
ExportPassword string `json:"exportPassword,omitempty"`
ExportIncludeCredentials bool `json:"exportIncludeCredentials"`
ExportIncludeForwards bool `json:"exportIncludeForwards"`
ExportIncludePolicyGroups bool `json:"exportIncludePolicyGroups"`
ExportIncludeShortcuts bool `json:"exportIncludeShortcuts"`
ExportIncludeThemes bool `json:"exportIncludeThemes"`
}
WebDAVStoredConfig 是前端可读取的 WebDAV 配置;password / token 解密后明文回填, 便于设置页编辑时直接显示已有值(数据未离开本地进程,加密存储已在落盘层做)。