cmd

package
v2.16.22 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0, Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package cmd defines the cobra command structs and an execution method for adding an improved CLI to KrakenD based api gateways

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRoot    Root
	RootCommand    Command
	RunCommand     Command
	CheckCommand   Command
	PluginCommand  Command
	VersionCommand Command
	AuditCommand   Command
)
View Source
var CustomValidationFunc = func(_ config.ServiceConfig) []error {
	return nil
}
View Source
var IsTTY = isatty.IsTerminal(os.Stderr.Fd())
View Source
var RunRouterFunc = func(cfg config.ServiceConfig) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = errors.New(r.(string))
		}
	}()

	gin.SetMode(gin.ReleaseMode)
	cfg.Debug = cfg.Debug || debug > 0
	if port != 0 {
		cfg.Port = port
	}

	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
	krakendgin.DefaultFactory(proxy.DefaultFactory(logging.NoOp), logging.NoOp).NewWithContext(ctx).Run(cfg)
	cancel()
	return nil
}
View Source
var SchemaURL = "https://www.krakend.io/schema/v%s/krakend.json"

Functions

func Execute

func Execute(configParser config.Parser, f Executor)

Execute sets up the cmd package with the received configuration parser and executor and delegates the CLI execution to the cobra lib

func ExecuteRoot

func ExecuteRoot(configParser config.Parser, f Executor, root Root)

func GetConfigFlag

func GetConfigFlag() string

func GetConfigParser

func GetConfigParser() config.Parser

func GetDebugFlag

func GetDebugFlag() bool

Types

type Command

type Command struct {
	Cmd   *cobra.Command
	Flags []FlagBuilder

	Constraints []ConstraintBuilder
	// contains filtered or unexported fields
}

func NewCheckCmd

func NewCheckCmd(rawSchema string) Command

func NewCommand

func NewCommand(command *cobra.Command, flags ...FlagBuilder) Command

func (*Command) AddConstraint

func (c *Command) AddConstraint(r ConstraintBuilder)

func (*Command) AddFlag

func (c *Command) AddFlag(f FlagBuilder)

func (*Command) AddSubCommand

func (c *Command) AddSubCommand(cmd *cobra.Command)

func (*Command) BuildFlags

func (c *Command) BuildFlags()

type ConstraintBuilder

type ConstraintBuilder func(*cobra.Command)

func MutuallyExclusive

func MutuallyExclusive(flags ...string) ConstraintBuilder

func OneRequired

func OneRequired(flags ...string) ConstraintBuilder

func RequiredTogether

func RequiredTogether(flags ...string) ConstraintBuilder

type Executor

type Executor func(config.ServiceConfig)

Executor defines the function that requires a service description

type FlagBuilder

type FlagBuilder func(*cobra.Command)

func BoolFlagBuilder

func BoolFlagBuilder(dst *bool, long, short string, defaultValue bool, help string) FlagBuilder

func CountFlagBuilder

func CountFlagBuilder(dst *int, long, short, help string) FlagBuilder

func DurationFlagBuilder

func DurationFlagBuilder(dst *time.Duration, long, short string, defaultValue time.Duration, help string) FlagBuilder

func Float64FlagBuilder

func Float64FlagBuilder(dst *float64, long, short string, defaultValue float64, help string) FlagBuilder

func IntFlagBuilder

func IntFlagBuilder(dst *int, long, short string, defaultValue int, help string) FlagBuilder

func StringFlagBuilder

func StringFlagBuilder(dst *string, long, short, defaultValue, help string) FlagBuilder

type LastSourcer

type LastSourcer interface {
	LastSource() ([]byte, error)
}

type Root

type Root struct {
	Command
	SubCommands []Command
	// contains filtered or unexported fields
}

func NewRoot

func NewRoot(root Command, subCommands ...Command) Root

func (*Root) Build

func (r *Root) Build()

func (Root) Execute

func (r Root) Execute(configParser config.Parser, f Executor)

type SchemaHttpLoader

type SchemaHttpLoader http.Client

func (*SchemaHttpLoader) Load

func (l *SchemaHttpLoader) Load(url string) (interface{}, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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