env

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package env 提供环境相关的公共处理能力。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEnv

func CreateEnv(ctx context.Context, workspaceID, specFile string) (*client.Env, error)

CreateEnv 读取 YAML spec 文件,创建环境并返回创建结果。

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

func ListFeatureEnvs(ctx context.Context, cli client.Client, appID string) ([]client.Env, error)

ListFeatureEnvs 从应用可用环境中筛选特性环境,保留完整环境信息用于输出。

func ParseScope

func ParseScope(scope string) (scopeType, scopeValue string, err error)

ParseScope 解析 --scope 参数值,格式为 "workspace" 或 "envType:"。 未指定时默认为 workspace 级别。 返回 scopeType 和 scopeValue。

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 的规范化和必填校验由调用方完成。

func ResolveScopedEnvVarID

func ResolveScopedEnvVarID(
	ctx context.Context, cli client.Client, workspaceID, key, scopeType, scopeValue string,
) (string, error)

ResolveScopedEnvVarID 通过 key + scopeType + scopeValue 从公共环境变量列表中查找变量 ID。 用于 public 级别的 update/delete 命令,通过人类可读的标识定位变量。

func UpdateEnv

func UpdateEnv(ctx context.Context, workspaceID, envName string, body client.UpdateEnvBasicInfoBody) error

UpdateEnv 通过环境名称解析 ID,更新环境基本信息(displayName / type)。

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 格式输出。

Jump to

Keyboard shortcuts

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