util

package
v0.0.0-...-bcc46de Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 22 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 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 HasDeferredUpdateAnnotation

func HasDeferredUpdateAnnotation(anns map[string]string) 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, tuned *tunedv1.Tuned) map[string]string

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.

func ToggleDeferredUpdateAnnotation

func ToggleDeferredUpdateAnnotation(anns map[string]string, toggle bool) map[string]string

Types

This section is empty.

Jump to

Keyboard shortcuts

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