Documentation
¶
Overview ¶
Package env 提供环境相关的公共处理能力。
Index ¶
- func CreateEnv(ctx context.Context, workspaceID, specFile string) (*client.Env, error)
- func CreateFeatureEnv(ctx context.Context, cli client.Client, appID, source, displayName string) (*client.Env, error)
- func ListFeatureEnvs(ctx context.Context, cli client.Client, appID string) ([]client.Env, error)
- func ParseScope(scope string) (scopeType, scopeValue string, err error)
- func ResolveEnvByName(ctx context.Context, cli client.Client, workspaceID, envName string) (*client.Env, error)
- func ResolveEnvIDByName(ctx context.Context, cli client.Client, workspaceID, envName string) (string, error)
- func ResolveEnvScopedEnvVarID(ctx context.Context, cli client.Client, envID, key string) (string, error)
- func ResolveFeatureEnv(ctx context.Context, cli client.Client, appID, nameOrID string) (*client.Env, error)
- func ResolveScopedEnvVarID(ctx context.Context, cli client.Client, ...) (string, error)
- func UpdateEnv(ctx context.Context, workspaceID, envName string, ...) error
- type EnvVarDetailedTableRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateFeatureEnv ¶ added in v1.0.3
func CreateFeatureEnv(ctx context.Context, cli client.Client, appID, source, displayName string) (*client.Env, error)
CreateFeatureEnv 在应用可用环境中按名称或 ID 解析源标准环境,然后创建特性环境。 调用方负责参数规范化和必填校验,此处校验来源类型,完整业务规则由服务端校验。
func ListFeatureEnvs ¶ added in v1.0.3
ListFeatureEnvs 从应用可用环境中筛选特性环境,保留完整环境信息用于输出。
func ParseScope ¶
ParseScope 解析 --scope 参数值,格式为 "workspace" 或 "envType:
func ResolveEnvByName ¶
func ResolveEnvByName(ctx context.Context, cli client.Client, workspaceID, envName string) (*client.Env, error)
ResolveEnvByName 通过环境名称获取完整 Env 对象(含 ID、集群信息等)。
func ResolveEnvIDByName ¶
func ResolveEnvIDByName(ctx context.Context, cli client.Client, workspaceID, envName string) (string, error)
ResolveEnvIDByName 通过环境名称解析出环境 ID。 该函数通过 ListEnvs 获取工作空间下的环境列表,按 name 匹配找到目标环境并返回其 ID。
func ResolveEnvScopedEnvVarID ¶
func ResolveEnvScopedEnvVarID(ctx context.Context, cli client.Client, envID, key string) (string, error)
ResolveEnvScopedEnvVarID 通过 envID + key 从环境级别环境变量列表中查找变量 ID。 用于 env 级别的 update/delete 命令,通过人类可读的标识定位变量。
func ResolveFeatureEnv ¶ added in v1.0.3
func ResolveFeatureEnv(ctx context.Context, cli client.Client, appID, nameOrID string) (*client.Env, error)
ResolveFeatureEnv 在应用可用环境中按名称或 ID 定位目标,并校验特性环境归属。 删除操作必须拒绝标准环境以及不属于当前应用的特性环境。 nameOrID 的规范化和必填校验由调用方完成。
Types ¶
type EnvVarDetailedTableRow ¶
type EnvVarDetailedTableRow struct {
ID string `json:"id" yaml:"id"`
ScopeType string `json:"scopeType" yaml:"scopeType"`
ScopeValue string `json:"scopeValue" yaml:"scopeValue"`
Key string `json:"key" yaml:"key"`
Value string `json:"value" yaml:"value"`
Description string `json:"description" yaml:"description"`
IsSensitive bool `json:"isSensitive" yaml:"isSensitive"`
ConflictedDetail string `json:"conflictedDetail" yaml:"conflictedDetail"`
}
EnvVarDetailedTableRow 用于 table 展示的扁平结构体,将 ScopedEnvVarDetailed 中的嵌套字段平级展开。
func ToTableRows ¶
func ToTableRows(items []client.ScopedEnvVarDetailed) []EnvVarDetailedTableRow
ToTableRows 将 []ScopedEnvVarDetailed 转换为 []EnvVarDetailedTableRow,用于 table 格式输出。