util

package
v0.0.0-...-cf6c19e Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Copyright © 2021 MicroShift Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToNoProxyEnv

func AddToNoProxyEnv(additionalEntries ...string) error

func ContainIPANetwork

func ContainIPANetwork(ip tcpnet.IP, networks []string) bool

ContainIPANetwork - will check if given IP address contained within list of networks

func ConvertYAMLOrJSONToUnstructured

func ConvertYAMLOrJSONToUnstructured(reader io.Reader) (*unstructured.Unstructured, error)

ConvertYAMLOrJSONToUnstructured converts a YAML or JSON stream to an unstructured object. It returns an error if the stream cannot be decoded or the object cannot be converted to unstructured. The function is used to parse Kubernetes resources from files that are unknown at compile time.

func CreateTempDir

func CreateTempDir(path string) (string, error)

CreateTempDir creates a temporary directory from given path and returns the pathname of the new directory.

func CreateTempFile

func CreateTempFile(path string) (*os.File, error)

CreateTempFile creates a temporary file from given path and returns resulting file

func Default

func Default(s string, defaultS string) string

func EnsureKeyPair

func EnsureKeyPair(pubKeyPath, privKeyPath string) error

func FindDefaultRouteIface

func FindDefaultRouteIface(ipFamily int) (iface *tcpnet.Interface, err error)

Find the Default route Interface based on ipv4 or ipv6 routes.

func FindDefaultRouteMTU

func FindDefaultRouteMTU(ipFamily int) (mtu int, err error)

func FindDefaultRouteMinMTU

func FindDefaultRouteMinMTU() (mtu int, err error)

func GenKeys

func GenKeys(pubPath, keyPath string) error

GenKeys generates and save rsa keys

func GetHostIP

func GetHostIP(nodeIP string) (string, error)

func GetHostIPv6

func GetHostIPv6(ipHint string) (string, error)

func GetOSVersion

func GetOSVersion() (string, error)

func GetSNIsFromCert

func GetSNIsFromCert(certPath string, extraNames []string) ([]string, error)

GetSNIsFromCert - get list of unique SNIs from certificate

func HasDefaultRoute

func HasDefaultRoute() (bool, error)

HasDefaultRoute returns whether the host has a default route for IPv4 or IPv6.

func HealthCheckServer

func HealthCheckServer(ctx context.Context, path, port string) (start func() error, shutdown func() error)

StartHealthCheck starts a server for a simple health check endpoint Returns a start and shutdown handler.

Note: typically servers return a non-nil error, here we return nil if the server was naturally shutdown.

func IsBootc

func IsBootc() bool

func IsCertAllowed

func IsCertAllowed(advertiseAddress string, clusterNetwork []string, serviceNetwork []string, certPath string, extraNames []string) (bool, error)

func IsOSTree

func IsOSTree() (bool, error)

func IsWildcardDNS

func IsWildcardDNS(val string) bool

IsWildcardDNS - check if DNS is a wildcard

func KubeConfigWithClientCerts

func KubeConfigWithClientCerts(
	path string,
	clusterURL string,
	clusterTrustBundle []byte,
	clientCertPEM []byte,
	clientKeyPEM []byte,
) error

KubeConfigWithClientCerts creates a kubeconfig authenticating with client cert/key at a location provided by `path`

func MakeDir

func MakeDir(path string) error

func Must

func Must(err error)

func PathExists

func PathExists(path string) (bool, error)

func PathExistsAndIsNotEmpty

func PathExistsAndIsNotEmpty(path string, ignores ...string) (bool, error)

func PathExistsFS

func PathExistsFS(fsys fs.StatFS, path string) (bool, error)

func PublicKeyToPem

func PublicKeyToPem(key *rsa.PublicKey) ([]byte, error)

PublicKeyToPem converts an rsa.PublicKey object to pem string

func RetryGet

func RetryGet(ctx context.Context, url, additionalCAPath string) int

func RetryInsecureGet

func RetryInsecureGet(ctx context.Context, url string) int

func RetryTCPConnection

func RetryTCPConnection(ctx context.Context, host string, port string) bool

func VerifyAllowedSNI

func VerifyAllowedSNI(advertiseAddress string, clusterNetwork []string, serviceNetwork []string, sni string) bool

verifyAllowedSNI checks if sni is allowed return bool: true, false

Types

type AllErrGroup

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

AllErrGroup is a helper to wait for all goroutines and get all errors that occurred. It's based on sync.WaitGroup (which doesn't capture any errors) and errgroup.Group (which only captures the first error).

func (*AllErrGroup) Go

func (g *AllErrGroup) Go(f func() error)

func (*AllErrGroup) Wait

func (g *AllErrGroup) Wait() error

type LogFilePath

type LogFilePath string

func (LogFilePath) Remove

func (l LogFilePath) Remove() error

Remove Will remove the existing file if it exists.

func (LogFilePath) Write

func (l LogFilePath) Write(data []byte) error

Write writes data to the desired filename, calling multiple times will overwrite the file with the most recent data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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