util

package
v0.0.0-...-bb71e59 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 30 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 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 GenerateUniqueTempPath

func GenerateUniqueTempPath(path string) (string, error)

GenerateUniqueTempPath returns a filepath from given path with extra suffix which doesn't exist.

func GetHostIP

func GetHostIP(nodeIP string) (string, error)

func GetHostIPv6

func GetHostIPv6(ipHint string) (string, error)

func GetSNIsFromCert

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

GetSNIsFromCert - get list of unique SNIs from certificate

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 IsCertAllowed

func IsCertAllowed(advertiseAddress string, clusterNetwork []string, serviceNetwork []string, certPath string, extraNames []string) (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 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 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