virtualhostname

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hostname provides a parse method to extract the components of a virtual hostname. Currently only intended for use by the SSH proxy feature, hostnames can reference machines, units, and pods.

Index

Constants

View Source
const (
	// ErrNoMatch indicates that the hostname could not be parsed.
	ErrNoMatch = errors.ConstError("could not parse hostname")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HostnameTarget

type HostnameTarget int

HostnameTarget defines what kind of infrastructure the user is targeting.

const (
	// MachineTarget defines a machine as the target.
	MachineTarget HostnameTarget = iota

	// UnitTarget defines a unit (K8s or machine)
	// as the target.
	UnitTarget

	// ContainerTarget defines a container within a
	// unit as the target.
	ContainerTarget
)

type Info

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

Info returns a breakdown of a virtual hostname into its constituent parts. The target field indicates what kind of hostname was parsed which will indicate that some fields are empty.

func Parse

func Parse(hostname string) (Info, error)

Parse parses a virtual Juju hostname that references entities like machines, units and containers.

func (Info) Container

func (i Info) Container() (string, bool)

Container returns the container name and a bool to indicate if a container is valid for the target type.

func (Info) Machine

func (i Info) Machine() (int, bool)

Machine returns the machine number.

func (Info) ModelUUID

func (i Info) ModelUUID() string

ModelUUID returns the model UUID.

func (Info) Target

func (i Info) Target() HostnameTarget

HostnameTarget returns an enum value indicating the target of the hostname e.g. container, machine, etc.

func (Info) Unit

func (i Info) Unit() (string, bool)

Unit returns the unit name.

Jump to

Keyboard shortcuts

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