README ¶ key/file 本地文件实现由 key.NewKey 内部使用,业务不需要直接初始化该子包。 当 key.yaml 未配置,或 type 为空/未知时,默认读取 ${conf}/root.key。文件内容可以是原始 32 字节, 也可以是 Base64 编码的根密钥;生产环境请将文件权限限制为 0400 或 0600。 Provider 初始化时会使用系统随机源创建缺失的根密钥文件并设置 0600 权限;已有文件直接复用,不会覆盖。 Expand ▾ Collapse ▴ Documentation ¶ Index ¶ func NewFromConfig(cfg *configv1.Key) (internal.Provider, error) type Provider func New(path string) (*Provider, error) func (p *Provider) Get(_ context.Context, name string) (internal.Secret, error) Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func NewFromConfig ¶ func NewFromConfig(cfg *configv1.Key) (internal.Provider, error) NewFromConfig 根据 Key 配置创建本地文件密钥 Provider。 Types ¶ type Provider ¶ type Provider struct { // contains filtered or unexported fields } Provider 从本地文件读取密钥,适用于开发环境或挂载的 Kubernetes Secret。 func New ¶ func New(path string) (*Provider, error) New 创建固定文件路径的密钥 Provider。 func (*Provider) Get ¶ func (p *Provider) Get(_ context.Context, name string) (internal.Secret, error) Get 读取密钥文件内容。 Source Files ¶ View all Source files file.go Click to show internal directories. Click to hide internal directories.