dependencies

package
v0.0.0-...-29a0f12 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: MIT, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

XTablesCmds is the set of all the xtables-related commands currently supported.

Functions

This section is empty.

Types

type Dependencies

type Dependencies interface {
	// RunOrFail runs a command and panics, if it fails
	RunOrFail(cmd string, args ...string)
	// Run runs a command
	Run(cmd string, args ...string) error
	// RunQuietlyAndIgnore runs a command quietly and ignores errors
	RunQuietlyAndIgnore(cmd string, args ...string)
}

Dependencies is used as abstraction for the commands used from the operating system

type RealDependencies

type RealDependencies struct {
	NetworkNamespace string
	CNIMode          bool
}

RealDependencies implementation of interface Dependencies, which is used in production

func (*RealDependencies) Run

func (r *RealDependencies) Run(cmd string, args ...string) (err error)

Run runs a command

func (*RealDependencies) RunOrFail

func (r *RealDependencies) RunOrFail(cmd string, args ...string)

RunOrFail runs a command and exits with an error message, if it fails

func (*RealDependencies) RunQuietlyAndIgnore

func (r *RealDependencies) RunQuietlyAndIgnore(cmd string, args ...string)

RunQuietlyAndIgnore runs a command quietly and ignores errors

type StdoutStubDependencies

type StdoutStubDependencies struct{}

StdoutStubDependencies implementation of interface Dependencies, which is used for testing

func (*StdoutStubDependencies) Run

func (s *StdoutStubDependencies) Run(cmd string, args ...string) error

Run runs a command

func (*StdoutStubDependencies) RunOrFail

func (s *StdoutStubDependencies) RunOrFail(cmd string, args ...string)

RunOrFail runs a command and panics, if it fails

func (*StdoutStubDependencies) RunQuietlyAndIgnore

func (s *StdoutStubDependencies) RunQuietlyAndIgnore(cmd string, args ...string)

RunQuietlyAndIgnore runs a command quietly and ignores errors

type XTablesExittype

type XTablesExittype int

XTablesExittype is the exit type of xtables commands.

const (
	// XTablesOtherProblem indicates a problem of other type in xtables
	XTablesOtherProblem XTablesExittype = iota + 1
	// XTablesParameterProblem indicates a parameter problem in xtables
	XTablesParameterProblem
	// XTablesVersionProblem indicates a version problem in xtables
	XTablesVersionProblem
	// XTablesResourceProblem indicates a resource problem in xtables
	XTablesResourceProblem
)

Learn from `xtables_exittype` of iptables. `XTF_ONLY_ONCE`, `XTF_NO_INVERT`, `XTF_BAD_VALUE`, `XTF_ONE_ACTION` will eventually turned out to be a parameter problem with explicit error message. Thus, we do not need to support them here.

Jump to

Keyboard shortcuts

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