Documentation
¶
Overview ¶
* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Constants
- Variables
- func DefaultPath() (string, error)
- type File
- type NamedNamespace
- type Namespace
- type Overrides
- type Resolved
- type Store
- func (s *Store) Delete(name string) error
- func (s *Store) Get(name string) (string, Namespace, error)
- func (s *Store) List() ([]NamedNamespace, error)
- func (s *Store) Load() (*File, error)
- func (s *Store) Path() string
- func (s *Store) Resolve(overrides Overrides) (Resolved, error)
- func (s *Store) Save(file *File) error
- func (s *Store) Upsert(name string, namespace Namespace, makeCurrent bool) error
- func (s *Store) Use(name string) error
Constants ¶
const ( DefaultOutput = "json" DefaultTimeout = 30 * time.Second )
Variables ¶
Functions ¶
func DefaultPath ¶
DefaultPath 返回默认 CLI 配置文件路径。 DefaultPath returns the default CLI configuration file path.
Types ¶
type File ¶
type File struct {
CurrentNamespace string `yaml:"current_namespace,omitempty"`
Namespaces map[string]Namespace `yaml:"namespaces,omitempty"`
}
File 表示 STX CLI 的本地配置文件。 File represents the local STX CLI configuration file.
type NamedNamespace ¶
NamedNamespace 是带名称和当前状态的命名空间视图。 NamedNamespace is a namespace view with its name and current status.
type Namespace ¶
type Namespace struct {
Server string `yaml:"server,omitempty"`
Token string `yaml:"token,omitempty"`
TokenExpiresAt string `yaml:"token_expires_at,omitempty"`
Output string `yaml:"output,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
}
Namespace 保存一个远端 STX 服务及其本地凭据。 Namespace stores one remote STX server and its local credentials.
type Overrides ¶
Overrides 表示高于配置文件优先级的命令参数。 Overrides represents command arguments that take precedence over the config file.
type Resolved ¶
type Resolved struct {
Name string
Server string
Token string
TokenExpiresAt string
Output string
Timeout time.Duration
}
Resolved 表示应用命令参数、环境变量和默认值后的有效配置。 Resolved represents effective configuration after command arguments, environment variables, and defaults are applied.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 管理一个 CLI 配置文件。 Store manages one CLI configuration file.
func NewDefaultStore ¶
NewDefaultStore 创建默认路径的配置存储。 NewDefaultStore creates a configuration store at the default path.
func (*Store) Delete ¶
Delete 删除命名空间;删除当前项后选择名称排序后的第一项。 Delete removes a namespace and selects the first sorted remaining name when deleting the current one.
func (*Store) Get ¶
Get 返回指定命名空间;名称为空时使用当前命名空间。 Get returns a named namespace, using the current namespace when name is empty.
func (*Store) List ¶
func (s *Store) List() ([]NamedNamespace, error)
List 返回按名称排序且不包含令牌的命名空间元数据。 List returns namespace metadata sorted by name without tokens.
func (*Store) Load ¶
Load 读取配置;文件不存在时返回空配置。 Load reads configuration and returns an empty configuration when the file does not exist.
func (*Store) Resolve ¶
Resolve 按命令参数、环境变量、当前命名空间和默认值解析有效配置。 Resolve applies command arguments, environment variables, current namespace values, and defaults in priority order.
func (*Store) Save ¶
Save 以受限权限原子保存配置。 Save atomically persists configuration with restricted permissions.