cmdutil

package
v2.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 51 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

View Source
var NamespaceSeparator = "::"

Functions

func BuildTemplatePath added in v2.30.0

func BuildTemplatePath(namespace, name string) string

func DisableAuthCheck

func DisableAuthCheck(cmd *cobra.Command) *cobra.Command

func DisableAuthCheckForCommand added in v2.57.0

func DisableAuthCheckForCommand(cmd *cobra.Command) *cobra.Command

DisableAuthCheckForCommand disables the auth check for the command only. Unlike DisableAuthCheck, the auth check of its subcommands is not affected

func DisableEncryptionCheck

func DisableEncryptionCheck(cmd *cobra.Command) *cobra.Command

DisableEncryptionCheck disable encryption check when reading the configuration

func ExecuteFileIterator added in v2.33.0

func ExecuteFileIterator(w io.Writer, log *logger.Logger, files []string, iterFactory func(string) (iterator.Iterator, error), opt FileIteratorOptions) error

func IsAuthCheckEnabled

func IsAuthCheckEnabled(cmd *cobra.Command) bool

func IsConfigEncryptionCheckEnabled

func IsConfigEncryptionCheckEnabled(cmd *cobra.Command) bool

IsConfigEncryptionCheckEnabled check if the encryption in the configuration should be validated or not

func NewRequestInputIterators

func NewRequestInputIterators(cmd *cobra.Command, cfg *config.Config) (*flags.RequestInputIterators, error)

NewRequestInputIterators create a request iterator based on pipe line configuration

func PrintResponseSize added in v2.41.0

func PrintResponseSize(l *logger.Logger, resp *http.Response, output []byte)

func ProcessAssertError added in v2.55.0

func ProcessAssertError(f *Factory, strictMode bool) func(error) error

func RenderBodyWithInput added in v2.57.0

func RenderBodyWithInput(body *mapbuilder.MapBuilder, input any, defaults ...BodyDefault) (json.RawMessage, error)

RenderBodyWithInput renders the body (including any templates) for a single request.

The input is the value returned by the iterator which drives the request (e.g. a path parameter). When it is a piped line ([]byte), it is made available to the template as input.value, otherwise input.value is null (e.g. when a plain value is given via a flag).

Each default is only set when the path does not exist in the rendered body, so values set by a template are not overwritten by the defaults.

func SetBodyValue added in v2.57.0

func SetBodyValue(body json.RawMessage, path string, value any) (json.RawMessage, error)

SetBodyValue sets a value in an already rendered body

func WithTemplateValue

func WithTemplateValue(factory *Factory) flags.GetOption

WithTemplateValue get the template value using the path resolver controlled by the configuration

func WithViewCompletion

func WithViewCompletion(flagName string, dataviewFunc func() (*dataview.DataView, error)) completion.Option

WithViewCompletion view completion

Types

type BodyDefault added in v2.57.0

type BodyDefault struct {
	Path  string
	Value any
}

BodyDefault is a value which is set in the body only if the path does not already exist

type Browser

type Browser interface {
	Browse(string) error
}

func NewBrowser

func NewBrowser(launcher string, stdout, stderr io.Writer) Browser

type Factory

type Factory struct {
	IOStreams      *iostreams.IOStreams
	Browser        Browser
	Client         func() (*c8y.Client, error)
	Config         func() (*config.Config, error)
	Logger         func() (*logger.Logger, error)
	ActivityLogger func() (*activitylogger.ActivityLogger, error)
	Console        func() (*console.Console, error)
	DataView       func() (*dataview.DataView, error)

	BuildVersion string
	BuildBranch  string

	// Extension
	ExtensionManager func() extensions.ExtensionManager

	// Executable is the path to the currently invoked binary
	Executable string

	// Command
	Command *cobra.Command
}

func (*Factory) CheckPostCommandError

func (f *Factory) CheckPostCommandError(err error) error

func (*Factory) CreateModeEnabled

func (f *Factory) CreateModeEnabled(cmd *cobra.Command) error

CreateModeEnabled create mode is enabled

func (*Factory) DeleteModeEnabled

func (f *Factory) DeleteModeEnabled(cmd *cobra.Command) error

ValidateDeleteMode delete mode is enabled

func (*Factory) ExecuteOutputTemplate added in v2.41.0

