base

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: 13 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 base — поведение, общее у команд всех ресурсов: подтверждение удаления, --wait, коды выхода, вывод сырого ответа API. Команда ресурса описывается полями DeleteCmd, ListCmd, DescribeCmd.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AwaitCreated

func AwaitCreated(cmd *cobra.Command, s *state.State, raw []byte, wait bool, ops Ops, opsCmd, list string) (string, error)

AwaitCreated — create: без wait печатает операцию, с wait ждёт её и отдаёт id созданного ресурса. "" без ошибки — печатать больше нечего: у завершённой операции нет resource_id (напечатана она и подсказка про list).

func Body

func Body(v string) ([]byte, error)

Body — значение --body: JSON строкой или @файл; "" — nil.

func BodyHelpText

func BodyHelpText() string

BodyHelpText — справка флага --body на выбранном языке.

func Finish

func Finish(cmd *cobra.Command, s *state.State, raw []byte, wait bool, ops Ops, opsCmd string) error

Finish печатает операцию из ответа raw сразу или, с wait, после её завершения. opsCmd — команда операций продукта для подсказки после обрыва.

func FinishOp

func FinishOp(cmd *cobra.Command, s *state.State, op operation.Operation, ok, wait bool, ops Ops, hint string) error

FinishOp — Finish над уже разобранной операцией (ok — в ответе операция). hint — команда, которой дождаться операции после обрыва; "" — такой нет.

func OneOf

func OneOf(flag, v string, allowed ...string) (string, error)

OneOf проверяет значение enum-флага до запроса: иначе API отвечает 400 без подсказки, а *_UNSPECIFIED проходит и сервер выбирает сам. Регистр и «_»/«-» не важны; возвращает значение в виде из справки.

func ParseKV

func ParseKV(flag string, kvs []string) (map[string]string, error)

ParseKV разбирает повторяемый флаг вида ключ=значение; пустая карта — поле не отправлять.

func PrintOperation

func PrintOperation(w io.Writer, op operation.Operation)

PrintOperation — операция для человека.

func WaitOptions

func WaitOptions(s *state.State) operation.Options

WaitOptions — предел и шаг опроса из state, прогресс — в stderr.

func ZoneID

func ZoneID(ctx context.Context, s *state.State, v string) (string, error)

ZoneID принимает id или имя зоны (ru.AZ-1) и возвращает id.

Types

type Call

type Call func(ctx context.Context, s *state.State, args []string) ([]byte, error)

Call — вызов API команды; ответ — сырой JSON.

type DeleteCmd

type DeleteCmd struct {
	Use, Short string
	Args       cobra.PositionalArgs
	Delete     Call
	Ops        Ops
	// OpsCmd — команда операций продукта («redis operations get») для подсказки
	// после обрыва --wait; без NoWait у команды есть --wait.
	OpsCmd string
	NoWait bool
	// ClusterCmd — команда чтения кластера для подсказки при удалении во время создания.
	// Пустое значение сохраняет ошибки остальных ресурсов и lifecycle-команд.
	ClusterCmd string
	// NeedYesKey и YesFlagKey разрешают ключи подтверждения через литеральный
	// i18n.T (проверка каталога); nil использует прежние ключи common.*.
	NeedYesKey func() string
	YesFlagKey func() string
}

DeleteCmd — удаление: без --yes отказ, ответ — операция.

func (DeleteCmd) Cmd

func (c DeleteCmd) Cmd(s *state.State) *cobra.Command

Cmd собирает cobra-команду.

type DescribeCmd

type DescribeCmd ListCmd

DescribeCmd — как ListCmd, для одного ресурса.

func (DescribeCmd) Cmd

func (c DescribeCmd) Cmd(s *state.State) *cobra.Command

Cmd собирает cobra-команду.

type ExitError

type ExitError struct {
	Code int
	Msg  string
}

ExitError — ошибка со своим кодом выхода.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) ExitCode

func (e *ExitError) ExitCode() int

type ListCmd

type ListCmd struct {
	Use, Short string
	Aliases    []string
	Args       cobra.PositionalArgs
	List       Call
	Table      func(w io.Writer, raw []byte) error
}

ListCmd — команда чтения: List отдаёт ответ, --json печатает его как есть, Table — для человека; без Table и человеку печатается JSON.

func (ListCmd) Cmd

func (c ListCmd) Cmd(s *state.State) *cobra.Command

Cmd собирает cobra-команду.

type Logging

type Logging struct {
	// contains filtered or unexported fields
}

Logging — флаги интеграции с Клиентским логированием, одинаковые у трёх продуктов.

func (*Logging) Register

func (l *Logging) Register(cmd *cobra.Command)

Register добавляет --logging и --log-group-id.

func (*Logging) Value

func (l *Logging) Value() (cloud.Logging, error)

Value — настройка для запроса; без --logging поле не отправляется.

type Ops

type Ops func(s *state.State) (operation.Getter, error)

Ops — опрос операций продукта для --wait.

type Password

type Password struct {
	// contains filtered or unexported fields
}

Password — флаги пароля. Флага с самим паролем нет: он виден в истории shell и в списке процессов.

func (*Password) Read

func (p *Password) Read(cmd *cobra.Command, s *state.State) (string, error)

Read — пароль из переменной окружения или первой строки stdin.

func (*Password) Register

func (p *Password) Register(cmd *cobra.Command)

Register добавляет --password-stdin и --password-env.

func (*Password) RegisterNew

func (p *Password) RegisterNew(cmd *cobra.Command)

RegisterNew — те же флаги для смены пароля.

func (*Password) Set

func (p *Password) Set() bool

Set — пароль задан флагом: для update без флагов пароль не меняется.

Jump to

Keyboard shortcuts

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