secret

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsKeyringRef

func IsKeyringRef(s string) bool

IsKeyringRef 判断值是否为 keyring 引用。

func Resolve

func Resolve(raw string, opts Options) (string, *errors.XError)

Resolve 解析 secret 值,遵循 docs/config.md 的顺序:

  1. keyring:<service>/<account> → 从 keyring 读取
  2. 否则若为明文且允许明文 → 直接返回
  3. 否则报错

注意:TTY 交互输入本阶段不实现(留给 cmd 层处理)。

Types

type KeyringAPI

type KeyringAPI interface {
	Get(service, account string) (string, error)
	Set(service, account, value string) error
	Delete(service, account string) error
}

KeyringAPI 是对 OS keyring 的最小抽象,便于测试与跨平台。 service 对应 keyring 的 service name,account 对应 user/account。

type Options

type Options struct {
	AllowPlaintext bool       // 是否允许明文(默认 false)
	Keyring        KeyringAPI // 可注入的 keyring 实现(nil 则用默认)
}

Options 控制 secret 解析行为。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL