util

package
v1.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ErrIPv6OnlyUnsupported  = "IPv6 only network family not supported yet"
	ErrUnknownNetworkFamily = "Unknown IP family %q only IPv4,IPv6,IPv4+IPv6 are valid values"
)
View Source
const (
	CloudInitNamespace = "cloud-init-settings"
)

Variables

View Source
var (
	// CABundle is set globally once by the main() function
	// and is used to overwrite the default set of CA certificates
	// loaded from the host system/pod.
	CABundle *x509.CertPool
)

Functions

func CIDRToIPAndNetMask added in v1.60.0

func CIDRToIPAndNetMask(ipv4 string) (string, string, int, error)

func CreateMachineCloudInitSecret added in v1.60.0

func CreateMachineCloudInitSecret(ctx context.Context, userdata, machineName string, client ctrlruntimeclient.Client) error

func ExtractTokenAndAPIServer added in v1.60.0

func ExtractTokenAndAPIServer(ctx context.Context, userdata string, client ctrlruntimeclient.Client) (string, string, error)

func GenerateRandMAC added in v1.60.0

func GenerateRandMAC() (net.HardwareAddr, error)

GenerateRandMAC generates a random unicast and locally administered MAC address.

func IsLinkLocal added in v1.60.0

func IsLinkLocal(ipAddr string) bool

IsLinkLocal checks if given ip address is link local..

func RemoveFinalizerOnInstanceNotFound

func RemoveFinalizerOnInstanceNotFound(finalizer string,
	machine *v1alpha1.Machine,
	provider *cloudprovidertypes.ProviderData) (bool, error)

RemoveFinalizerOnInstanceNotFound checks whether a finalizer exists and removes it on demand.

func SetCABundleFile added in v1.60.0

func SetCABundleFile(filename string) error

SetCABundleFile reads a PEM-encoded file and replaces the current global CABundle with a new one. The file must contain at least one valid certificate.

Types

type HTTPClientConfig added in v1.60.0

type HTTPClientConfig struct {
	// LogPrefix is prepended to request/response logs
	LogPrefix string
	// Global timeout used by the client
	Timeout time.Duration
}

func (HTTPClientConfig) New added in v1.60.0

func (c HTTPClientConfig) New() http.Client

New return a custom HTTP client that allows for logging HTTP request and response information.

type IPFamily added in v1.60.0

type IPFamily string

IPFamily IPv4 | IPv6 | IPv4+IPv6.

const (
	IPFamilyUnspecified IPFamily = ""          // interpreted as IPv4
	IPFamilyIPv4        IPFamily = "IPv4"      // IPv4 only
	IPFamilyIPv6        IPFamily = "IPv6"      // IPv6 only
	IPFamilyIPv4IPv6    IPFamily = "IPv4+IPv6" // dualstack with IPv4 as primary
	IPFamilyIPv6IPv4    IPFamily = "IPv6+IPv4" // dualstack with IPv6 as primary
)

func (IPFamily) HasIPv4 added in v1.60.0

func (f IPFamily) HasIPv4() bool

func (IPFamily) HasIPv6 added in v1.60.0

func (f IPFamily) HasIPv6() bool

func (IPFamily) IsDualstack added in v1.60.0

func (f IPFamily) IsDualstack() bool

type LogRoundTripper added in v1.60.0

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

LogRoundTripper is used to log information about requests and responses that may be useful for debugging purposes. Note that setting log level >5 results in full dumps of requests and responses, including sensitive invormation (e.g. Authorization header).

func (*LogRoundTripper) RoundTrip added in v1.60.0

func (lrt *LogRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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