util

package
v0.0.0-...-886bed7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2024 Red Hat, Inc.

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.

Copyright 2024 Red Hat, Inc.

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.

Copyright 2024 Red Hat, Inc.

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.

Copyright 2024 Red Hat, Inc.

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.

Copyright 2024 Red Hat, Inc.

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.

Copyright 2024 Red Hat, Inc.

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.

Copyright 2024 Red Hat, Inc.

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

View Source
var (
	// LeaseDuration is the default duration for the leader election lease.
	LeaseDuration = metav1.Duration{Duration: 137 * time.Second}
	// RenewDeadline is the default duration for the leader renewal.
	RenewDeadline = metav1.Duration{Duration: 107 * time.Second}
	// RetryPeriod is the default duration for the leader election retrial.
	RetryPeriod = metav1.Duration{Duration: 26 * time.Second}
)

The default durations for the leader election operations.

Functions

func ApplyConfigPatch

func ApplyConfigPatch(applyConfig interface{}) client.Patch

ApplyConfigPatch is a helper function for using applyConfigPatch.

func ContainsString

func ContainsString(slice []string, s string) bool

ContainsString checks if a given slice of strings contains the provided string.

func FilterNamespace

func FilterNamespace(namespace string) predicate.Predicate

FilterNamespace filters a client.Object request, ensuring they are in the namespace provided.

func GetInfra

GetInfra returns the infrastructure resource.

func GetPlatform

func GetPlatform(ctx context.Context, infra *configv1.Infrastructure) (configv1.PlatformType, error)

GetPlatform returns the platform type from the infrastructure resource.

func GetReleaseVersion

func GetReleaseVersion() string

GetReleaseVersion is used to get the current release version from the env. This is used to identify which version of feature gates should be observed, and to know which version to set in the operator status.

func IsPatchRequired

func IsPatchRequired(origObj client.Object, patch client.Patch) (bool, error)

IsPatchRequired returns true if the calculated patch data is not an empty JSON object.

func MergeMaps

func MergeMaps(m1, m2 map[string]string) map[string]string

MergeMaps merges two maps, with values from the second map taking precedence.

func ReadImagesFile

func ReadImagesFile(imagesFile string) (map[string]string, error)

ReadImagesFile reads the images file and returns the map of container images.

func ReadProvidersFile

func ReadProvidersFile(providersFile string) (map[string]bool, error)

ReadProvidersFile reads the providers file and returns the map of supported providers.

func ResolveCAPIMachineSetFromObject

func ResolveCAPIMachineSetFromObject(namespace string) func(context.Context, client.Object) []reconcile.Request

ResolveCAPIMachineSetFromObject should probably be renamed. It: 1. takes a client.Object (expecting a CAPI InfrastructureMachineTemplate) and checks to see if it's owned by a CAPI MachineSet 2. If it is, returns a reconcile.Request for the MAPI namespace, so we reconcile the mirror MAPI MachineSet.

func RewriteNamespace

func RewriteNamespace(namespace string) func(context.Context, client.Object) []reconcile.Request

RewriteNamespace takes a client.Object and returns a reconcile.Request for it in the namespace provided.

It is intended for use with CAPI Machines and MachineSet requests, where we expect there to be a mirror object in the MAPI namespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

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