Documentation
¶
Overview ¶
Copyright 2025 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 2025 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 2025 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 2025 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 2025 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
- Variables
- func ApplyConfigPatch(applyConfig interface{}) client.Patch
- func CAPIMachineSetStatusEqual(a, b clusterv1.MachineSetStatus) map[string]any
- func ContainsString(slice []string, s string) bool
- func DeepCopyMapStringString(original map[string]string) map[string]string
- func EnsureFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizer string) (bool, error)
- func FilterNamespace(namespace string) predicate.Predicate
- func GenerateInfraMachineTemplateNameWithSpecHash(name string, spec interface{}) (string, error)
- func GetCondition(obj client.Object, conditionType string) (*metav1.Condition, error)
- func GetConditionStatus(obj client.Object, conditionType string) (corev1.ConditionStatus, error)
- func GetInfra(ctx context.Context, cl client.Reader) (*configv1.Infrastructure, error)
- func GetMAPIMachineSetCondition(conditions []machinev1beta1.Condition, conditionType string) *machinev1beta1.Condition
- func GetPlatform(ctx context.Context, infra *configv1.Infrastructure) (configv1.PlatformType, error)
- func GetReferencedObject(ctx context.Context, c client.Reader, scheme *runtime.Scheme, ...) (client.Object, error)
- func GetReleaseVersion() string
- func GetResourceVersion(obj client.Object) string
- func IsNilObject(obj client.Object) bool
- func IsPatchRequired(origObj client.Object, patch client.Patch) (bool, error)
- func MAPIMachineSetStatusEqual(a, b machinev1beta1.MachineSetStatus) map[string]any
- func MergeMaps(m1, m2 map[string]string) map[string]string
- func ObjectMetaEqual(a, b metav1.ObjectMeta) map[string]any
- func ReadImagesFile(imagesFile string) (map[string]string, error)
- func ReadProvidersFile(providersFile string) (map[string]bool, error)
- func RemoveAnnotation(obj client.Object, key string)
- func RemoveFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizer string) (bool, error)
- func ResolveCAPIMachineSetFromInfraMachineTemplate(namespace string) func(context.Context, client.Object) []reconcile.Request
- func RewriteNamespace(namespace string) func(context.Context, client.Object) []reconcile.Request
- func SetLastTransitionTime(condType machinev1beta1.ConditionType, conditions []machinev1beta1.Condition, ...)
- func SetMAPIMachineSetCondition(conditions []machinev1beta1.Condition, condition *machinev1beta1.Condition) []machinev1beta1.Condition
Constants ¶
const MapiDeleteMachineAnnotation = "machine.openshift.io/delete-machine"
MapiDeleteMachineAnnotation is the delete-machine annotation used in Machine API. It has an equivalent annotation in Cluster API to convert to.
Variables ¶
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 ¶
ApplyConfigPatch is a helper function for using applyConfigPatch.
func CAPIMachineSetStatusEqual ¶
func CAPIMachineSetStatusEqual(a, b clusterv1.MachineSetStatus) map[string]any
CAPIMachineSetStatusEqual compares variables a and b, and returns a list of differences, or nil if there are none, for the fields we care about when synchronising MAPI and CAPI Machines.
func ContainsString ¶
ContainsString checks if a given slice of strings contains the provided string.
func DeepCopyMapStringString ¶
DeepCopyMapStringString creates a deep copy of a map[string]string.
func EnsureFinalizer ¶
func EnsureFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizer string) (bool, error)
EnsureFinalizer ensures that the specified finalizer is added to the given object using a Patch operation.
func FilterNamespace ¶
FilterNamespace filters a client.Object request, ensuring they are in the namespace provided.
func GenerateInfraMachineTemplateNameWithSpecHash ¶
GenerateInfraMachineTemplateNameWithSpecHash generates hash infra machine spec and combines it with infra machine name. Resulting name is "<name>-<hash>" where <hash> is a hex string of 8 characters. The hash function is FNV-1a 32-bit.
func GetCondition ¶
GetCondition retrieves a specific condition from a client.Object.
func GetConditionStatus ¶
GetConditionStatus returns the status for the condition.
func GetMAPIMachineSetCondition ¶
func GetMAPIMachineSetCondition(conditions []machinev1beta1.Condition, conditionType string) *machinev1beta1.Condition
GetMAPIMachineSetCondition retrieves a specific condition from a list of MAPI MachineSet conditions.
func GetPlatform ¶
func GetPlatform(ctx context.Context, infra *configv1.Infrastructure) (configv1.PlatformType, error)
GetPlatform returns the platform type from the infrastructure resource.
func GetReferencedObject ¶
func GetReferencedObject(ctx context.Context, c client.Reader, scheme *runtime.Scheme, ref corev1.ObjectReference) (client.Object, error)
GetReferencedObject retrieves a Kubernetes object dynamically based on an ObjectReference.
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 GetResourceVersion ¶
GetResourceVersion returns the object ResourceVersion or the zero value for it.
func IsNilObject ¶
IsNilObject checks whether a client.Object is nil or not.
func IsPatchRequired ¶
IsPatchRequired returns true if the calculated patch data is not an empty JSON object.
func MAPIMachineSetStatusEqual ¶
func MAPIMachineSetStatusEqual(a, b machinev1beta1.MachineSetStatus) map[string]any
MAPIMachineSetStatusEqual compares variables a and b, and returns a list of differences, or nil if there are none, for the fields we care about when synchronising MAPI and CAPI Machines.
func ObjectMetaEqual ¶
func ObjectMetaEqual(a, b metav1.ObjectMeta) map[string]any
ObjectMetaEqual compares variables a and b, and returns a list of differences, or nil if there are none, for the fields we care about when synchronising MAPI and CAPI Machines.
func ReadImagesFile ¶
ReadImagesFile reads the images file and returns the map of container images.
func ReadProvidersFile ¶
ReadProvidersFile reads the providers file and returns the map of supported providers.
func RemoveAnnotation ¶
RemoveAnnotation deletes a specific annotation from a client.Object.
func RemoveFinalizer ¶
func RemoveFinalizer(ctx context.Context, c client.Client, obj client.Object, finalizer string) (bool, error)
RemoveFinalizer ensures that the specified finalizer is removed from the given object using a Patch operation.
func ResolveCAPIMachineSetFromInfraMachineTemplate ¶
func ResolveCAPIMachineSetFromInfraMachineTemplate(namespace string) func(context.Context, client.Object) []reconcile.Request
ResolveCAPIMachineSetFromInfraMachineTemplate resolves a synchronized MachineSet from an InfrastructureMachineTemplate. It takes a client.Object (expecting a CAPI InfrastructureMachineTemplate) and checks if it has the machine.openshift.io/cluster-api-machineset label. If present, it returns a reconcile.Request for the corresponding MachineSet in the MAPI namespace to trigger reconciliation of the mirror MAPI MachineSet.
func RewriteNamespace ¶
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.
func SetLastTransitionTime ¶
func SetLastTransitionTime(condType machinev1beta1.ConditionType, conditions []machinev1beta1.Condition, conditionAc *machinev1applyconfigs.ConditionApplyConfiguration)
SetLastTransitionTime determines if the last transition time should be set or updated for a given condition type.
func SetMAPIMachineSetCondition ¶
func SetMAPIMachineSetCondition(conditions []machinev1beta1.Condition, condition *machinev1beta1.Condition) []machinev1beta1.Condition
SetMAPIMachineSetCondition sets a condition in a list of MAPI MachineSet conditions. If the condition already exists and state (Status, Reason, Message) has changed: - if the lasttransitiontime is not set, it sets it to the current time - if the lasttransitiontime is set, it updates it with the one of the newly provided condition lasttransitiontime. If the condition state has not changed, it preserves the existing LastTransitionTime. If the condition does not exist, it adds it. This function behaves similarly to conditions.Set() for CAPI conditions.
Types ¶
This section is empty.