common

package
v0.0.0-...-adfa13f Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReleaseName       = "consul"
	DefaultReleaseNamespace  = "consul"
	ConsulDemoAppReleaseName = "consul-demo"
	TopLevelChartDirName     = "consul"
	ReleaseTypeConsul        = "Consul"
	ReleaseTypeConsulDemo    = "Consul demo application"

	// CLILabelKey and CLILabelValue are added to each secret on creation so the CLI knows
	// which key to delete on an uninstall.
	CLILabelKey   = "managed-by"
	CLILabelValue = "consul-k8s"
)

Variables

This section is empty.

Functions

func Abort

func Abort(raw string) bool

Abort returns true if the raw input string is not equal to "y" or "yes".

func CloseWithError

func CloseWithError(c *BaseCommand)

CloseWithError terminates a command and cleans up its resources. If termination fails, the error is logged and the process exits with an exit code of 1.

func Diff

func Diff(a, b map[string]interface{}) (string, error)

Diff returns a string representation of the difference between two maps as YAML. The returned string is sorted alphabetically by key. If the maps are identical, the returned string is empty.

func IsDanglingResourceError

func IsDanglingResourceError(err error) bool

IsDanglingResourceError returns true if the error passed in is of type DanglingResourceError.

func IsValidLabel

func IsValidLabel(label string) bool

IsValidLabel checks if a given label conforms to RFC 1123 https://datatracker.ietf.org/doc/html/rfc1123. This standard requires that the label begins and ends with an alphanumeric character, does not exceed 63 characters, and contains only alphanumeric characters and '-'.

func MergeMaps

func MergeMaps(a, b map[string]interface{}) map[string]interface{}

MergeMaps merges two maps giving b precedent. @source: https://github.com/helm/helm/blob/main/pkg/cli/values/options.go

func Usage

func Usage(txt string, flags *flag.FlagSet) string

Usage returns a usage string nicely formatted.

Types

type BaseCommand

type BaseCommand struct {
	// Ctx is the base context for the command. It is up to commands to
	// utilize this context so that cancellation works in a timely manner.
	Ctx context.Context

	// Log is the logger to use.
	Log hclog.Logger

	// UI is used to write to the CLI.
	UI terminal.UI
}

BaseCommand is embedded in all commands to provide common logic and data.

func (*BaseCommand) Close

func (c *BaseCommand) Close() error

Close cleans up any resources that the command created. This should be defered by any CLI command that embeds baseCommand in the Run command.

type DanglingResourceError

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

DanglingResourceError should be used when a request was made to remove a resource and the resource still remains after enough time has elapsed that it should have been removed by Kubernetes.

func NewDanglingResourceError

func NewDanglingResourceError(message string) *DanglingResourceError

NewDanglingResourceError returns a new instance of DanglingResourceError with the given message.

func (*DanglingResourceError) Error

func (d *DanglingResourceError) Error() string

Error returns a string representation of the dangling resource error.

type PortForward

type PortForward struct {
	// Namespace is the Kubernetes Namespace where the Pod can be found.
	Namespace string
	// PodName is the name of the Pod to port forward.
	PodName string
	// RemotePort is the port on the Pod to forward to.
	RemotePort int

	// KubeClient is the Kubernetes Client to use for port forwarding.
	KubeClient kubernetes.Interface
	// RestConfig is the REST client configuration to use for port forwarding.
	RestConfig *rest.Config
	// contains filtered or unexported fields
}

PortForward represents a Kubernetes Pod port forwarding session which can be run as a background process.

func (*PortForward) Close

func (pf *PortForward) Close()

Close closes the port forward connection.

func (*PortForward) GetLocalPort

func (pf *PortForward) GetLocalPort() int

func (*PortForward) Open

func (pf *PortForward) Open(ctx context.Context) (string, error)

Open opens a port forward session to a Kubernetes Pod.

type PortForwarder

type PortForwarder interface {
	Open(context.Context) (string, error)
	Close()
	GetLocalPort() int
}

PortForwarder enables a user to open and close a connection to a remote server.

type Usager

type Usager struct {
	Usage string
	Flags *flag.FlagSet
}

func (*Usager) String

func (u *Usager) String() string

Directories

Path Synopsis
Package flag is a thin layer over the stdlib flag package that provides some minimal features such as aliasing, autocompletion handling, improved defaults, etc.
Package flag is a thin layer over the stdlib flag package that provides some minimal features such as aliasing, autocompletion handling, improved defaults, etc.
Package terminal is a modified version of https://github.com/hashicorp/waypoint-plugin-sdk/tree/74d9328929293551499078da388b8d057f3b2341/terminal.
Package terminal is a modified version of https://github.com/hashicorp/waypoint-plugin-sdk/tree/74d9328929293551499078da388b8d057f3b2341/terminal.

Jump to

Keyboard shortcuts

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