state

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package state — зависимости команд: вывод, проект, ожидание операций и клиенты API. Клиенты — функции: строятся при первом вызове, поэтому version, help и completion работают без ключа.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoProject = i18n.Sentinel("state.err.no_project")

ErrNoProject — проект не задан ни флагом, ни в окружении.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Config      config.Config
	Version     string
	RetryDelays []time.Duration
	MaxBody     int64
}

Conn — из чего собрать клиенты API: конфиг, версия для User-Agent и настройки транспорта (тесты уменьшают паузы и предел тела).

type State

type State struct {
	Printer *output.Printer
	Project string
	// Timeout — предел --wait, PollDelay — шаг опроса операции.
	Timeout, PollDelay time.Duration
	// Env — переменная окружения (пароль из --password-env); читает её config.
	Env func(name string) string

	// ClickHouseURL — адрес API ClickHouse; флаг --api-url продукта пишет сюда.
	ClickHouseURL string
	ClickHouse    func() (*cloud.ClickHouse, error)
	// RedisURL — адрес API Redis; флаг --api-url продукта пишет сюда.
	RedisURL string
	Redis    func() (*cloud.Redis, error)
	// KafkaURL — адрес API Kafka; флаг --api-url продукта пишет сюда.
	KafkaURL      string
	Kafka         func() (*cloud.Kafka, error)
	PostgreSQLURL string
	OpenSearchURL string
	PostgreSQL    func() (*cloud.PostgreSQL, error)
	OpenSearch    func() (*cloud.OpenSearch, error)
	Compute       func() (*cloud.Compute, error)
	VPC           func() (*cloud.VPC, error)
	IAM           func() (*cloud.IAM, error)
}

State заполняет корневая команда до запуска подкоманды.

func (*State) Connect

func (s *State) Connect(c Conn) error

Connect собирает ключ, кэш токена и транспорт и заполняет клиенты API. Клиенты строятся при первом вызове; адреса продуктов берутся из полей *URL уже после разбора флагов --api-url.

func (*State) NeedProject

func (s *State) NeedProject() (string, error)

NeedProject — проект или ErrNoProject.

Jump to

Keyboard shortcuts

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