util

package
v0.0.0-...-3ed6084 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendMissingDefaultMCPManifests

func AppendMissingDefaultMCPManifests(currentMCPs []*mcfgv1.MachineConfigPool) []*mcfgv1.MachineConfigPool

AppendMissingDefaultMCPManifests When default MCPs are missing, it is desirable to still generate the relevant files based off of the standard MCP labels and node selectors.

Here we create the default `master` and `worker` MCP if they are missing with their respective base Labels and NodeSelector Labels, this allows any resource such as PAO to utilize the default during bootstrap rendering.

func Delete

func Delete(file string) error

Delete a file if it exists. Returns nil if 'file' does not exist.

func DeleteDeferredUpdateAnnotation

func DeleteDeferredUpdateAnnotation(anns map[string]string) map[string]string

func DeserializeObjectFromData

func DeserializeObjectFromData(data []byte, addToSchemeFn ...func(scheme2 *runtime.Scheme) error) (runtime.Object, error)

func GetLeaderElectionConfig

func GetLeaderElectionConfig(restcfg *rest.Config, enabled bool) configv1.LeaderElection

GetLeaderElectionConfig returns leader election configs defaults based on the cluster topology

func GetProviderName

func GetProviderName(providerID string) string

GetProviderName returns ProviderName part of 'providerID' in the format: <ProviderName>://<ProviderSpecificNodeID>

func IsDeferredUpdate

func IsDeferredUpdate(value DeferMode) bool

func IsImmediateUpdate

func IsImmediateUpdate(value DeferMode) bool

func IsNoMatchError

func IsNoMatchError(err error) bool

IsNoMatchError checks if error is for a non existent resource, there is a meaningful difference between a resource type not existing on the cluster as a whole versus an individual resource not being found.

Example: OLM can be an optional operator, when the OLM resources do not exist, the returned error is a discovery error of meta.NoResourceMatchError.

A bug is present in controller-runtime@v0.16.1 and older where the returned error type is a DiscoveryFailedError this was fixed in https://github.com/kubernetes-sigs/controller-runtime/pull/2472 and versions of controller-runtime@v0.16.2 going forward will return the meta.NoResourceMatchError error. Here we check if either one is true.

func KernelArgumentsEqual

func KernelArgumentsEqual(args1, args2 string, exclude ...string) bool

KernelArgumentsEqual compares kernel arguments 'args1' and 'args2' excluding parameters 'exclude'. Returns true when they're equal. Note the order of kernel arguments matters. For example, "hugepagesz=1G hugepages=1" vs. "hugepages=1 hugepagesz=1G".

func ListFiles

func ListFiles(dirPaths string) ([]string, error)

func ListFilesFromMultiplePaths

func ListFilesFromMultiplePaths(dirPaths []string) ([]string, error)

func MapOfStringsContains

func MapOfStringsContains(a, b map[string]string) bool

MapOfStringsContains returns true if map of strings a contains all entries of the map of strings b. Use MapOfStringsEqual for checking if two maps of strings are equal. For example MapOfStringsContains(map[string]string{"a": "a","b": "b"}, map[string]string{"a": "a"}) will return true, but MapOfStringsContains(map[string]string{"a": "a"}, map[string]string{"a": "a","b": "b"}) will return false.

func MapOfStringsCopy

func MapOfStringsCopy(a map[string]string) map[string]string

MapOfStringsCopy returns a copy of a map of strings 'a'.

func MapOfStringsEqual

func MapOfStringsEqual(a, b map[string]string) bool

MapOfStringsEqual returns true if maps of strings 'a' and 'b' are equal. reflect.DeepEqual is roughly 10x slower than this.

func ObjectInfo

func ObjectInfo(o interface{}) string

func ParseManifests

func ParseManifests(filename string, r io.Reader) ([]manifest, error)

ParseManifests parses a YAML or JSON document that may contain one or more kubernetes resources.

func PtrBoolEqual

func PtrBoolEqual(a, b *bool) bool

PtrBoolEqual returns true if the booleans pointed to by 'a' and 'b' are equal or both 'a' and 'b' are nil.

func SetDeferredUpdateAnnotation

func SetDeferredUpdateAnnotation(anns map[string]string, value DeferMode) map[string]string

func SetLogLevel

func SetLogLevel(targetLevel int) error

SetLogLevel was lifted with minor modifications from library-go. In their own words, it is a nasty hack and attempt to manipulate the global flags as klog does not expose a way to dynamically change the loglevel in runtime.

func SplitKernelArguments

func SplitKernelArguments(args string) []string

SplitKernelArguments splits kernel parameters into a slice of strings one parameter per string. Workaround for rhbz#1812605.

func SplitKernelArgumentsWithout

func SplitKernelArgumentsWithout(args string, exclude []string) []string

SplitKernelArgumentsWithout splits kernel parameters excluding any parameters in the 'exclude' slice into a slice of strings one parameter per string.

func StringSlicesAsSetsEqual

func StringSlicesAsSetsEqual(a, b []string) bool

StringSlicesAsSetsEqual returns true if slices of strings 'a' and 'b' with their items sorted equally with duplicate items removed are the same.

func StringSlicesEqual

func StringSlicesEqual(a, b []string) bool

StringSlicesEqual returns true if slices of strings 'a' and 'b' are the same.

func Symlink(target, linkName string) error

Create a symbolic link. Returns nil if the link already exists.

Types

type DeferMode

type DeferMode string

DeferMode controls the deferred feature. Default is "never", which is the value assumed when no annotation is set, and which cause all objects to be processed immediately (never deferred)

const (
	// DeferNever means deferred mode is disabled; treat as immediate update, like the annotation is not present.
	DeferNever DeferMode = "never"
	// DeferAlways means the changes carried will be deferred until the next node restart: both for the first application and for profile changes.
	DeferAlways DeferMode = "always"
	// DeferUpdate means in-place updates/changes to only the contents of the currently used profile. Switches to different TuneD profiles are processed immediately without the need to reboot.
	DeferUpdate DeferMode = "update"
)

func GetDeferredUpdateAnnotation

func GetDeferredUpdateAnnotation(anns map[string]string) DeferMode

func (DeferMode) String

func (dm DeferMode) String() string

Jump to

Keyboard shortcuts

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