func (f *Factory) ExecuteOutputTemplate(output []byte, params OutputContext, commonOptions *config.CommonCommandOptions) ([]byte, error)

func (*Factory) GetRequestHandler

func (f *Factory) GetRequestHandler() (*request.RequestHandler, error)

func (*Factory) GetTenant added in v2.30.0

func (f *Factory) GetTenant() string

func (*Factory) GetViewProperties

func (f *Factory) GetViewProperties(cfg *config.Config, cmd *cobra.Command, output []byte) ([]string, error)

GetViewProperties Look up the view properties to display

func (*Factory) GuessDataProperty added in v2.41.0

func (f *Factory) GuessDataProperty(output gjson.Result) string

func (*Factory) ResolveTemplates added in v2.30.0

func (f *Factory) ResolveTemplates(pattern string, withFullPath bool) ([]string, error)

func (*Factory) RunSequentiallyWithGenericWorkers added in v2.41.0

func (f *Factory) RunSequentiallyWithGenericWorkers(cmd *cobra.Command, iter iterator.Iterator, runFunc worker.Runner, inputIterators *flags.RequestInputIterators) error

func (*Factory) RunWithGenericWorkers added in v2.41.0

func (f *Factory) RunWithGenericWorkers(cmd *cobra.Command, inputIterators *flags.RequestInputIterators, iter iterator.Iterator, runFunc worker.Runner, checkError func(error) error) error

func (*Factory) RunWithWorkers

func (f *Factory) RunWithWorkers(client *c8y.Client, cmd *cobra.Command, req *c8y.RequestOptions, inputIterators *flags.RequestInputIterators) error

func (*Factory) SetCommand added in v2.41.0

func (f *Factory) SetCommand(cmd *cobra.Command) *Factory

Set reference to the cobra command

func (*Factory) UpdateModeEnabled

func (f *Factory) UpdateModeEnabled(cmd *cobra.Command) error

ValidateUpdateMode update mode is enabled

func (*Factory) WithExitCodeError added in v2.55.0

func (f *Factory) WithExitCodeError(exitCode cmderrors.ExitCode) func(error) error

func (*Factory) WithTemplateCompletion added in v2.32.0

func (f *Factory) WithTemplateCompletion(flagName string) completion.Option

func (*Factory) WithTemplateFlag

func (f *Factory) WithTemplateFlag(cmd *cobra.Command) flags.Option

WithTemplateFlag add template flag with completion

func (*Factory) WriteOutput added in v2.41.0

func (f *Factory) WriteOutput(output []byte, params OutputContext, commonOptions *config.CommonCommandOptions) error

func (*Factory) WriteOutputWithRows added in v2.41.0

func (f *Factory) WriteOutputWithRows(output []byte, params OutputContext, commonOptions *config.CommonCommandOptions) (int, error)

func (*Factory) WriteOutputWithoutPropertyGuess added in v2.41.0

func (f *Factory) WriteOutputWithoutPropertyGuess(output []byte, params OutputContext) error

type FileIteratorOptions added in v2.33.0

type FileIteratorOptions struct {
	Infinite        bool
	FirstNRows      int64
	Times           RandomRange
	TotalRows       int64
	RandomSkip      float32
	DelayBefore     time.Duration
	Delay           time.Duration
	RandomDelayFunc flags.DurationGenerator
	OutputFunc      func([]byte) error
	Format          func([]byte, int64) []byte
}

type OutputContext added in v2.41.0

type OutputContext struct {
	Input    any
	Response *http.Response
	Duration time.Duration
}

type RandomRange added in v2.38.0

type RandomRange struct {
	Min *int64
	Max *int64
}

type TemplatePathResolver

type TemplatePathResolver struct {
	Paths []string
}

func NewTemplateResolver added in v2.14.0

func NewTemplateResolver(factory *Factory) *TemplatePathResolver

func (*TemplatePathResolver) Resolve

func (t *TemplatePathResolver) Resolve(name string) (string, error)

type TestBrowser

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

func (*TestBrowser) Browse

func (b *TestBrowser) Browse(url string) error

func (*TestBrowser) BrowsedURL

func (b *TestBrowser) BrowsedURL() string

func (*TestBrowser) Verify

func (b *TestBrowser) Verify(t _testing, url string)

Jump to

Keyboard shortcuts

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