From ea042aef9212f7dbead459f04eca80ed96191ce0 Mon Sep 17 00:00:00 2001 From: Theo Barber-Bany Date: Mon, 21 Oct 2024 12:49:15 +0100 Subject: [PATCH 1/4] Vendor MAO Conditions utilities --- go.mod | 7 +- go.sum | 14 +- .../go-openapi/jsonpointer/pointer.go | 2 +- .../go-openapi/swag/initialism_index.go | 2 +- .../go-openapi/swag/string_bytes.go | 14 -- vendor/github.com/go-openapi/swag/yaml.go | 3 +- .../openshift/machine-api-operator/LICENSE | 201 ++++++++++++++++++ .../pkg/util/conditions/conditions.go | 35 +++ .../pkg/util/conditions/gettersetter.go | 181 ++++++++++++++++ .../pkg/util/conditions/matcher.go | 102 +++++++++ .../pkg/util/conditions/wrap.go | 41 ++++ vendor/modules.txt | 15 +- 12 files changed, 585 insertions(+), 32 deletions(-) create mode 100644 vendor/github.com/openshift/machine-api-operator/LICENSE create mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go create mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go create mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go create mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go diff --git a/go.mod b/go.mod index 045f503c1..0f78315a1 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20241024095219-086923b9d3fd github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20241008085214-8d85b2cb2c1d github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b + github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace gopkg.in/yaml.v2 v2.4.0 @@ -106,10 +107,10 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/errors v0.22.0 // indirect - github.com/go-openapi/jsonpointer v0.20.2 // indirect - github.com/go-openapi/jsonreference v0.20.4 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/strfmt v0.23.0 // indirect - github.com/go-openapi/swag v0.22.8 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.19.0 // indirect diff --git a/go.sum b/go.sum index 52b78c299..4ac2bd44d 100644 --- a/go.sum +++ b/go.sum @@ -166,14 +166,14 @@ github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/errors v0.22.0 h1:c4xY/OLxUBSTiepAg3j/MHuAv5mJhnf53LLMWFB+u/w= github.com/go-openapi/errors v0.22.0/go.mod h1:J3DmZScxCDufmIMsdOuDHxJbdOGC0xtUynjIx092vXE= -github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= -github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= -github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= -github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= github.com/go-openapi/strfmt v0.23.0 h1:nlUS6BCqcnAk0pyhi9Y+kdDVZdZMHfEKQiS4HaMgO/c= github.com/go-openapi/strfmt v0.23.0/go.mod h1:NrtIpfKtWIygRkKVsxh7XQMDQW5HKQl6S5ik2elW+K4= -github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= -github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -429,6 +429,8 @@ github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-202410080 github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20241008085214-8d85b2cb2c1d/go.mod h1:u+45mmWUg2ld7nsPDXzntjMsxannCV0CVmcUj9tIDvU= github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b h1:y2DduJug7UZqTu0QTkRPAu73nskuUbFA66fmgxVf/fI= github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b/go.mod h1:f8QcnrooSwGa96xI4UaKbKGJZskhTCGeimXKyc4t/ZU= +github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac h1:qlOVMOPOJ/0YRDKUk5FUZspJSILUo/7P3V5Kd8vP4d8= +github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac/go.mod h1:gXjplVdC80eclLdaZbWsDbbewhHmE99CVk4o61TiTbM= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= diff --git a/vendor/github.com/go-openapi/jsonpointer/pointer.go b/vendor/github.com/go-openapi/jsonpointer/pointer.go index d975773d4..d970c7cf4 100644 --- a/vendor/github.com/go-openapi/jsonpointer/pointer.go +++ b/vendor/github.com/go-openapi/jsonpointer/pointer.go @@ -264,7 +264,7 @@ func (p *Pointer) set(node, data any, nameProvider *swag.NameProvider) error { knd := reflect.ValueOf(node).Kind() if knd != reflect.Ptr && knd != reflect.Struct && knd != reflect.Map && knd != reflect.Slice && knd != reflect.Array { - return fmt.Errorf("only structs, pointers, maps and slices are supported for setting values") + return errors.New("only structs, pointers, maps and slices are supported for setting values") } if nameProvider == nil { diff --git a/vendor/github.com/go-openapi/swag/initialism_index.go b/vendor/github.com/go-openapi/swag/initialism_index.go index 2b2e46310..20a359bb6 100644 --- a/vendor/github.com/go-openapi/swag/initialism_index.go +++ b/vendor/github.com/go-openapi/swag/initialism_index.go @@ -176,7 +176,7 @@ func (m *indexOfInitialisms) add(key string) *indexOfInitialisms { func (m *indexOfInitialisms) sorted() (result []string) { m.sortMutex.Lock() defer m.sortMutex.Unlock() - m.index.Range(func(key, value interface{}) bool { + m.index.Range(func(key, _ interface{}) bool { k := key.(string) result = append(result, k) return true diff --git a/vendor/github.com/go-openapi/swag/string_bytes.go b/vendor/github.com/go-openapi/swag/string_bytes.go index c52d6bf71..90745d5ca 100644 --- a/vendor/github.com/go-openapi/swag/string_bytes.go +++ b/vendor/github.com/go-openapi/swag/string_bytes.go @@ -2,21 +2,7 @@ package swag import "unsafe" -type internalString struct { - Data unsafe.Pointer - Len int -} - // hackStringBytes returns the (unsafe) underlying bytes slice of a string. -func hackStringBytes(str string) []byte { - p := (*internalString)(unsafe.Pointer(&str)).Data - return unsafe.Slice((*byte)(p), len(str)) -} - -/* - * go1.20 version (for when go mod moves to a go1.20 requirement): - func hackStringBytes(str string) []byte { return unsafe.Slice(unsafe.StringData(str), len(str)) } -*/ diff --git a/vendor/github.com/go-openapi/swag/yaml.go b/vendor/github.com/go-openapi/swag/yaml.go index a8c4e359e..f59e02593 100644 --- a/vendor/github.com/go-openapi/swag/yaml.go +++ b/vendor/github.com/go-openapi/swag/yaml.go @@ -16,6 +16,7 @@ package swag import ( "encoding/json" + "errors" "fmt" "path/filepath" "reflect" @@ -50,7 +51,7 @@ func BytesToYAMLDoc(data []byte) (interface{}, error) { return nil, err } if document.Kind != yaml.DocumentNode || len(document.Content) != 1 || document.Content[0].Kind != yaml.MappingNode { - return nil, fmt.Errorf("only YAML documents that are objects are supported") + return nil, errors.New("only YAML documents that are objects are supported") } return &document, nil } diff --git a/vendor/github.com/openshift/machine-api-operator/LICENSE b/vendor/github.com/openshift/machine-api-operator/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/openshift/machine-api-operator/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go new file mode 100644 index 000000000..4f5d74d03 --- /dev/null +++ b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go @@ -0,0 +1,35 @@ +package conditions + +import ( + machinev1 "github.com/openshift/api/machine/v1beta1" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" +) + +// GetNodeCondition returns node condition by type +func GetNodeCondition(node *corev1.Node, conditionType corev1.NodeConditionType) *corev1.NodeCondition { + for _, cond := range node.Status.Conditions { + if cond.Type == conditionType { + return &cond + } + } + return nil +} + +// GetDeploymentCondition returns node condition by type +func GetDeploymentCondition(deployment *appsv1.Deployment, conditionType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition { + for _, cond := range deployment.Status.Conditions { + if cond.Type == conditionType { + return &cond + } + } + return nil +} + +func DeepCopyConditions(in []machinev1.Condition) []machinev1.Condition { + out := make([]machinev1.Condition, 0) + for _, cond := range in { + out = append(out, *cond.DeepCopy()) + } + return out +} diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go new file mode 100644 index 000000000..d2a3eafb4 --- /dev/null +++ b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go @@ -0,0 +1,181 @@ +package conditions + +import ( + "fmt" + "sort" + "time" + + machinev1 "github.com/openshift/api/machine/v1beta1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +type GetterSetter interface { + runtime.Object + metav1.Object + + // GetConditions returns the list of conditions for a machine API object. + GetConditions() []machinev1.Condition + + // SetConditions sets the list of conditions for a machine API object. + SetConditions([]machinev1.Condition) +} + +// Get returns the condition with the given type, if the condition does not exists, +// it returns nil. +func Get(from interface{}, t machinev1.ConditionType) *machinev1.Condition { + obj := getWrapperObject(from) + conditions := obj.GetConditions() + if conditions == nil { + return nil + } + + for _, condition := range conditions { + if condition.Type == t { + return &condition + } + } + return nil +} + +// Set sets the given condition. +// +// NOTE: If a condition already exists, the LastTransitionTime is updated only if a change is detected +// in any of the following fields: Status, Reason, Severity and Message. +func Set(to interface{}, condition *machinev1.Condition) { + if to == nil || condition == nil { + return + } + + obj := getWrapperObject(to) + + // Check if the new conditions already exists, and change it only if there is a status + // transition (otherwise we should preserve the current last transition time)- + conditions := obj.GetConditions() + exists := false + for i := range conditions { + existingCondition := conditions[i] + if existingCondition.Type == condition.Type { + exists = true + if !hasSameState(&existingCondition, condition) { + condition.LastTransitionTime = metav1.NewTime(time.Now().UTC().Truncate(time.Second)) + conditions[i] = *condition + break + } + condition.LastTransitionTime = existingCondition.LastTransitionTime + break + } + } + + // If the condition does not exist, add it, setting the transition time only if not already set + if !exists { + if condition.LastTransitionTime.IsZero() { + condition.LastTransitionTime = metav1.NewTime(time.Now().UTC().Truncate(time.Second)) + } + conditions = append(conditions, *condition) + } + + // Sorts conditions for convenience of the consumer, i.e. kubectl. + sort.Slice(conditions, func(i, j int) bool { + return lexicographicLess(&conditions[i], &conditions[j]) + }) + + obj.SetConditions(conditions) +} + +// TrueCondition returns a condition with Status=True and the given type. +func TrueCondition(t machinev1.ConditionType) *machinev1.Condition { + return &machinev1.Condition{ + Type: t, + Status: corev1.ConditionTrue, + } +} + +// TrueConditionWithReason returns a condition with Status=True and the given type. +func TrueConditionWithReason(t machinev1.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *machinev1.Condition { + return &machinev1.Condition{ + Type: t, + Status: corev1.ConditionTrue, + Reason: reason, + Message: fmt.Sprintf(messageFormat, messageArgs...), + } +} + +// FalseCondition returns a condition with Status=False and the given type. +func FalseCondition(t machinev1.ConditionType, reason string, severity machinev1.ConditionSeverity, messageFormat string, messageArgs ...interface{}) *machinev1.Condition { + return &machinev1.Condition{ + Type: t, + Status: corev1.ConditionFalse, + Reason: reason, + Severity: severity, + Message: fmt.Sprintf(messageFormat, messageArgs...), + } +} + +// UnknownCondition returns a condition with Status=Unknown and the given type. +func UnknownCondition(t machinev1.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *machinev1.Condition { + return &machinev1.Condition{ + Type: t, + Status: corev1.ConditionUnknown, + Reason: reason, + Message: fmt.Sprintf(messageFormat, messageArgs...), + } +} + +// MarkTrue sets Status=True for the condition with the given type. +func MarkTrue(to interface{}, t machinev1.ConditionType) { + Set(to, TrueCondition(t)) +} + +// MarkFalse sets Status=False for the condition with the given type. +func MarkFalse(to interface{}, t machinev1.ConditionType, reason string, severity machinev1.ConditionSeverity, messageFormat string, messageArgs ...interface{}) { + Set(to, FalseCondition(t, reason, severity, messageFormat, messageArgs...)) +} + +// IsTrue is true if the condition with the given type is True, otherwise it return false +// if the condition is not True or if the condition does not exist (is nil). +func IsTrue(from interface{}, t machinev1.ConditionType) bool { + if c := Get(from, t); c != nil { + return c.Status == corev1.ConditionTrue + } + return false +} + +// IsFalse is true if the condition with the given type is False, otherwise it return false +// if the condition is not False or if the condition does not exist (is nil). +func IsFalse(from interface{}, t machinev1.ConditionType) bool { + if c := Get(from, t); c != nil { + return c.Status == corev1.ConditionFalse + } + return false +} + +// lexicographicLess returns true if a condition is less than another with regards to the +// to order of conditions designed for convenience of the consumer, i.e. kubectl. +func lexicographicLess(i, j *machinev1.Condition) bool { + return i.Type < j.Type +} + +// hasSameState returns true if a condition has the same state of another; state is defined +// by the union of following fields: Type, Status, Reason, Severity and Message (it excludes LastTransitionTime). +func hasSameState(i, j *machinev1.Condition) bool { + return i.Type == j.Type && + i.Status == j.Status && + i.Reason == j.Reason && + i.Severity == j.Severity && + i.Message == j.Message +} + +func getWrapperObject(from interface{}) GetterSetter { + switch obj := from.(type) { + case *machinev1.Machine: + return &MachineWrapper{obj} + case *machinev1.MachineSet: + return &MachineSetWrapper{obj} + case *machinev1.MachineHealthCheck: + return &MachineHealthCheckWrapper{obj} + default: + panic("type is not supported as conditions getter or setter") + } +} diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go new file mode 100644 index 000000000..5e5576103 --- /dev/null +++ b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go @@ -0,0 +1,102 @@ +/* +Copyright 2020 The Kubernetes Authors. + +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. +*/ + +package conditions + +import ( + "fmt" + + . "github.com/onsi/gomega" + "github.com/onsi/gomega/types" + machinev1 "github.com/openshift/api/machine/v1beta1" +) + +// MatchConditions returns a custom matcher to check equality of mapiv1.Conditions +func MatchConditions(expected []machinev1.Condition) types.GomegaMatcher { + return &matchConditions{ + expected: expected, + } +} + +type matchConditions struct { + expected []machinev1.Condition +} + +func (m matchConditions) Match(actual interface{}) (success bool, err error) { + elems := []interface{}{} + for _, condition := range m.expected { + elems = append(elems, MatchCondition(condition)) + } + + return ConsistOf(elems).Match(actual) +} + +func (m matchConditions) FailureMessage(actual interface{}) (message string) { + return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected) +} + +func (m matchConditions) NegatedFailureMessage(actual interface{}) (message string) { + return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected) +} + +// MatchCondition returns a custom matcher to check equality of mapiv1.Condition +func MatchCondition(expected machinev1.Condition) types.GomegaMatcher { + return &matchCondition{ + expected: expected, + } +} + +type matchCondition struct { + expected machinev1.Condition +} + +func (m matchCondition) Match(actual interface{}) (success bool, err error) { + actualCondition, ok := actual.(machinev1.Condition) + if !ok { + return false, fmt.Errorf("actual should be of type Condition") + } + + ok, err = Equal(m.expected.Type).Match(actualCondition.Type) + if !ok { + return ok, err + } + ok, err = Equal(m.expected.Status).Match(actualCondition.Status) + if !ok { + return ok, err + } + ok, err = Equal(m.expected.Severity).Match(actualCondition.Severity) + if !ok { + return ok, err + } + ok, err = Equal(m.expected.Reason).Match(actualCondition.Reason) + if !ok { + return ok, err + } + ok, err = Equal(m.expected.Message).Match(actualCondition.Message) + if !ok { + return ok, err + } + + return ok, err +} + +func (m matchCondition) FailureMessage(actual interface{}) (message string) { + return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected) +} + +func (m matchCondition) NegatedFailureMessage(actual interface{}) (message string) { + return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected) +} diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go new file mode 100644 index 000000000..5f72d1e15 --- /dev/null +++ b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go @@ -0,0 +1,41 @@ +package conditions + +import ( + machinev1 "github.com/openshift/api/machine/v1beta1" +) + +type MachineWrapper struct { + *machinev1.Machine +} + +func (m *MachineWrapper) GetConditions() []machinev1.Condition { + return m.Status.Conditions +} + +func (m *MachineWrapper) SetConditions(conditions []machinev1.Condition) { + m.Status.Conditions = conditions +} + +type MachineHealthCheckWrapper struct { + *machinev1.MachineHealthCheck +} + +func (m *MachineHealthCheckWrapper) GetConditions() []machinev1.Condition { + return m.Status.Conditions +} + +func (m *MachineHealthCheckWrapper) SetConditions(conditions []machinev1.Condition) { + m.Status.Conditions = conditions +} + +type MachineSetWrapper struct { + *machinev1.MachineSet +} + +func (m *MachineSetWrapper) GetConditions() []machinev1.Condition { + return m.Status.Conditions +} + +func (m *MachineSetWrapper) SetConditions(conditions []machinev1.Condition) { + m.Status.Conditions = conditions +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1990924af..a349c5790 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -290,18 +290,18 @@ github.com/go-logr/zapr # github.com/go-openapi/errors v0.22.0 ## explicit; go 1.20 github.com/go-openapi/errors -# github.com/go-openapi/jsonpointer v0.20.2 -## explicit; go 1.19 +# github.com/go-openapi/jsonpointer v0.21.0 +## explicit; go 1.20 github.com/go-openapi/jsonpointer -# github.com/go-openapi/jsonreference v0.20.4 -## explicit; go 1.19 +# github.com/go-openapi/jsonreference v0.21.0 +## explicit; go 1.20 github.com/go-openapi/jsonreference github.com/go-openapi/jsonreference/internal # github.com/go-openapi/strfmt v0.23.0 ## explicit; go 1.20 github.com/go-openapi/strfmt -# github.com/go-openapi/swag v0.22.8 -## explicit; go 1.19 +# github.com/go-openapi/swag v0.23.0 +## explicit; go 1.20 github.com/go-openapi/swag # github.com/go-playground/locales v0.14.1 ## explicit; go 1.17 @@ -960,6 +960,9 @@ github.com/openshift/library-go/pkg/operator/resource/resourcemerge github.com/openshift/library-go/pkg/operator/resource/resourceread github.com/openshift/library-go/pkg/operator/resourcesynccontroller github.com/openshift/library-go/pkg/operator/v1helpers +# github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac +## explicit; go 1.22.1 +github.com/openshift/machine-api-operator/pkg/util/conditions # github.com/pelletier/go-toml/v2 v2.2.3 ## explicit; go 1.21.0 github.com/pelletier/go-toml/v2 From 4840af7d1e6e61d32da0cc5b54780a9dbb31fe8d Mon Sep 17 00:00:00 2001 From: Theo Barber-Bany Date: Fri, 18 Oct 2024 15:22:41 +0100 Subject: [PATCH 2/4] Implements CAPI to MAPI MachineSet synchronisation This change Implements synchronisation from CAPI -> MAPI MachineSets when the AuthoritativeAPI is set to CAPI. --- go.mod | 3 +- go.sum | 6 +- pkg/controllers/common_consts.go | 11 + .../machineset_sync_controller.go | 294 ++++-- .../machineset_sync_controller_test.go | 37 +- pkg/controllers/machinesetsync/suite_test.go | 5 + pkg/test/crdbuilder.go | 6 + pkg/test/envtest.go | 10 +- pkg/util/maps.go | 30 + pkg/util/ssa.go | 46 + .../applyconfigurations/internal/internal.go | 956 ++++++++++++++++++ .../machine/v1beta1/condition.go | 74 ++ .../machine/v1beta1/lastoperation.go | 54 + .../machine/v1beta1/lifecyclehook.go | 32 + .../machine/v1beta1/lifecyclehooks.go | 42 + .../machine/v1beta1/machine.go | 248 +++++ .../machine/v1beta1/machinehealthcheck.go | 248 +++++ .../machine/v1beta1/machinehealthcheckspec.go | 71 ++ .../v1beta1/machinehealthcheckstatus.go | 55 + .../machine/v1beta1/machineset.go | 248 +++++ .../machine/v1beta1/machinesetspec.go | 73 ++ .../machine/v1beta1/machinesetstatus.go | 113 +++ .../machine/v1beta1/machinespec.go | 145 +++ .../machine/v1beta1/machinestatus.go | 127 +++ .../machine/v1beta1/machinetemplatespec.go | 105 ++ .../machine/v1beta1/objectmeta.go | 89 ++ .../machine/v1beta1/providerspec.go | 27 + .../machine/v1beta1/unhealthycondition.go | 46 + .../openshift/machine-api-operator/LICENSE | 201 ---- .../pkg/util/conditions/conditions.go | 35 - .../pkg/util/conditions/gettersetter.go | 181 ---- .../pkg/util/conditions/matcher.go | 102 -- .../pkg/util/conditions/wrap.go | 41 - vendor/modules.txt | 7 +- .../pkg/client/fake/client.go | 43 +- 35 files changed, 3164 insertions(+), 647 deletions(-) create mode 100644 pkg/util/maps.go create mode 100644 pkg/util/ssa.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/internal/internal.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/condition.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lastoperation.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehook.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehooks.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machine.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheck.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckspec.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckstatus.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machineset.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetspec.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetstatus.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinespec.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinestatus.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinetemplatespec.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/objectmeta.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/providerspec.go create mode 100644 vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/unhealthycondition.go delete mode 100644 vendor/github.com/openshift/machine-api-operator/LICENSE delete mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go delete mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go delete mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go delete mode 100644 vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go diff --git a/go.mod b/go.mod index 0f78315a1..c29f25845 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,6 @@ require ( github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20241024095219-086923b9d3fd github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20241008085214-8d85b2cb2c1d github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b - github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac github.com/pkg/errors v0.9.1 github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace gopkg.in/yaml.v2 v2.4.0 @@ -36,7 +35,7 @@ require ( sigs.k8s.io/cluster-api-provider-ibmcloud v0.8.0 sigs.k8s.io/cluster-api-provider-openstack v0.11.1 sigs.k8s.io/cluster-api-provider-vsphere v1.10.0 - sigs.k8s.io/controller-runtime v0.19.0 + sigs.k8s.io/controller-runtime v0.19.1 sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240923090159-236e448db12c sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index 4ac2bd44d..af3d1c3c0 100644 --- a/go.sum +++ b/go.sum @@ -429,8 +429,6 @@ github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-202410080 github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20241008085214-8d85b2cb2c1d/go.mod h1:u+45mmWUg2ld7nsPDXzntjMsxannCV0CVmcUj9tIDvU= github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b h1:y2DduJug7UZqTu0QTkRPAu73nskuUbFA66fmgxVf/fI= github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b/go.mod h1:f8QcnrooSwGa96xI4UaKbKGJZskhTCGeimXKyc4t/ZU= -github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac h1:qlOVMOPOJ/0YRDKUk5FUZspJSILUo/7P3V5Kd8vP4d8= -github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac/go.mod h1:gXjplVdC80eclLdaZbWsDbbewhHmE99CVk4o61TiTbM= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= @@ -845,8 +843,8 @@ sigs.k8s.io/cluster-api-provider-openstack v0.11.1 h1:j3aBJr5DozXbOT25QHmbDdCKs6 sigs.k8s.io/cluster-api-provider-openstack v0.11.1/go.mod h1:fH/eFFSgLtfyNB1OvYVPhrIdM7zhxAAkWbuJhr3ObpM= sigs.k8s.io/cluster-api-provider-vsphere v1.10.0 h1:UMdJgcaKm+RBLEG6k2jotXh4yuhCJg2OYv4eqOji1tU= sigs.k8s.io/cluster-api-provider-vsphere v1.10.0/go.mod h1:CksGHK/wRUPa9I9tmjb4xwM+0f/u/6L8o8EjTggt3xI= -sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q= -sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= +sigs.k8s.io/controller-runtime v0.19.1 h1:Son+Q40+Be3QWb+niBXAg2vFiYWolDjjRfO8hn/cxOk= +sigs.k8s.io/controller-runtime v0.19.1/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240923090159-236e448db12c h1:w1vANkdIpYwbEZH0y1C7iJItgdEGvF9A3eCdRmLhg8I= sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240923090159-236e448db12c/go.mod h1:IaDsO8xSPRxRG1/rm9CP7+jPmj0nMNAuNi/yiHnLX8k= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/pkg/controllers/common_consts.go b/pkg/controllers/common_consts.go index f6cf280a2..a9f388246 100644 --- a/pkg/controllers/common_consts.go +++ b/pkg/controllers/common_consts.go @@ -15,6 +15,8 @@ limitations under the License. */ package controllers +import machinev1beta1 "github.com/openshift/api/machine/v1beta1" + const ( // DefaultManagedNamespace is the default namespace where the operator // manages CAPI resources. @@ -32,4 +34,13 @@ const ( // InfrastructureResourceName is the name of the cluster global infrastructure resource. InfrastructureResourceName = "cluster" + + // SynchronizedCondition is used to denote when a MAPI or CAPI resource is + // synchronized. This condition should only be true when a synchronization + // controller has successfully synchronized a non-authoritative resource. + SynchronizedCondition machinev1beta1.ConditionType = "Synchronized" + + // ReasonResourceSynchronized denotes that the resource is synchronized + // successfully. + ReasonResourceSynchronized = "ResourceSynchronized" ) diff --git a/pkg/controllers/machinesetsync/machineset_sync_controller.go b/pkg/controllers/machinesetsync/machineset_sync_controller.go index f9b7f62e5..074325031 100644 --- a/pkg/controllers/machinesetsync/machineset_sync_controller.go +++ b/pkg/controllers/machinesetsync/machineset_sync_controller.go @@ -20,14 +20,24 @@ import ( "context" "errors" "fmt" + "reflect" + "github.com/go-logr/logr" configv1 "github.com/openshift/api/config/v1" machinev1beta1 "github.com/openshift/api/machine/v1beta1" + consts "github.com/openshift/cluster-capi-operator/pkg/controllers" + "github.com/openshift/cluster-capi-operator/pkg/conversion/capi2mapi" "github.com/openshift/cluster-capi-operator/pkg/util" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + utilerrors "k8s.io/apimachinery/pkg/util/errors" + + machinev1applyconfigs "github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1" "k8s.io/client-go/tools/record" - awscapiv1beta1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta1" + awscapiv1beta1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" @@ -37,11 +47,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" ) -const ( - capiNamespace string = "openshift-cluster-api" - mapiNamespace string = "openshift-machine-api" -) - var ( // errPlatformNotSupported is returned when the platform is not supported. errPlatformNotSupported = errors.New("error determining InfraMachineTemplate type, platform not supported") @@ -58,20 +63,21 @@ type MachineSetSyncReconciler struct { MAPINamespace string } -// SetupWithManager sets the CoreClusterReconciler controller up with the given manager. +// SetupWithManager sets up the controller with the Manager. func (r *MachineSetSyncReconciler) SetupWithManager(mgr ctrl.Manager) error { infraMachineTemplate, err := getInfraMachineTemplateFromProvider(r.Platform) if err != nil { - return fmt.Errorf("failed to get InfraMachine from Provider: %w", err) + return fmt.Errorf("failed to get InfraMachineTemplate from Provider: %w", err) } + // Allow the namespaces to be set externally for test purposes, when not set, // default to the production namespaces. if r.CAPINamespace == "" { - r.CAPINamespace = capiNamespace + r.CAPINamespace = consts.DefaultManagedNamespace } if r.MAPINamespace == "" { - r.MAPINamespace = mapiNamespace + r.MAPINamespace = consts.DefaultMAPIManagedNamespace } if err := ctrl.NewControllerManagedBy(mgr). @@ -98,88 +104,224 @@ func (r *MachineSetSyncReconciler) SetupWithManager(mgr ctrl.Manager) error { return nil } -// Reconcile reconciles CAPI and MAPI machines for their respective namespaces. -// -//nolint:funlen +// Reconcile reconciles CAPI and MAPI MachineSets for their respective namespaces. func (r *MachineSetSyncReconciler) Reconcile(ctx context.Context, req reconcile.Request) (ctrl.Result, error) { - logger := log.FromContext(ctx, "namespace", req.Namespace, "name", req.Name) + logger := log.FromContext(ctx).WithValues("namespace", req.Namespace, "name", req.Name) + ctx = logr.NewContext(ctx, logger) - logger.V(1).Info("Reconciling machineset") - defer logger.V(1).Info("Finished reconciling machineset") + logger.V(1).Info("Reconciling machine set") + defer logger.V(1).Info("Finished reconciling machine set") - var mapiMachineSetNotFound, capiMachineSetNotFound bool + mapiMachineSet, capiMachineSet, err := r.fetchMachineSets(ctx, req.Name) + if err != nil { + return ctrl.Result{}, fmt.Errorf("failed to fetch machine sets: %w", err) + } - // Get the MAPI MachineSet. - mapiMachineSet := &machinev1beta1.MachineSet{} - mapiNamespacedName := client.ObjectKey{ - Namespace: r.MAPINamespace, - Name: req.Name, + if mapiMachineSet == nil && capiMachineSet == nil { + logger.Info("Both MAPI and CAPI machine sets not found, nothing to do") + return ctrl.Result{}, nil } - if err := r.Get(ctx, mapiNamespacedName, mapiMachineSet); apierrors.IsNotFound(err) { - logger.Info("MAPI MachineSet not found") + if mapiMachineSet == nil { + logger.Info("Only CAPI machine set found, nothing to do") + return ctrl.Result{}, nil + } + + return r.syncMachineSets(ctx, mapiMachineSet, capiMachineSet) +} + +// fetchMachineSets fetches both MAPI and CAPI MachineSets. +func (r *MachineSetSyncReconciler) fetchMachineSets(ctx context.Context, name string) (*machinev1beta1.MachineSet, *capiv1beta1.MachineSet, error) { + logger := log.FromContext(ctx) - mapiMachineSetNotFound = true + mapiMachineSet := &machinev1beta1.MachineSet{} + + if err := r.Get(ctx, client.ObjectKey{Namespace: r.MAPINamespace, Name: name}, mapiMachineSet); apierrors.IsNotFound(err) { + logger.Info("MAPI machine set not found") + + mapiMachineSet = nil } else if err != nil { - logger.Error(err, "Failed to get MAPI MachineSet") - return ctrl.Result{}, fmt.Errorf("failed to get MAPI MachineSet: %w", err) + return nil, nil, fmt.Errorf("failed to get MAPI machine set: %w", err) } - // Get the corresponding CAPI Machine. capiMachineSet := &capiv1beta1.MachineSet{} - capiNamespacedName := client.ObjectKey{ - Namespace: r.CAPINamespace, - Name: req.Name, - } - if err := r.Get(ctx, capiNamespacedName, capiMachineSet); apierrors.IsNotFound(err) { - logger.Info("CAPI MachineSet not found") + if err := r.Get(ctx, client.ObjectKey{Namespace: r.CAPINamespace, Name: name}, capiMachineSet); apierrors.IsNotFound(err) { + logger.Info("CAPI machine set not found") - capiMachineSetNotFound = true + capiMachineSet = nil } else if err != nil { - logger.Error(err, "Failed to get CAPI MachineSet") - return ctrl.Result{}, fmt.Errorf("failed to get CAPI MachineSet: %w", err) + return nil, nil, fmt.Errorf("failed to get CAPI machine set: %w", err) } - if mapiMachineSetNotFound && capiMachineSetNotFound { - logger.Info("CAPI and MAPI MachineSets not found, nothing to do") - return ctrl.Result{}, nil - } + return mapiMachineSet, capiMachineSet, nil +} - // If the MachineSet only exists in CAPI, we don't need to sync back to MAPI. - if mapiMachineSetNotFound { - logger.Info("Only CAPI MachineSet found, nothing to do") - return ctrl.Result{}, nil - } +// syncMachineSets synchronizes MachineSets based on the authoritative API. +func (r *MachineSetSyncReconciler) syncMachineSets(ctx context.Context, mapiMachineSet *machinev1beta1.MachineSet, capiMachineSet *capiv1beta1.MachineSet) (ctrl.Result, error) { + logger := log.FromContext(ctx) switch mapiMachineSet.Status.AuthoritativeAPI { case machinev1beta1.MachineAuthorityMachineAPI: - return r.reconcileMAPIMachineSettoCAPIMachineSet(ctx, mapiMachineSet, capiMachineSet) + return r.reconcileMAPIMachineSetToCAPIMachineSet(ctx, mapiMachineSet, capiMachineSet) case machinev1beta1.MachineAuthorityClusterAPI: - return r.reconcileCAPIMachineSettoMAPIMachineSet(ctx, capiMachineSet, mapiMachineSet) + return r.reconcileCAPIMachineSetToMAPIMachineSet(ctx, capiMachineSet, mapiMachineSet) case machinev1beta1.MachineAuthorityMigrating: - logger.Info("machine currently migrating", "machine", mapiMachineSet.GetName()) + logger.Info("machine set is currently being migrated", "machine set", mapiMachineSet.GetName()) return ctrl.Result{}, nil default: - logger.Info("machine AuthoritativeAPI has unexpected value", "AuthoritativeAPI", mapiMachineSet.Status.AuthoritativeAPI) + logger.Info("Unexpected value for AuthoritativeAPI", "AuthoritativeAPI", mapiMachineSet.Status.AuthoritativeAPI) return ctrl.Result{}, nil } } -// reconcileCAPIMachineSettoMAPIMachineSet reconciles a CAPI MachineSet to a MAPI MachineSet. -func (r *MachineSetSyncReconciler) reconcileCAPIMachineSettoMAPIMachineSet(ctx context.Context, capiMachineSet *capiv1beta1.MachineSet, mapiMachineSet *machinev1beta1.MachineSet) (ctrl.Result, error) { +// reconcileMAPIMachineSetToCAPIMachineSet reconciles a MAPI MachineSet to a CAPI MachineSet. +func (r *MachineSetSyncReconciler) reconcileMAPIMachineSetToCAPIMachineSet(ctx context.Context, mapiMachineSet *machinev1beta1.MachineSet, capiMachineSet *capiv1beta1.MachineSet) (ctrl.Result, error) { + // This function is currently a placeholder. return ctrl.Result{}, nil } -// reconcileMAPIMachineSettoCAPIMachineSet MAPI MachineSet to a CAPI MachineSet. -func (r *MachineSetSyncReconciler) reconcileMAPIMachineSettoCAPIMachineSet(ctx context.Context, mapiMachineSet *machinev1beta1.MachineSet, capiMachineSet *capiv1beta1.MachineSet) (ctrl.Result, error) { - return ctrl.Result{}, nil +// reconcileCAPIMachineSetToMAPIMachineSet reconciles a CAPI MachineSet to a +// MAPI MachineSet. +// +// TODO: Platform specific implementation (currently this works only for AWS, +// we want a switch on platform somewhere). +// TODO: Put Gets() for Cluster + Template in helper func. +// +//nolint:funlen +func (r *MachineSetSyncReconciler) reconcileCAPIMachineSetToMAPIMachineSet(ctx context.Context, capiMachineSet *capiv1beta1.MachineSet, mapiMachineSet *machinev1beta1.MachineSet) (ctrl.Result, error) { + logger := log.FromContext(ctx) + + infraCluster := &awscapiv1beta1.AWSCluster{} + clusterNamespacedName := client.ObjectKey{ + Namespace: capiMachineSet.GetNamespace(), + Name: capiMachineSet.Spec.ClusterName, + } + + if err := r.Get(ctx, clusterNamespacedName, infraCluster); err != nil { + getErr := fmt.Errorf("failed to get CAPI InfraCluster: %w", err) + + if condErr := r.updateSynchronizedConditionWithPatch( + ctx, mapiMachineSet, corev1.ConditionFalse, + "FailedToGetCAPIInfraCluster", err.Error(), nil); condErr != nil { + return ctrl.Result{}, utilerrors.NewAggregate([]error{getErr, condErr}) + } + + return ctrl.Result{}, getErr + } + + infraMachineTemplate := &awscapiv1beta1.AWSMachineTemplate{} + templateNamespacedName := client.ObjectKey{ + Namespace: capiMachineSet.Spec.Template.Spec.InfrastructureRef.Namespace, + Name: capiMachineSet.Spec.Template.Spec.InfrastructureRef.Name, + } + + if err := r.Get(ctx, templateNamespacedName, infraMachineTemplate); err != nil { + getErr := fmt.Errorf("failed to get InfraMachineTemplate: %w", err) + + if condErr := r.updateSynchronizedConditionWithPatch( + ctx, mapiMachineSet, corev1.ConditionFalse, + "FailedToGetCAPIInfraMachineTemplate", err.Error(), nil); condErr != nil { + return ctrl.Result{}, utilerrors.NewAggregate([]error{getErr, condErr}) + } + + return ctrl.Result{}, getErr + } + + // Convert the CAPI MachineSet and AWS resources to a MAPI MachineSet + newMapiMachineSet, warns, err := capi2mapi.FromMachineSetAndAWSMachineTemplateAndAWSCluster( + capiMachineSet, infraMachineTemplate, infraCluster).ToMachineSet() + if err != nil { + conversionErr := fmt.Errorf("failed to convert CAPI machine set to MAPI machine set: %w", err) + + if condErr := r.updateSynchronizedConditionWithPatch( + ctx, mapiMachineSet, corev1.ConditionFalse, + "FailedToConvertCAPIMachineSetToMAPI", err.Error(), nil); condErr != nil { + return ctrl.Result{}, utilerrors.NewAggregate([]error{conversionErr, condErr}) + } + + return ctrl.Result{}, conversionErr + } + + for _, warning := range warns { + logger.Info("Warning during conversion", "warning", warning) + r.Recorder.Event(mapiMachineSet, corev1.EventTypeWarning, "ConversionWarning", warning) + } + + newMapiMachineSet.Spec.Template.Labels = util.MergeMaps(mapiMachineSet.Spec.Template.Labels, newMapiMachineSet.Spec.Template.Labels) + + // We need to change the namespace as the newMapiMachineSet will have the CAPI namespace set otherwise + newMapiMachineSet.SetNamespace(mapiMachineSet.GetNamespace()) + // The conversion does not set a resource version, so we must copy it over + newMapiMachineSet.SetResourceVersion(mapiMachineSet.GetResourceVersion()) + + // Check if there are any changes to spec or metadata + if !reflect.DeepEqual(newMapiMachineSet.Spec, mapiMachineSet.Spec) || !objectMetaIsEqual(newMapiMachineSet.ObjectMeta, mapiMachineSet.ObjectMeta) { + logger.Info("Updating MAPI machine set") + + if err := r.Update(ctx, newMapiMachineSet); err != nil { + logger.Error(err, "Failed to update MAPI machine set") + + updateErr := fmt.Errorf("failed to update MAPI machine set: %w", err) + + if condErr := r.updateSynchronizedConditionWithPatch( + ctx, mapiMachineSet, corev1.ConditionFalse, + "FailedToUpdateMAPIMachineSet", err.Error(), nil); condErr != nil { + return ctrl.Result{}, utilerrors.NewAggregate([]error{updateErr, condErr}) + } + + return ctrl.Result{}, updateErr + } + + logger.Info("Successfully updated MAPI machine set") + } else { + logger.Info("No changes detected in MAPI machine set") + } + + return ctrl.Result{}, r.updateSynchronizedConditionWithPatch(ctx, mapiMachineSet, corev1.ConditionTrue, + consts.ReasonResourceSynchronized, "Successfully synchronized CAPI MachineSet to MAPI", + &capiMachineSet.Generation) +} + +// updateSynchronizedConditionWithPatch updates the synchronized condition +// using a server side apply patch. We do this to force ownership of the +// 'Synchronized' condition and 'SynchronizedGeneration'. +func (r *MachineSetSyncReconciler) updateSynchronizedConditionWithPatch(ctx context.Context, mapiMachineSet *machinev1beta1.MachineSet, status corev1.ConditionStatus, reason, message string, generation *int64) error { + var severity machinev1beta1.ConditionSeverity + if status == corev1.ConditionTrue { + severity = machinev1beta1.ConditionSeverityNone + } else { + severity = machinev1beta1.ConditionSeverityError + } + + conditionAc := machinev1applyconfigs.Condition(). + WithType(consts.SynchronizedCondition). + WithStatus(status). + WithReason(reason). + WithMessage(message). + WithSeverity(severity) + + setLastTransitionTime(consts.SynchronizedCondition, mapiMachineSet.Status.Conditions, conditionAc) + + statusAc := machinev1applyconfigs.MachineSetStatus(). + WithConditions(conditionAc) + + if status == corev1.ConditionTrue && generation != nil { + statusAc = statusAc.WithSynchronizedGeneration(*generation) + } + + msAc := machinev1applyconfigs.MachineSet(mapiMachineSet.GetName(), mapiMachineSet.GetNamespace()). + WithStatus(statusAc) + + if err := r.Status().Patch(ctx, mapiMachineSet, util.ApplyConfigPatch(msAc), client.ForceOwnership, client.FieldOwner("machineset-sync-controller")); err != nil { + return fmt.Errorf("failed to patch MAPI machine set status with synchronized condition: %w", err) + } + + return nil } // getInfraMachineTemplateFromProvider returns the correct InfraMachineTemplate implementation // for a given provider. -// -// As we implement other cloud providers, we'll need to update this list. func getInfraMachineTemplateFromProvider(platform configv1.PlatformType) (client.Object, error) { switch platform { case configv1.AWSPlatformType: @@ -188,3 +330,41 @@ func getInfraMachineTemplateFromProvider(platform configv1.PlatformType) (client return nil, fmt.Errorf("%w: %s", errPlatformNotSupported, platform) } } + +// setLastTransitionTime determines if the last transition time should be set or updated for a given condition type. +func setLastTransitionTime(condType machinev1beta1.ConditionType, conditions []machinev1beta1.Condition, conditionAc *machinev1applyconfigs.ConditionApplyConfiguration) { + for _, condition := range conditions { + if condition.Type == condType { + if !hasSameState(&condition, conditionAc) { + conditionAc.WithLastTransitionTime(metav1.Now()) + + return + } + + conditionAc.WithLastTransitionTime(condition.LastTransitionTime) + + return + } + } + // Condition does not exist; set the transition time + conditionAc.WithLastTransitionTime(metav1.Now()) +} + +// hasSameState returns true if a condition has the same state as a condition +// apply config; state is defined by the union of following fields: Type, +// Status, Reason, Severity and Message (it excludes LastTransitionTime). +func hasSameState(i *machinev1beta1.Condition, j *machinev1applyconfigs.ConditionApplyConfiguration) bool { + return i.Type == *j.Type && + i.Status == *j.Status +} + +// objectMetaIsEqual determines if the two ObjectMeta are equal for the fields we care about +// when synchronising MAPI and CAPI MachineSets. +func objectMetaIsEqual(a, b metav1.ObjectMeta) bool { + return a.DeletionTimestamp.Equal(b.DeletionTimestamp) && + a.DeletionGracePeriodSeconds == b.DeletionGracePeriodSeconds && + reflect.DeepEqual(a.Labels, b.Labels) && + reflect.DeepEqual(a.Annotations, b.Annotations) && + reflect.DeepEqual(a.Finalizers, b.Finalizers) && + reflect.DeepEqual(a.OwnerReferences, b.OwnerReferences) +} diff --git a/pkg/controllers/machinesetsync/machineset_sync_controller_test.go b/pkg/controllers/machinesetsync/machineset_sync_controller_test.go index 30be57fcf..a835922c2 100644 --- a/pkg/controllers/machinesetsync/machineset_sync_controller_test.go +++ b/pkg/controllers/machinesetsync/machineset_sync_controller_test.go @@ -26,11 +26,10 @@ import ( corev1resourcebuilder "github.com/openshift/cluster-api-actuator-pkg/testutils/resourcebuilder/core/v1" machinev1resourcebuilder "github.com/openshift/cluster-api-actuator-pkg/testutils/resourcebuilder/machine/v1beta1" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/reconcile" + consts "github.com/openshift/cluster-capi-operator/pkg/controllers" "github.com/openshift/cluster-capi-operator/pkg/test" ) @@ -106,15 +105,33 @@ var _ = Describe("MachineSetSync Reconciler", func() { stopManager() }) - It("should reconcile without erroring", func() { - machineset = machineSetBuilder.Build() + Context("when the MAPI machine set has MachineAuthority set to Cluster API", func() { + JustBeforeEach(func() { + By("Creating the CAPI and MAPI MachineSets") + mapiMachineSet = mapiMachineSetBuilder.Build() + capiMachineSet = capiMachineSetBuilder.Build() - _, err := reconciler.Reconcile(ctx, reconcile.Request{ - NamespacedName: types.NamespacedName{ - Namespace: namespaceName, - Name: machineset.Name, - }, + Expect(k8sClient.Create(ctx, capiMachineSet)).Should(Succeed()) + Expect(k8sClient.Create(ctx, mapiMachineSet)).Should(Succeed()) + + }) + + // For now only happy path + It("should update the synchronized condition", func() { + + By("Setting the AuthoritativeAPI to ClusterAPI") + Eventually(k.UpdateStatus(mapiMachineSet, func() { + mapiMachineSet.Status.AuthoritativeAPI = machinev1beta1.MachineAuthorityClusterAPI + })).Should(Succeed()) + + Eventually(k.Object(mapiMachineSet), timeout).Should( + HaveField("Status.Conditions", ContainElement( + SatisfyAll( + HaveField("Type", Equal(consts.SynchronizedCondition)), + HaveField("Status", Equal(corev1.ConditionTrue)), + ))), + ) }) - Expect(err).ToNot(HaveOccurred()) + }) }) diff --git a/pkg/controllers/machinesetsync/suite_test.go b/pkg/controllers/machinesetsync/suite_test.go index 9e99c99bb..494fd18c1 100644 --- a/pkg/controllers/machinesetsync/suite_test.go +++ b/pkg/controllers/machinesetsync/suite_test.go @@ -19,6 +19,7 @@ package machinesetsync import ( "context" "testing" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -41,6 +42,10 @@ import ( //+kubebuilder:scaffold:imports ) +const ( + timeout = time.Second * 2 +) + var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment diff --git a/pkg/test/crdbuilder.go b/pkg/test/crdbuilder.go index ba62bd5fa..0c423ead2 100644 --- a/pkg/test/crdbuilder.go +++ b/pkg/test/crdbuilder.go @@ -70,6 +70,12 @@ var ( // fakeAWSClusterCRD is a fake AWSCluster CRD. fakeAWSClusterCRD = generateCRD(v1beta2InfrastructureGroupVersion.WithKind(fakeAWSClusterKind)) + // fakeAWSMachineTemplateKind is the kind for the AWSMachineTemplate. + fakeAWSMachineTemplateKind = "AWSMachineTemplate" + + // fakeAWSMachineTemplateCRD is a fake AWSMachineTemplate CRD. + fakeAWSMachineTemplateCRD = generateCRD(v1beta2InfrastructureGroupVersion.WithKind(fakeAWSMachineTemplateKind)) + // fakeAzureClusterKind is the Kind for the AWSCluster. fakeAzureClusterKind = "AzureCluster" diff --git a/pkg/test/envtest.go b/pkg/test/envtest.go index b578b08ba..c3f01768f 100644 --- a/pkg/test/envtest.go +++ b/pkg/test/envtest.go @@ -62,16 +62,24 @@ func StartEnvTest(testEnv *envtest.Environment) (*rest.Config, client.Client, er fakeMachineCRD, fakeMachineSetCRD, fakeAWSClusterCRD, + fakeAWSMachineTemplateCRD, fakeAzureClusterCRD, fakeGCPClusterCRD, } + testEnv.CRDDirectoryPaths = []string{ path.Join(root, "vendor", "github.com", "openshift", "api", "config", "v1", "zz_generated.crd-manifests"), path.Join(root, "vendor", "github.com", "openshift", "api", "operator", "v1", "zz_generated.crd-manifests"), - path.Join(root, "vendor", "github.com", "openshift", "api", "machine", "v1beta1", "zz_generated.crd-manifests"), } testEnv.ErrorIfCRDPathMissing = true + testEnv.CRDInstallOptions = envtest.CRDInstallOptions{ + Paths: []string{ + path.Join(root, "vendor", "github.com", "openshift", "api", "machine", "v1beta1", "zz_generated.crd-manifests", "0000_10_machine-api_01_machinesets-CustomNoUpgrade.crd.yaml"), + path.Join(root, "vendor", "github.com", "openshift", "api", "machine", "v1beta1", "zz_generated.crd-manifests", "0000_10_machine-api_01_machines-CustomNoUpgrade.crd.yaml"), + }, + } + cfg, err := testEnv.Start() if err != nil { return nil, nil, err diff --git a/pkg/util/maps.go b/pkg/util/maps.go new file mode 100644 index 000000000..0433ff8da --- /dev/null +++ b/pkg/util/maps.go @@ -0,0 +1,30 @@ +/* +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. +*/ +package util + +// MergeMaps merges two maps, with values from the second map taking precedence. +func MergeMaps(m1, m2 map[string]string) map[string]string { + result := make(map[string]string, len(m1)) + for k, v := range m1 { + result[k] = v + } + + for k, v := range m2 { + result[k] = v + } + + return result +} diff --git a/pkg/util/ssa.go b/pkg/util/ssa.go new file mode 100644 index 000000000..44b39aa62 --- /dev/null +++ b/pkg/util/ssa.go @@ -0,0 +1,46 @@ +/* +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. +*/ + +package util + +import ( + "encoding/json" + + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// applyConfigPatch uses server-side apply to patch the object. +type applyConfigPatch struct { + applyConfig interface{} +} + +// Type implements Patch. +func (p applyConfigPatch) Type() types.PatchType { + return types.ApplyPatchType +} + +// Data implements Patch. +func (p applyConfigPatch) Data(_ client.Object) ([]byte, error) { + return json.Marshal(p.applyConfig) //nolint:wrapcheck +} + +// ApplyConfigPatch is a helper function for using applyConfigPatch. +func ApplyConfigPatch(applyConfig interface{}) client.Patch { + return &applyConfigPatch{ + applyConfig: applyConfig, + } +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/internal/internal.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/internal/internal.go new file mode 100644 index 000000000..d478ac7fe --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/internal/internal.go @@ -0,0 +1,956 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package internal + +import ( + "fmt" + "sync" + + typed "sigs.k8s.io/structured-merge-diff/v4/typed" +) + +func Parser() *typed.Parser { + parserOnce.Do(func() { + var err error + parser, err = typed.NewParser(schemaYAML) + if err != nil { + panic(fmt.Sprintf("Failed to parse schema: %v", err)) + } + }) + return parser +} + +var parserOnce sync.Once +var parser *typed.Parser +var schemaYAML = typed.YAMLObject(`types: +- name: com.github.openshift.api.machine.v1.AWSFailureDomain + map: + fields: + - name: placement + type: + namedType: com.github.openshift.api.machine.v1.AWSFailureDomainPlacement + default: {} + - name: subnet + type: + namedType: com.github.openshift.api.machine.v1.AWSResourceReference +- name: com.github.openshift.api.machine.v1.AWSFailureDomainPlacement + map: + fields: + - name: availabilityZone + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1.AWSResourceFilter + map: + fields: + - name: name + type: + scalar: string + default: "" + - name: values + type: + list: + elementType: + scalar: string + elementRelationship: atomic +- name: com.github.openshift.api.machine.v1.AWSResourceReference + map: + fields: + - name: arn + type: + scalar: string + - name: filters + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.AWSResourceFilter + elementRelationship: atomic + - name: id + type: + scalar: string + - name: type + type: + scalar: string + default: "" + unions: + - discriminator: type + fields: + - fieldName: arn + discriminatorValue: ARN + - fieldName: filters + discriminatorValue: Filters + - fieldName: id + discriminatorValue: ID +- name: com.github.openshift.api.machine.v1.AzureFailureDomain + map: + fields: + - name: subnet + type: + scalar: string + - name: zone + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1.ControlPlaneMachineSet + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.openshift.api.machine.v1.ControlPlaneMachineSetSpec + default: {} + - name: status + type: + namedType: com.github.openshift.api.machine.v1.ControlPlaneMachineSetStatus + default: {} +- name: com.github.openshift.api.machine.v1.ControlPlaneMachineSetSpec + map: + fields: + - name: replicas + type: + scalar: numeric + - name: selector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + default: {} + - name: state + type: + scalar: string + default: Inactive + - name: strategy + type: + namedType: com.github.openshift.api.machine.v1.ControlPlaneMachineSetStrategy + default: {} + - name: template + type: + namedType: com.github.openshift.api.machine.v1.ControlPlaneMachineSetTemplate + default: {} +- name: com.github.openshift.api.machine.v1.ControlPlaneMachineSetStatus + map: + fields: + - name: conditions + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Condition + elementRelationship: associative + keys: + - type + - name: observedGeneration + type: + scalar: numeric + - name: readyReplicas + type: + scalar: numeric + - name: replicas + type: + scalar: numeric + - name: unavailableReplicas + type: + scalar: numeric + - name: updatedReplicas + type: + scalar: numeric +- name: com.github.openshift.api.machine.v1.ControlPlaneMachineSetStrategy + map: + fields: + - name: type + type: + scalar: string + default: RollingUpdate +- name: com.github.openshift.api.machine.v1.ControlPlaneMachineSetTemplate + map: + fields: + - name: machineType + type: + scalar: string + - name: machines_v1beta1_machine_openshift_io + type: + namedType: com.github.openshift.api.machine.v1.OpenShiftMachineV1Beta1MachineTemplate + unions: + - discriminator: machineType + fields: + - fieldName: machines_v1beta1_machine_openshift_io + discriminatorValue: OpenShiftMachineV1Beta1Machine +- name: com.github.openshift.api.machine.v1.ControlPlaneMachineSetTemplateObjectMeta + map: + fields: + - name: annotations + type: + map: + elementType: + scalar: string + - name: labels + type: + map: + elementType: + scalar: string +- name: com.github.openshift.api.machine.v1.FailureDomains + map: + fields: + - name: aws + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.AWSFailureDomain + elementRelationship: atomic + - name: azure + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.AzureFailureDomain + elementRelationship: atomic + - name: gcp + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.GCPFailureDomain + elementRelationship: atomic + - name: nutanix + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.NutanixFailureDomainReference + elementRelationship: associative + keys: + - name + - name: openstack + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.OpenStackFailureDomain + elementRelationship: atomic + - name: platform + type: + scalar: string + default: "" + - name: vsphere + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1.VSphereFailureDomain + elementRelationship: associative + keys: + - name + unions: + - discriminator: platform + fields: + - fieldName: aws + discriminatorValue: AWS + - fieldName: azure + discriminatorValue: Azure + - fieldName: gcp + discriminatorValue: GCP + - fieldName: nutanix + discriminatorValue: Nutanix + - fieldName: openstack + discriminatorValue: OpenStack + - fieldName: vsphere + discriminatorValue: VSphere +- name: com.github.openshift.api.machine.v1.GCPFailureDomain + map: + fields: + - name: zone + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1.NutanixFailureDomainReference + map: + fields: + - name: name + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1.OpenShiftMachineV1Beta1MachineTemplate + map: + fields: + - name: failureDomains + type: + namedType: com.github.openshift.api.machine.v1.FailureDomains + - name: metadata + type: + namedType: com.github.openshift.api.machine.v1.ControlPlaneMachineSetTemplateObjectMeta + default: {} + - name: spec + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineSpec + default: {} +- name: com.github.openshift.api.machine.v1.OpenStackFailureDomain + map: + fields: + - name: availabilityZone + type: + scalar: string + - name: rootVolume + type: + namedType: com.github.openshift.api.machine.v1.RootVolume +- name: com.github.openshift.api.machine.v1.RootVolume + map: + fields: + - name: availabilityZone + type: + scalar: string + - name: volumeType + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1.VSphereFailureDomain + map: + fields: + - name: name + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1beta1.Condition + map: + fields: + - name: lastTransitionTime + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: message + type: + scalar: string + - name: reason + type: + scalar: string + - name: severity + type: + scalar: string + - name: status + type: + scalar: string + default: "" + - name: type + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1beta1.LastOperation + map: + fields: + - name: description + type: + scalar: string + - name: lastUpdated + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: state + type: + scalar: string + - name: type + type: + scalar: string +- name: com.github.openshift.api.machine.v1beta1.LifecycleHook + map: + fields: + - name: name + type: + scalar: string + default: "" + - name: owner + type: + scalar: string + default: "" +- name: com.github.openshift.api.machine.v1beta1.LifecycleHooks + map: + fields: + - name: preDrain + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1beta1.LifecycleHook + elementRelationship: associative + keys: + - name + - name: preTerminate + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1beta1.LifecycleHook + elementRelationship: associative + keys: + - name +- name: com.github.openshift.api.machine.v1beta1.Machine + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineSpec + default: {} + - name: status + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineStatus + default: {} +- name: com.github.openshift.api.machine.v1beta1.MachineHealthCheck + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineHealthCheckSpec + default: {} + - name: status + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineHealthCheckStatus + default: {} +- name: com.github.openshift.api.machine.v1beta1.MachineHealthCheckSpec + map: + fields: + - name: maxUnhealthy + type: + namedType: io.k8s.apimachinery.pkg.util.intstr.IntOrString + - name: nodeStartupTimeout + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Duration + - name: remediationTemplate + type: + namedType: io.k8s.api.core.v1.ObjectReference + - name: selector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + default: {} + - name: unhealthyConditions + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1beta1.UnhealthyCondition + elementRelationship: atomic +- name: com.github.openshift.api.machine.v1beta1.MachineHealthCheckStatus + map: + fields: + - name: conditions + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1beta1.Condition + elementRelationship: associative + keys: + - type + - name: currentHealthy + type: + scalar: numeric + - name: expectedMachines + type: + scalar: numeric + - name: remediationsAllowed + type: + scalar: numeric + default: 0 +- name: com.github.openshift.api.machine.v1beta1.MachineSet + map: + fields: + - name: apiVersion + type: + scalar: string + - name: kind + type: + scalar: string + - name: metadata + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineSetSpec + default: {} + - name: status + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineSetStatus + default: {} +- name: com.github.openshift.api.machine.v1beta1.MachineSetSpec + map: + fields: + - name: authoritativeAPI + type: + scalar: string + default: MachineAPI + - name: deletePolicy + type: + scalar: string + - name: minReadySeconds + type: + scalar: numeric + - name: replicas + type: + scalar: numeric + - name: selector + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + default: {} + - name: template + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineTemplateSpec + default: {} +- name: com.github.openshift.api.machine.v1beta1.MachineSetStatus + map: + fields: + - name: authoritativeAPI + type: + scalar: string + - name: availableReplicas + type: + scalar: numeric + - name: conditions + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1beta1.Condition + elementRelationship: associative + keys: + - type + - name: errorMessage + type: + scalar: string + - name: errorReason + type: + scalar: string + - name: fullyLabeledReplicas + type: + scalar: numeric + - name: observedGeneration + type: + scalar: numeric + - name: readyReplicas + type: + scalar: numeric + - name: replicas + type: + scalar: numeric + default: 0 + - name: synchronizedGeneration + type: + scalar: numeric +- name: com.github.openshift.api.machine.v1beta1.MachineSpec + map: + fields: + - name: authoritativeAPI + type: + scalar: string + default: MachineAPI + - name: lifecycleHooks + type: + namedType: com.github.openshift.api.machine.v1beta1.LifecycleHooks + default: {} + - name: metadata + type: + namedType: com.github.openshift.api.machine.v1beta1.ObjectMeta + default: {} + - name: providerID + type: + scalar: string + - name: providerSpec + type: + namedType: com.github.openshift.api.machine.v1beta1.ProviderSpec + default: {} + - name: taints + type: + list: + elementType: + namedType: io.k8s.api.core.v1.Taint + elementRelationship: atomic +- name: com.github.openshift.api.machine.v1beta1.MachineStatus + map: + fields: + - name: addresses + type: + list: + elementType: + namedType: io.k8s.api.core.v1.NodeAddress + elementRelationship: atomic + - name: authoritativeAPI + type: + scalar: string + - name: conditions + type: + list: + elementType: + namedType: com.github.openshift.api.machine.v1beta1.Condition + elementRelationship: associative + keys: + - type + - name: errorMessage + type: + scalar: string + - name: errorReason + type: + scalar: string + - name: lastOperation + type: + namedType: com.github.openshift.api.machine.v1beta1.LastOperation + - name: lastUpdated + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: nodeRef + type: + namedType: io.k8s.api.core.v1.ObjectReference + - name: phase + type: + scalar: string + - name: providerStatus + type: + namedType: __untyped_atomic_ + - name: synchronizedGeneration + type: + scalar: numeric +- name: com.github.openshift.api.machine.v1beta1.MachineTemplateSpec + map: + fields: + - name: metadata + type: + namedType: com.github.openshift.api.machine.v1beta1.ObjectMeta + default: {} + - name: spec + type: + namedType: com.github.openshift.api.machine.v1beta1.MachineSpec + default: {} +- name: com.github.openshift.api.machine.v1beta1.ObjectMeta + map: + fields: + - name: annotations + type: + map: + elementType: + scalar: string + - name: generateName + type: + scalar: string + - name: labels + type: + map: + elementType: + scalar: string + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: ownerReferences + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + elementRelationship: associative + keys: + - uid +- name: com.github.openshift.api.machine.v1beta1.ProviderSpec + map: + fields: + - name: value + type: + namedType: __untyped_atomic_ +- name: com.github.openshift.api.machine.v1beta1.UnhealthyCondition + map: + fields: + - name: status + type: + scalar: string + default: "" + - name: timeout + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Duration + - name: type + type: + scalar: string + default: "" +- name: io.k8s.api.core.v1.NodeAddress + map: + fields: + - name: address + type: + scalar: string + default: "" + - name: type + type: + scalar: string + default: "" +- name: io.k8s.api.core.v1.ObjectReference + map: + fields: + - name: apiVersion + type: + scalar: string + - name: fieldPath + type: + scalar: string + - name: kind + type: + scalar: string + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: resourceVersion + type: + scalar: string + - name: uid + type: + scalar: string + elementRelationship: atomic +- name: io.k8s.api.core.v1.Taint + map: + fields: + - name: effect + type: + scalar: string + default: "" + - name: key + type: + scalar: string + default: "" + - name: timeAdded + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: value + type: + scalar: string +- name: io.k8s.apimachinery.pkg.apis.meta.v1.Condition + map: + fields: + - name: lastTransitionTime + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: message + type: + scalar: string + default: "" + - name: observedGeneration + type: + scalar: numeric + - name: reason + type: + scalar: string + default: "" + - name: status + type: + scalar: string + default: "" + - name: type + type: + scalar: string + default: "" +- name: io.k8s.apimachinery.pkg.apis.meta.v1.Duration + scalar: string +- name: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector + map: + fields: + - name: matchExpressions + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement + elementRelationship: atomic + - name: matchLabels + type: + map: + elementType: + scalar: string + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement + map: + fields: + - name: key + type: + scalar: string + default: "" + - name: operator + type: + scalar: string + default: "" + - name: values + type: + list: + elementType: + scalar: string + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + map: + fields: + - name: apiVersion + type: + scalar: string + - name: fieldsType + type: + scalar: string + - name: fieldsV1 + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.FieldsV1 + - name: manager + type: + scalar: string + - name: operation + type: + scalar: string + - name: subresource + type: + scalar: string + - name: time + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time +- name: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta + map: + fields: + - name: annotations + type: + map: + elementType: + scalar: string + - name: creationTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: deletionGracePeriodSeconds + type: + scalar: numeric + - name: deletionTimestamp + type: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.Time + - name: finalizers + type: + list: + elementType: + scalar: string + elementRelationship: associative + - name: generateName + type: + scalar: string + - name: generation + type: + scalar: numeric + - name: labels + type: + map: + elementType: + scalar: string + - name: managedFields + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ManagedFieldsEntry + elementRelationship: atomic + - name: name + type: + scalar: string + - name: namespace + type: + scalar: string + - name: ownerReferences + type: + list: + elementType: + namedType: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + elementRelationship: associative + keys: + - uid + - name: resourceVersion + type: + scalar: string + - name: selfLink + type: + scalar: string + - name: uid + type: + scalar: string +- name: io.k8s.apimachinery.pkg.apis.meta.v1.OwnerReference + map: + fields: + - name: apiVersion + type: + scalar: string + default: "" + - name: blockOwnerDeletion + type: + scalar: boolean + - name: controller + type: + scalar: boolean + - name: kind + type: + scalar: string + default: "" + - name: name + type: + scalar: string + default: "" + - name: uid + type: + scalar: string + default: "" + elementRelationship: atomic +- name: io.k8s.apimachinery.pkg.apis.meta.v1.Time + scalar: untyped +- name: io.k8s.apimachinery.pkg.runtime.RawExtension + map: + elementType: + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +- name: io.k8s.apimachinery.pkg.util.intstr.IntOrString + scalar: untyped +- name: __untyped_atomic_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic +- name: __untyped_deduced_ + scalar: untyped + list: + elementType: + namedType: __untyped_atomic_ + elementRelationship: atomic + map: + elementType: + namedType: __untyped_deduced_ + elementRelationship: separable +`) diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/condition.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/condition.go new file mode 100644 index 000000000..49e898dcb --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/condition.go @@ -0,0 +1,74 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/openshift/api/machine/v1beta1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// ConditionApplyConfiguration represents a declarative configuration of the Condition type for use +// with apply. +type ConditionApplyConfiguration struct { + Type *v1beta1.ConditionType `json:"type,omitempty"` + Status *v1.ConditionStatus `json:"status,omitempty"` + Severity *v1beta1.ConditionSeverity `json:"severity,omitempty"` + LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` + Reason *string `json:"reason,omitempty"` + Message *string `json:"message,omitempty"` +} + +// ConditionApplyConfiguration constructs a declarative configuration of the Condition type for use with +// apply. +func Condition() *ConditionApplyConfiguration { + return &ConditionApplyConfiguration{} +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *ConditionApplyConfiguration) WithType(value v1beta1.ConditionType) *ConditionApplyConfiguration { + b.Type = &value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *ConditionApplyConfiguration) WithStatus(value v1.ConditionStatus) *ConditionApplyConfiguration { + b.Status = &value + return b +} + +// WithSeverity sets the Severity field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Severity field is set to the value of the last call. +func (b *ConditionApplyConfiguration) WithSeverity(value v1beta1.ConditionSeverity) *ConditionApplyConfiguration { + b.Severity = &value + return b +} + +// WithLastTransitionTime sets the LastTransitionTime field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastTransitionTime field is set to the value of the last call. +func (b *ConditionApplyConfiguration) WithLastTransitionTime(value metav1.Time) *ConditionApplyConfiguration { + b.LastTransitionTime = &value + return b +} + +// WithReason sets the Reason field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Reason field is set to the value of the last call. +func (b *ConditionApplyConfiguration) WithReason(value string) *ConditionApplyConfiguration { + b.Reason = &value + return b +} + +// WithMessage sets the Message field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Message field is set to the value of the last call. +func (b *ConditionApplyConfiguration) WithMessage(value string) *ConditionApplyConfiguration { + b.Message = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lastoperation.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lastoperation.go new file mode 100644 index 000000000..881220157 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lastoperation.go @@ -0,0 +1,54 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// LastOperationApplyConfiguration represents a declarative configuration of the LastOperation type for use +// with apply. +type LastOperationApplyConfiguration struct { + Description *string `json:"description,omitempty"` + LastUpdated *v1.Time `json:"lastUpdated,omitempty"` + State *string `json:"state,omitempty"` + Type *string `json:"type,omitempty"` +} + +// LastOperationApplyConfiguration constructs a declarative configuration of the LastOperation type for use with +// apply. +func LastOperation() *LastOperationApplyConfiguration { + return &LastOperationApplyConfiguration{} +} + +// WithDescription sets the Description field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Description field is set to the value of the last call. +func (b *LastOperationApplyConfiguration) WithDescription(value string) *LastOperationApplyConfiguration { + b.Description = &value + return b +} + +// WithLastUpdated sets the LastUpdated field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastUpdated field is set to the value of the last call. +func (b *LastOperationApplyConfiguration) WithLastUpdated(value v1.Time) *LastOperationApplyConfiguration { + b.LastUpdated = &value + return b +} + +// WithState sets the State field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the State field is set to the value of the last call. +func (b *LastOperationApplyConfiguration) WithState(value string) *LastOperationApplyConfiguration { + b.State = &value + return b +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *LastOperationApplyConfiguration) WithType(value string) *LastOperationApplyConfiguration { + b.Type = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehook.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehook.go new file mode 100644 index 000000000..3618a1393 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehook.go @@ -0,0 +1,32 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// LifecycleHookApplyConfiguration represents a declarative configuration of the LifecycleHook type for use +// with apply. +type LifecycleHookApplyConfiguration struct { + Name *string `json:"name,omitempty"` + Owner *string `json:"owner,omitempty"` +} + +// LifecycleHookApplyConfiguration constructs a declarative configuration of the LifecycleHook type for use with +// apply. +func LifecycleHook() *LifecycleHookApplyConfiguration { + return &LifecycleHookApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *LifecycleHookApplyConfiguration) WithName(value string) *LifecycleHookApplyConfiguration { + b.Name = &value + return b +} + +// WithOwner sets the Owner field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Owner field is set to the value of the last call. +func (b *LifecycleHookApplyConfiguration) WithOwner(value string) *LifecycleHookApplyConfiguration { + b.Owner = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehooks.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehooks.go new file mode 100644 index 000000000..840ec2f91 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/lifecyclehooks.go @@ -0,0 +1,42 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// LifecycleHooksApplyConfiguration represents a declarative configuration of the LifecycleHooks type for use +// with apply. +type LifecycleHooksApplyConfiguration struct { + PreDrain []LifecycleHookApplyConfiguration `json:"preDrain,omitempty"` + PreTerminate []LifecycleHookApplyConfiguration `json:"preTerminate,omitempty"` +} + +// LifecycleHooksApplyConfiguration constructs a declarative configuration of the LifecycleHooks type for use with +// apply. +func LifecycleHooks() *LifecycleHooksApplyConfiguration { + return &LifecycleHooksApplyConfiguration{} +} + +// WithPreDrain adds the given value to the PreDrain field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the PreDrain field. +func (b *LifecycleHooksApplyConfiguration) WithPreDrain(values ...*LifecycleHookApplyConfiguration) *LifecycleHooksApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPreDrain") + } + b.PreDrain = append(b.PreDrain, *values[i]) + } + return b +} + +// WithPreTerminate adds the given value to the PreTerminate field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the PreTerminate field. +func (b *LifecycleHooksApplyConfiguration) WithPreTerminate(values ...*LifecycleHookApplyConfiguration) *LifecycleHooksApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithPreTerminate") + } + b.PreTerminate = append(b.PreTerminate, *values[i]) + } + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machine.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machine.go new file mode 100644 index 000000000..4ac6311a3 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machine.go @@ -0,0 +1,248 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + machinev1beta1 "github.com/openshift/api/machine/v1beta1" + internal "github.com/openshift/client-go/machine/applyconfigurations/internal" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineApplyConfiguration represents a declarative configuration of the Machine type for use +// with apply. +type MachineApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *MachineSpecApplyConfiguration `json:"spec,omitempty"` + Status *MachineStatusApplyConfiguration `json:"status,omitempty"` +} + +// Machine constructs a declarative configuration of the Machine type for use with +// apply. +func Machine(name, namespace string) *MachineApplyConfiguration { + b := &MachineApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Machine") + b.WithAPIVersion("machine.openshift.io/v1beta1") + return b +} + +// ExtractMachine extracts the applied configuration owned by fieldManager from +// machine. If no managedFields are found in machine for fieldManager, a +// MachineApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// machine must be a unmodified Machine API object that was retrieved from the Kubernetes API. +// ExtractMachine provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractMachine(machine *machinev1beta1.Machine, fieldManager string) (*MachineApplyConfiguration, error) { + return extractMachine(machine, fieldManager, "") +} + +// ExtractMachineStatus is the same as ExtractMachine except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractMachineStatus(machine *machinev1beta1.Machine, fieldManager string) (*MachineApplyConfiguration, error) { + return extractMachine(machine, fieldManager, "status") +} + +func extractMachine(machine *machinev1beta1.Machine, fieldManager string, subresource string) (*MachineApplyConfiguration, error) { + b := &MachineApplyConfiguration{} + err := managedfields.ExtractInto(machine, internal.Parser().Type("com.github.openshift.api.machine.v1beta1.Machine"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(machine.Name) + b.WithNamespace(machine.Namespace) + + b.WithKind("Machine") + b.WithAPIVersion("machine.openshift.io/v1beta1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithKind(value string) *MachineApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithAPIVersion(value string) *MachineApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithName(value string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithGenerateName(value string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithNamespace(value string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithUID(value types.UID) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithResourceVersion(value string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithGeneration(value int64) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithCreationTimestamp(value metav1.Time) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *MachineApplyConfiguration) WithLabels(entries map[string]string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *MachineApplyConfiguration) WithAnnotations(entries map[string]string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *MachineApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *MachineApplyConfiguration) WithFinalizers(values ...string) *MachineApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *MachineApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithSpec(value *MachineSpecApplyConfiguration) *MachineApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *MachineApplyConfiguration) WithStatus(value *MachineStatusApplyConfiguration) *MachineApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *MachineApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheck.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheck.go new file mode 100644 index 000000000..f81b469ee --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheck.go @@ -0,0 +1,248 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + machinev1beta1 "github.com/openshift/api/machine/v1beta1" + internal "github.com/openshift/client-go/machine/applyconfigurations/internal" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineHealthCheckApplyConfiguration represents a declarative configuration of the MachineHealthCheck type for use +// with apply. +type MachineHealthCheckApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *MachineHealthCheckSpecApplyConfiguration `json:"spec,omitempty"` + Status *MachineHealthCheckStatusApplyConfiguration `json:"status,omitempty"` +} + +// MachineHealthCheck constructs a declarative configuration of the MachineHealthCheck type for use with +// apply. +func MachineHealthCheck(name, namespace string) *MachineHealthCheckApplyConfiguration { + b := &MachineHealthCheckApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("MachineHealthCheck") + b.WithAPIVersion("machine.openshift.io/v1beta1") + return b +} + +// ExtractMachineHealthCheck extracts the applied configuration owned by fieldManager from +// machineHealthCheck. If no managedFields are found in machineHealthCheck for fieldManager, a +// MachineHealthCheckApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// machineHealthCheck must be a unmodified MachineHealthCheck API object that was retrieved from the Kubernetes API. +// ExtractMachineHealthCheck provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractMachineHealthCheck(machineHealthCheck *machinev1beta1.MachineHealthCheck, fieldManager string) (*MachineHealthCheckApplyConfiguration, error) { + return extractMachineHealthCheck(machineHealthCheck, fieldManager, "") +} + +// ExtractMachineHealthCheckStatus is the same as ExtractMachineHealthCheck except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractMachineHealthCheckStatus(machineHealthCheck *machinev1beta1.MachineHealthCheck, fieldManager string) (*MachineHealthCheckApplyConfiguration, error) { + return extractMachineHealthCheck(machineHealthCheck, fieldManager, "status") +} + +func extractMachineHealthCheck(machineHealthCheck *machinev1beta1.MachineHealthCheck, fieldManager string, subresource string) (*MachineHealthCheckApplyConfiguration, error) { + b := &MachineHealthCheckApplyConfiguration{} + err := managedfields.ExtractInto(machineHealthCheck, internal.Parser().Type("com.github.openshift.api.machine.v1beta1.MachineHealthCheck"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(machineHealthCheck.Name) + b.WithNamespace(machineHealthCheck.Namespace) + + b.WithKind("MachineHealthCheck") + b.WithAPIVersion("machine.openshift.io/v1beta1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithKind(value string) *MachineHealthCheckApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithAPIVersion(value string) *MachineHealthCheckApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithName(value string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithGenerateName(value string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithNamespace(value string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithUID(value types.UID) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithResourceVersion(value string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithGeneration(value int64) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithCreationTimestamp(value metav1.Time) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *MachineHealthCheckApplyConfiguration) WithLabels(entries map[string]string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *MachineHealthCheckApplyConfiguration) WithAnnotations(entries map[string]string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *MachineHealthCheckApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *MachineHealthCheckApplyConfiguration) WithFinalizers(values ...string) *MachineHealthCheckApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *MachineHealthCheckApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithSpec(value *MachineHealthCheckSpecApplyConfiguration) *MachineHealthCheckApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *MachineHealthCheckApplyConfiguration) WithStatus(value *MachineHealthCheckStatusApplyConfiguration) *MachineHealthCheckApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *MachineHealthCheckApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckspec.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckspec.go new file mode 100644 index 000000000..0cd81dfb0 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckspec.go @@ -0,0 +1,71 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + intstr "k8s.io/apimachinery/pkg/util/intstr" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineHealthCheckSpecApplyConfiguration represents a declarative configuration of the MachineHealthCheckSpec type for use +// with apply. +type MachineHealthCheckSpecApplyConfiguration struct { + Selector *v1.LabelSelectorApplyConfiguration `json:"selector,omitempty"` + UnhealthyConditions []UnhealthyConditionApplyConfiguration `json:"unhealthyConditions,omitempty"` + MaxUnhealthy *intstr.IntOrString `json:"maxUnhealthy,omitempty"` + NodeStartupTimeout *metav1.Duration `json:"nodeStartupTimeout,omitempty"` + RemediationTemplate *corev1.ObjectReference `json:"remediationTemplate,omitempty"` +} + +// MachineHealthCheckSpecApplyConfiguration constructs a declarative configuration of the MachineHealthCheckSpec type for use with +// apply. +func MachineHealthCheckSpec() *MachineHealthCheckSpecApplyConfiguration { + return &MachineHealthCheckSpecApplyConfiguration{} +} + +// WithSelector sets the Selector field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Selector field is set to the value of the last call. +func (b *MachineHealthCheckSpecApplyConfiguration) WithSelector(value *v1.LabelSelectorApplyConfiguration) *MachineHealthCheckSpecApplyConfiguration { + b.Selector = value + return b +} + +// WithUnhealthyConditions adds the given value to the UnhealthyConditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the UnhealthyConditions field. +func (b *MachineHealthCheckSpecApplyConfiguration) WithUnhealthyConditions(values ...*UnhealthyConditionApplyConfiguration) *MachineHealthCheckSpecApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithUnhealthyConditions") + } + b.UnhealthyConditions = append(b.UnhealthyConditions, *values[i]) + } + return b +} + +// WithMaxUnhealthy sets the MaxUnhealthy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MaxUnhealthy field is set to the value of the last call. +func (b *MachineHealthCheckSpecApplyConfiguration) WithMaxUnhealthy(value intstr.IntOrString) *MachineHealthCheckSpecApplyConfiguration { + b.MaxUnhealthy = &value + return b +} + +// WithNodeStartupTimeout sets the NodeStartupTimeout field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeStartupTimeout field is set to the value of the last call. +func (b *MachineHealthCheckSpecApplyConfiguration) WithNodeStartupTimeout(value metav1.Duration) *MachineHealthCheckSpecApplyConfiguration { + b.NodeStartupTimeout = &value + return b +} + +// WithRemediationTemplate sets the RemediationTemplate field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RemediationTemplate field is set to the value of the last call. +func (b *MachineHealthCheckSpecApplyConfiguration) WithRemediationTemplate(value corev1.ObjectReference) *MachineHealthCheckSpecApplyConfiguration { + b.RemediationTemplate = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckstatus.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckstatus.go new file mode 100644 index 000000000..032b47496 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinehealthcheckstatus.go @@ -0,0 +1,55 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +// MachineHealthCheckStatusApplyConfiguration represents a declarative configuration of the MachineHealthCheckStatus type for use +// with apply. +type MachineHealthCheckStatusApplyConfiguration struct { + ExpectedMachines *int `json:"expectedMachines,omitempty"` + CurrentHealthy *int `json:"currentHealthy,omitempty"` + RemediationsAllowed *int32 `json:"remediationsAllowed,omitempty"` + Conditions []ConditionApplyConfiguration `json:"conditions,omitempty"` +} + +// MachineHealthCheckStatusApplyConfiguration constructs a declarative configuration of the MachineHealthCheckStatus type for use with +// apply. +func MachineHealthCheckStatus() *MachineHealthCheckStatusApplyConfiguration { + return &MachineHealthCheckStatusApplyConfiguration{} +} + +// WithExpectedMachines sets the ExpectedMachines field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ExpectedMachines field is set to the value of the last call. +func (b *MachineHealthCheckStatusApplyConfiguration) WithExpectedMachines(value int) *MachineHealthCheckStatusApplyConfiguration { + b.ExpectedMachines = &value + return b +} + +// WithCurrentHealthy sets the CurrentHealthy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CurrentHealthy field is set to the value of the last call. +func (b *MachineHealthCheckStatusApplyConfiguration) WithCurrentHealthy(value int) *MachineHealthCheckStatusApplyConfiguration { + b.CurrentHealthy = &value + return b +} + +// WithRemediationsAllowed sets the RemediationsAllowed field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the RemediationsAllowed field is set to the value of the last call. +func (b *MachineHealthCheckStatusApplyConfiguration) WithRemediationsAllowed(value int32) *MachineHealthCheckStatusApplyConfiguration { + b.RemediationsAllowed = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *MachineHealthCheckStatusApplyConfiguration) WithConditions(values ...*ConditionApplyConfiguration) *MachineHealthCheckStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machineset.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machineset.go new file mode 100644 index 000000000..ffbda1369 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machineset.go @@ -0,0 +1,248 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + machinev1beta1 "github.com/openshift/api/machine/v1beta1" + internal "github.com/openshift/client-go/machine/applyconfigurations/internal" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineSetApplyConfiguration represents a declarative configuration of the MachineSet type for use +// with apply. +type MachineSetApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *MachineSetSpecApplyConfiguration `json:"spec,omitempty"` + Status *MachineSetStatusApplyConfiguration `json:"status,omitempty"` +} + +// MachineSet constructs a declarative configuration of the MachineSet type for use with +// apply. +func MachineSet(name, namespace string) *MachineSetApplyConfiguration { + b := &MachineSetApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("MachineSet") + b.WithAPIVersion("machine.openshift.io/v1beta1") + return b +} + +// ExtractMachineSet extracts the applied configuration owned by fieldManager from +// machineSet. If no managedFields are found in machineSet for fieldManager, a +// MachineSetApplyConfiguration is returned with only the Name, Namespace (if applicable), +// APIVersion and Kind populated. It is possible that no managed fields were found for because other +// field managers have taken ownership of all the fields previously owned by fieldManager, or because +// the fieldManager never owned fields any fields. +// machineSet must be a unmodified MachineSet API object that was retrieved from the Kubernetes API. +// ExtractMachineSet provides a way to perform a extract/modify-in-place/apply workflow. +// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously +// applied if another fieldManager has updated or force applied any of the previously applied fields. +// Experimental! +func ExtractMachineSet(machineSet *machinev1beta1.MachineSet, fieldManager string) (*MachineSetApplyConfiguration, error) { + return extractMachineSet(machineSet, fieldManager, "") +} + +// ExtractMachineSetStatus is the same as ExtractMachineSet except +// that it extracts the status subresource applied configuration. +// Experimental! +func ExtractMachineSetStatus(machineSet *machinev1beta1.MachineSet, fieldManager string) (*MachineSetApplyConfiguration, error) { + return extractMachineSet(machineSet, fieldManager, "status") +} + +func extractMachineSet(machineSet *machinev1beta1.MachineSet, fieldManager string, subresource string) (*MachineSetApplyConfiguration, error) { + b := &MachineSetApplyConfiguration{} + err := managedfields.ExtractInto(machineSet, internal.Parser().Type("com.github.openshift.api.machine.v1beta1.MachineSet"), fieldManager, b, subresource) + if err != nil { + return nil, err + } + b.WithName(machineSet.Name) + b.WithNamespace(machineSet.Namespace) + + b.WithKind("MachineSet") + b.WithAPIVersion("machine.openshift.io/v1beta1") + return b, nil +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithKind(value string) *MachineSetApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithAPIVersion(value string) *MachineSetApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithName(value string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithGenerateName(value string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithNamespace(value string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithUID(value types.UID) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithResourceVersion(value string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithGeneration(value int64) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithCreationTimestamp(value metav1.Time) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *MachineSetApplyConfiguration) WithLabels(entries map[string]string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *MachineSetApplyConfiguration) WithAnnotations(entries map[string]string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *MachineSetApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *MachineSetApplyConfiguration) WithFinalizers(values ...string) *MachineSetApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *MachineSetApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithSpec(value *MachineSetSpecApplyConfiguration) *MachineSetApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *MachineSetApplyConfiguration) WithStatus(value *MachineSetStatusApplyConfiguration) *MachineSetApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *MachineSetApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetspec.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetspec.go new file mode 100644 index 000000000..3813fddb8 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetspec.go @@ -0,0 +1,73 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + machinev1beta1 "github.com/openshift/api/machine/v1beta1" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineSetSpecApplyConfiguration represents a declarative configuration of the MachineSetSpec type for use +// with apply. +type MachineSetSpecApplyConfiguration struct { + Replicas *int32 `json:"replicas,omitempty"` + MinReadySeconds *int32 `json:"minReadySeconds,omitempty"` + DeletePolicy *string `json:"deletePolicy,omitempty"` + Selector *v1.LabelSelectorApplyConfiguration `json:"selector,omitempty"` + Template *MachineTemplateSpecApplyConfiguration `json:"template,omitempty"` + AuthoritativeAPI *machinev1beta1.MachineAuthority `json:"authoritativeAPI,omitempty"` +} + +// MachineSetSpecApplyConfiguration constructs a declarative configuration of the MachineSetSpec type for use with +// apply. +func MachineSetSpec() *MachineSetSpecApplyConfiguration { + return &MachineSetSpecApplyConfiguration{} +} + +// WithReplicas sets the Replicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Replicas field is set to the value of the last call. +func (b *MachineSetSpecApplyConfiguration) WithReplicas(value int32) *MachineSetSpecApplyConfiguration { + b.Replicas = &value + return b +} + +// WithMinReadySeconds sets the MinReadySeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the MinReadySeconds field is set to the value of the last call. +func (b *MachineSetSpecApplyConfiguration) WithMinReadySeconds(value int32) *MachineSetSpecApplyConfiguration { + b.MinReadySeconds = &value + return b +} + +// WithDeletePolicy sets the DeletePolicy field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletePolicy field is set to the value of the last call. +func (b *MachineSetSpecApplyConfiguration) WithDeletePolicy(value string) *MachineSetSpecApplyConfiguration { + b.DeletePolicy = &value + return b +} + +// WithSelector sets the Selector field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Selector field is set to the value of the last call. +func (b *MachineSetSpecApplyConfiguration) WithSelector(value *v1.LabelSelectorApplyConfiguration) *MachineSetSpecApplyConfiguration { + b.Selector = value + return b +} + +// WithTemplate sets the Template field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Template field is set to the value of the last call. +func (b *MachineSetSpecApplyConfiguration) WithTemplate(value *MachineTemplateSpecApplyConfiguration) *MachineSetSpecApplyConfiguration { + b.Template = value + return b +} + +// WithAuthoritativeAPI sets the AuthoritativeAPI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthoritativeAPI field is set to the value of the last call. +func (b *MachineSetSpecApplyConfiguration) WithAuthoritativeAPI(value machinev1beta1.MachineAuthority) *MachineSetSpecApplyConfiguration { + b.AuthoritativeAPI = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetstatus.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetstatus.go new file mode 100644 index 000000000..11cf9bb14 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetstatus.go @@ -0,0 +1,113 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/openshift/api/machine/v1beta1" +) + +// MachineSetStatusApplyConfiguration represents a declarative configuration of the MachineSetStatus type for use +// with apply. +type MachineSetStatusApplyConfiguration struct { + Replicas *int32 `json:"replicas,omitempty"` + FullyLabeledReplicas *int32 `json:"fullyLabeledReplicas,omitempty"` + ReadyReplicas *int32 `json:"readyReplicas,omitempty"` + AvailableReplicas *int32 `json:"availableReplicas,omitempty"` + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + ErrorReason *v1beta1.MachineSetStatusError `json:"errorReason,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Conditions []ConditionApplyConfiguration `json:"conditions,omitempty"` + AuthoritativeAPI *v1beta1.MachineAuthority `json:"authoritativeAPI,omitempty"` + SynchronizedGeneration *int64 `json:"synchronizedGeneration,omitempty"` +} + +// MachineSetStatusApplyConfiguration constructs a declarative configuration of the MachineSetStatus type for use with +// apply. +func MachineSetStatus() *MachineSetStatusApplyConfiguration { + return &MachineSetStatusApplyConfiguration{} +} + +// WithReplicas sets the Replicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Replicas field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithReplicas(value int32) *MachineSetStatusApplyConfiguration { + b.Replicas = &value + return b +} + +// WithFullyLabeledReplicas sets the FullyLabeledReplicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the FullyLabeledReplicas field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithFullyLabeledReplicas(value int32) *MachineSetStatusApplyConfiguration { + b.FullyLabeledReplicas = &value + return b +} + +// WithReadyReplicas sets the ReadyReplicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ReadyReplicas field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithReadyReplicas(value int32) *MachineSetStatusApplyConfiguration { + b.ReadyReplicas = &value + return b +} + +// WithAvailableReplicas sets the AvailableReplicas field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AvailableReplicas field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithAvailableReplicas(value int32) *MachineSetStatusApplyConfiguration { + b.AvailableReplicas = &value + return b +} + +// WithObservedGeneration sets the ObservedGeneration field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ObservedGeneration field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithObservedGeneration(value int64) *MachineSetStatusApplyConfiguration { + b.ObservedGeneration = &value + return b +} + +// WithErrorReason sets the ErrorReason field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorReason field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithErrorReason(value v1beta1.MachineSetStatusError) *MachineSetStatusApplyConfiguration { + b.ErrorReason = &value + return b +} + +// WithErrorMessage sets the ErrorMessage field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorMessage field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithErrorMessage(value string) *MachineSetStatusApplyConfiguration { + b.ErrorMessage = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *MachineSetStatusApplyConfiguration) WithConditions(values ...*ConditionApplyConfiguration) *MachineSetStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} + +// WithAuthoritativeAPI sets the AuthoritativeAPI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthoritativeAPI field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithAuthoritativeAPI(value v1beta1.MachineAuthority) *MachineSetStatusApplyConfiguration { + b.AuthoritativeAPI = &value + return b +} + +// WithSynchronizedGeneration sets the SynchronizedGeneration field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SynchronizedGeneration field is set to the value of the last call. +func (b *MachineSetStatusApplyConfiguration) WithSynchronizedGeneration(value int64) *MachineSetStatusApplyConfiguration { + b.SynchronizedGeneration = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinespec.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinespec.go new file mode 100644 index 000000000..25e742c58 --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinespec.go @@ -0,0 +1,145 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + machinev1beta1 "github.com/openshift/api/machine/v1beta1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineSpecApplyConfiguration represents a declarative configuration of the MachineSpec type for use +// with apply. +type MachineSpecApplyConfiguration struct { + *ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + LifecycleHooks *LifecycleHooksApplyConfiguration `json:"lifecycleHooks,omitempty"` + Taints []v1.Taint `json:"taints,omitempty"` + ProviderSpec *ProviderSpecApplyConfiguration `json:"providerSpec,omitempty"` + ProviderID *string `json:"providerID,omitempty"` + AuthoritativeAPI *machinev1beta1.MachineAuthority `json:"authoritativeAPI,omitempty"` +} + +// MachineSpecApplyConfiguration constructs a declarative configuration of the MachineSpec type for use with +// apply. +func MachineSpec() *MachineSpecApplyConfiguration { + return &MachineSpecApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithName(value string) *MachineSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithGenerateName(value string) *MachineSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithNamespace(value string) *MachineSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *MachineSpecApplyConfiguration) WithLabels(entries map[string]string) *MachineSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *MachineSpecApplyConfiguration) WithAnnotations(entries map[string]string) *MachineSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *MachineSpecApplyConfiguration) WithOwnerReferences(values ...*metav1.OwnerReferenceApplyConfiguration) *MachineSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +func (b *MachineSpecApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &ObjectMetaApplyConfiguration{} + } +} + +// WithLifecycleHooks sets the LifecycleHooks field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LifecycleHooks field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithLifecycleHooks(value *LifecycleHooksApplyConfiguration) *MachineSpecApplyConfiguration { + b.LifecycleHooks = value + return b +} + +// WithTaints adds the given value to the Taints field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Taints field. +func (b *MachineSpecApplyConfiguration) WithTaints(values ...v1.Taint) *MachineSpecApplyConfiguration { + for i := range values { + b.Taints = append(b.Taints, values[i]) + } + return b +} + +// WithProviderSpec sets the ProviderSpec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderSpec field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithProviderSpec(value *ProviderSpecApplyConfiguration) *MachineSpecApplyConfiguration { + b.ProviderSpec = value + return b +} + +// WithProviderID sets the ProviderID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderID field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithProviderID(value string) *MachineSpecApplyConfiguration { + b.ProviderID = &value + return b +} + +// WithAuthoritativeAPI sets the AuthoritativeAPI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthoritativeAPI field is set to the value of the last call. +func (b *MachineSpecApplyConfiguration) WithAuthoritativeAPI(value machinev1beta1.MachineAuthority) *MachineSpecApplyConfiguration { + b.AuthoritativeAPI = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinestatus.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinestatus.go new file mode 100644 index 000000000..acadb0b0d --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinestatus.go @@ -0,0 +1,127 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/openshift/api/machine/v1beta1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// MachineStatusApplyConfiguration represents a declarative configuration of the MachineStatus type for use +// with apply. +type MachineStatusApplyConfiguration struct { + NodeRef *v1.ObjectReference `json:"nodeRef,omitempty"` + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + ErrorReason *v1beta1.MachineStatusError `json:"errorReason,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProviderStatus *runtime.RawExtension `json:"providerStatus,omitempty"` + Addresses []v1.NodeAddress `json:"addresses,omitempty"` + LastOperation *LastOperationApplyConfiguration `json:"lastOperation,omitempty"` + Phase *string `json:"phase,omitempty"` + Conditions []ConditionApplyConfiguration `json:"conditions,omitempty"` + AuthoritativeAPI *v1beta1.MachineAuthority `json:"authoritativeAPI,omitempty"` + SynchronizedGeneration *int64 `json:"synchronizedGeneration,omitempty"` +} + +// MachineStatusApplyConfiguration constructs a declarative configuration of the MachineStatus type for use with +// apply. +func MachineStatus() *MachineStatusApplyConfiguration { + return &MachineStatusApplyConfiguration{} +} + +// WithNodeRef sets the NodeRef field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeRef field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithNodeRef(value v1.ObjectReference) *MachineStatusApplyConfiguration { + b.NodeRef = &value + return b +} + +// WithLastUpdated sets the LastUpdated field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastUpdated field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithLastUpdated(value metav1.Time) *MachineStatusApplyConfiguration { + b.LastUpdated = &value + return b +} + +// WithErrorReason sets the ErrorReason field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorReason field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithErrorReason(value v1beta1.MachineStatusError) *MachineStatusApplyConfiguration { + b.ErrorReason = &value + return b +} + +// WithErrorMessage sets the ErrorMessage field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorMessage field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithErrorMessage(value string) *MachineStatusApplyConfiguration { + b.ErrorMessage = &value + return b +} + +// WithProviderStatus sets the ProviderStatus field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ProviderStatus field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithProviderStatus(value runtime.RawExtension) *MachineStatusApplyConfiguration { + b.ProviderStatus = &value + return b +} + +// WithAddresses adds the given value to the Addresses field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Addresses field. +func (b *MachineStatusApplyConfiguration) WithAddresses(values ...v1.NodeAddress) *MachineStatusApplyConfiguration { + for i := range values { + b.Addresses = append(b.Addresses, values[i]) + } + return b +} + +// WithLastOperation sets the LastOperation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the LastOperation field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithLastOperation(value *LastOperationApplyConfiguration) *MachineStatusApplyConfiguration { + b.LastOperation = value + return b +} + +// WithPhase sets the Phase field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Phase field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithPhase(value string) *MachineStatusApplyConfiguration { + b.Phase = &value + return b +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *MachineStatusApplyConfiguration) WithConditions(values ...*ConditionApplyConfiguration) *MachineStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} + +// WithAuthoritativeAPI sets the AuthoritativeAPI field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the AuthoritativeAPI field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithAuthoritativeAPI(value v1beta1.MachineAuthority) *MachineStatusApplyConfiguration { + b.AuthoritativeAPI = &value + return b +} + +// WithSynchronizedGeneration sets the SynchronizedGeneration field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the SynchronizedGeneration field is set to the value of the last call. +func (b *MachineStatusApplyConfiguration) WithSynchronizedGeneration(value int64) *MachineStatusApplyConfiguration { + b.SynchronizedGeneration = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinetemplatespec.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinetemplatespec.go new file mode 100644 index 000000000..329b999eb --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinetemplatespec.go @@ -0,0 +1,105 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// MachineTemplateSpecApplyConfiguration represents a declarative configuration of the MachineTemplateSpec type for use +// with apply. +type MachineTemplateSpecApplyConfiguration struct { + *ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *MachineSpecApplyConfiguration `json:"spec,omitempty"` +} + +// MachineTemplateSpecApplyConfiguration constructs a declarative configuration of the MachineTemplateSpec type for use with +// apply. +func MachineTemplateSpec() *MachineTemplateSpecApplyConfiguration { + return &MachineTemplateSpecApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *MachineTemplateSpecApplyConfiguration) WithName(value string) *MachineTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *MachineTemplateSpecApplyConfiguration) WithGenerateName(value string) *MachineTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *MachineTemplateSpecApplyConfiguration) WithNamespace(value string) *MachineTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *MachineTemplateSpecApplyConfiguration) WithLabels(entries map[string]string) *MachineTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *MachineTemplateSpecApplyConfiguration) WithAnnotations(entries map[string]string) *MachineTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *MachineTemplateSpecApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *MachineTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +func (b *MachineTemplateSpecApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *MachineTemplateSpecApplyConfiguration) WithSpec(value *MachineSpecApplyConfiguration) *MachineTemplateSpecApplyConfiguration { + b.Spec = value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/objectmeta.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/objectmeta.go new file mode 100644 index 000000000..3b22652fe --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/objectmeta.go @@ -0,0 +1,89 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// ObjectMetaApplyConfiguration represents a declarative configuration of the ObjectMeta type for use +// with apply. +type ObjectMetaApplyConfiguration struct { + Name *string `json:"name,omitempty"` + GenerateName *string `json:"generateName,omitempty"` + Namespace *string `json:"namespace,omitempty"` + Labels map[string]string `json:"labels,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + OwnerReferences []v1.OwnerReferenceApplyConfiguration `json:"ownerReferences,omitempty"` +} + +// ObjectMetaApplyConfiguration constructs a declarative configuration of the ObjectMeta type for use with +// apply. +func ObjectMeta() *ObjectMetaApplyConfiguration { + return &ObjectMetaApplyConfiguration{} +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithName(value string) *ObjectMetaApplyConfiguration { + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithGenerateName(value string) *ObjectMetaApplyConfiguration { + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *ObjectMetaApplyConfiguration) WithNamespace(value string) *ObjectMetaApplyConfiguration { + b.Namespace = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *ObjectMetaApplyConfiguration) WithLabels(entries map[string]string) *ObjectMetaApplyConfiguration { + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *ObjectMetaApplyConfiguration) WithAnnotations(entries map[string]string) *ObjectMetaApplyConfiguration { + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *ObjectMetaApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ObjectMetaApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/providerspec.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/providerspec.go new file mode 100644 index 000000000..a820e9c7e --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/providerspec.go @@ -0,0 +1,27 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// ProviderSpecApplyConfiguration represents a declarative configuration of the ProviderSpec type for use +// with apply. +type ProviderSpecApplyConfiguration struct { + Value *runtime.RawExtension `json:"value,omitempty"` +} + +// ProviderSpecApplyConfiguration constructs a declarative configuration of the ProviderSpec type for use with +// apply. +func ProviderSpec() *ProviderSpecApplyConfiguration { + return &ProviderSpecApplyConfiguration{} +} + +// WithValue sets the Value field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Value field is set to the value of the last call. +func (b *ProviderSpecApplyConfiguration) WithValue(value runtime.RawExtension) *ProviderSpecApplyConfiguration { + b.Value = &value + return b +} diff --git a/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/unhealthycondition.go b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/unhealthycondition.go new file mode 100644 index 000000000..804a6bbaf --- /dev/null +++ b/vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/unhealthycondition.go @@ -0,0 +1,46 @@ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// UnhealthyConditionApplyConfiguration represents a declarative configuration of the UnhealthyCondition type for use +// with apply. +type UnhealthyConditionApplyConfiguration struct { + Type *v1.NodeConditionType `json:"type,omitempty"` + Status *v1.ConditionStatus `json:"status,omitempty"` + Timeout *metav1.Duration `json:"timeout,omitempty"` +} + +// UnhealthyConditionApplyConfiguration constructs a declarative configuration of the UnhealthyCondition type for use with +// apply. +func UnhealthyCondition() *UnhealthyConditionApplyConfiguration { + return &UnhealthyConditionApplyConfiguration{} +} + +// WithType sets the Type field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Type field is set to the value of the last call. +func (b *UnhealthyConditionApplyConfiguration) WithType(value v1.NodeConditionType) *UnhealthyConditionApplyConfiguration { + b.Type = &value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *UnhealthyConditionApplyConfiguration) WithStatus(value v1.ConditionStatus) *UnhealthyConditionApplyConfiguration { + b.Status = &value + return b +} + +// WithTimeout sets the Timeout field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Timeout field is set to the value of the last call. +func (b *UnhealthyConditionApplyConfiguration) WithTimeout(value metav1.Duration) *UnhealthyConditionApplyConfiguration { + b.Timeout = &value + return b +} diff --git a/vendor/github.com/openshift/machine-api-operator/LICENSE b/vendor/github.com/openshift/machine-api-operator/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/vendor/github.com/openshift/machine-api-operator/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go deleted file mode 100644 index 4f5d74d03..000000000 --- a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/conditions.go +++ /dev/null @@ -1,35 +0,0 @@ -package conditions - -import ( - machinev1 "github.com/openshift/api/machine/v1beta1" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" -) - -// GetNodeCondition returns node condition by type -func GetNodeCondition(node *corev1.Node, conditionType corev1.NodeConditionType) *corev1.NodeCondition { - for _, cond := range node.Status.Conditions { - if cond.Type == conditionType { - return &cond - } - } - return nil -} - -// GetDeploymentCondition returns node condition by type -func GetDeploymentCondition(deployment *appsv1.Deployment, conditionType appsv1.DeploymentConditionType) *appsv1.DeploymentCondition { - for _, cond := range deployment.Status.Conditions { - if cond.Type == conditionType { - return &cond - } - } - return nil -} - -func DeepCopyConditions(in []machinev1.Condition) []machinev1.Condition { - out := make([]machinev1.Condition, 0) - for _, cond := range in { - out = append(out, *cond.DeepCopy()) - } - return out -} diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go deleted file mode 100644 index d2a3eafb4..000000000 --- a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/gettersetter.go +++ /dev/null @@ -1,181 +0,0 @@ -package conditions - -import ( - "fmt" - "sort" - "time" - - machinev1 "github.com/openshift/api/machine/v1beta1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" -) - -type GetterSetter interface { - runtime.Object - metav1.Object - - // GetConditions returns the list of conditions for a machine API object. - GetConditions() []machinev1.Condition - - // SetConditions sets the list of conditions for a machine API object. - SetConditions([]machinev1.Condition) -} - -// Get returns the condition with the given type, if the condition does not exists, -// it returns nil. -func Get(from interface{}, t machinev1.ConditionType) *machinev1.Condition { - obj := getWrapperObject(from) - conditions := obj.GetConditions() - if conditions == nil { - return nil - } - - for _, condition := range conditions { - if condition.Type == t { - return &condition - } - } - return nil -} - -// Set sets the given condition. -// -// NOTE: If a condition already exists, the LastTransitionTime is updated only if a change is detected -// in any of the following fields: Status, Reason, Severity and Message. -func Set(to interface{}, condition *machinev1.Condition) { - if to == nil || condition == nil { - return - } - - obj := getWrapperObject(to) - - // Check if the new conditions already exists, and change it only if there is a status - // transition (otherwise we should preserve the current last transition time)- - conditions := obj.GetConditions() - exists := false - for i := range conditions { - existingCondition := conditions[i] - if existingCondition.Type == condition.Type { - exists = true - if !hasSameState(&existingCondition, condition) { - condition.LastTransitionTime = metav1.NewTime(time.Now().UTC().Truncate(time.Second)) - conditions[i] = *condition - break - } - condition.LastTransitionTime = existingCondition.LastTransitionTime - break - } - } - - // If the condition does not exist, add it, setting the transition time only if not already set - if !exists { - if condition.LastTransitionTime.IsZero() { - condition.LastTransitionTime = metav1.NewTime(time.Now().UTC().Truncate(time.Second)) - } - conditions = append(conditions, *condition) - } - - // Sorts conditions for convenience of the consumer, i.e. kubectl. - sort.Slice(conditions, func(i, j int) bool { - return lexicographicLess(&conditions[i], &conditions[j]) - }) - - obj.SetConditions(conditions) -} - -// TrueCondition returns a condition with Status=True and the given type. -func TrueCondition(t machinev1.ConditionType) *machinev1.Condition { - return &machinev1.Condition{ - Type: t, - Status: corev1.ConditionTrue, - } -} - -// TrueConditionWithReason returns a condition with Status=True and the given type. -func TrueConditionWithReason(t machinev1.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *machinev1.Condition { - return &machinev1.Condition{ - Type: t, - Status: corev1.ConditionTrue, - Reason: reason, - Message: fmt.Sprintf(messageFormat, messageArgs...), - } -} - -// FalseCondition returns a condition with Status=False and the given type. -func FalseCondition(t machinev1.ConditionType, reason string, severity machinev1.ConditionSeverity, messageFormat string, messageArgs ...interface{}) *machinev1.Condition { - return &machinev1.Condition{ - Type: t, - Status: corev1.ConditionFalse, - Reason: reason, - Severity: severity, - Message: fmt.Sprintf(messageFormat, messageArgs...), - } -} - -// UnknownCondition returns a condition with Status=Unknown and the given type. -func UnknownCondition(t machinev1.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *machinev1.Condition { - return &machinev1.Condition{ - Type: t, - Status: corev1.ConditionUnknown, - Reason: reason, - Message: fmt.Sprintf(messageFormat, messageArgs...), - } -} - -// MarkTrue sets Status=True for the condition with the given type. -func MarkTrue(to interface{}, t machinev1.ConditionType) { - Set(to, TrueCondition(t)) -} - -// MarkFalse sets Status=False for the condition with the given type. -func MarkFalse(to interface{}, t machinev1.ConditionType, reason string, severity machinev1.ConditionSeverity, messageFormat string, messageArgs ...interface{}) { - Set(to, FalseCondition(t, reason, severity, messageFormat, messageArgs...)) -} - -// IsTrue is true if the condition with the given type is True, otherwise it return false -// if the condition is not True or if the condition does not exist (is nil). -func IsTrue(from interface{}, t machinev1.ConditionType) bool { - if c := Get(from, t); c != nil { - return c.Status == corev1.ConditionTrue - } - return false -} - -// IsFalse is true if the condition with the given type is False, otherwise it return false -// if the condition is not False or if the condition does not exist (is nil). -func IsFalse(from interface{}, t machinev1.ConditionType) bool { - if c := Get(from, t); c != nil { - return c.Status == corev1.ConditionFalse - } - return false -} - -// lexicographicLess returns true if a condition is less than another with regards to the -// to order of conditions designed for convenience of the consumer, i.e. kubectl. -func lexicographicLess(i, j *machinev1.Condition) bool { - return i.Type < j.Type -} - -// hasSameState returns true if a condition has the same state of another; state is defined -// by the union of following fields: Type, Status, Reason, Severity and Message (it excludes LastTransitionTime). -func hasSameState(i, j *machinev1.Condition) bool { - return i.Type == j.Type && - i.Status == j.Status && - i.Reason == j.Reason && - i.Severity == j.Severity && - i.Message == j.Message -} - -func getWrapperObject(from interface{}) GetterSetter { - switch obj := from.(type) { - case *machinev1.Machine: - return &MachineWrapper{obj} - case *machinev1.MachineSet: - return &MachineSetWrapper{obj} - case *machinev1.MachineHealthCheck: - return &MachineHealthCheckWrapper{obj} - default: - panic("type is not supported as conditions getter or setter") - } -} diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go deleted file mode 100644 index 5e5576103..000000000 --- a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/matcher.go +++ /dev/null @@ -1,102 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -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. -*/ - -package conditions - -import ( - "fmt" - - . "github.com/onsi/gomega" - "github.com/onsi/gomega/types" - machinev1 "github.com/openshift/api/machine/v1beta1" -) - -// MatchConditions returns a custom matcher to check equality of mapiv1.Conditions -func MatchConditions(expected []machinev1.Condition) types.GomegaMatcher { - return &matchConditions{ - expected: expected, - } -} - -type matchConditions struct { - expected []machinev1.Condition -} - -func (m matchConditions) Match(actual interface{}) (success bool, err error) { - elems := []interface{}{} - for _, condition := range m.expected { - elems = append(elems, MatchCondition(condition)) - } - - return ConsistOf(elems).Match(actual) -} - -func (m matchConditions) FailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected) -} - -func (m matchConditions) NegatedFailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected) -} - -// MatchCondition returns a custom matcher to check equality of mapiv1.Condition -func MatchCondition(expected machinev1.Condition) types.GomegaMatcher { - return &matchCondition{ - expected: expected, - } -} - -type matchCondition struct { - expected machinev1.Condition -} - -func (m matchCondition) Match(actual interface{}) (success bool, err error) { - actualCondition, ok := actual.(machinev1.Condition) - if !ok { - return false, fmt.Errorf("actual should be of type Condition") - } - - ok, err = Equal(m.expected.Type).Match(actualCondition.Type) - if !ok { - return ok, err - } - ok, err = Equal(m.expected.Status).Match(actualCondition.Status) - if !ok { - return ok, err - } - ok, err = Equal(m.expected.Severity).Match(actualCondition.Severity) - if !ok { - return ok, err - } - ok, err = Equal(m.expected.Reason).Match(actualCondition.Reason) - if !ok { - return ok, err - } - ok, err = Equal(m.expected.Message).Match(actualCondition.Message) - if !ok { - return ok, err - } - - return ok, err -} - -func (m matchCondition) FailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("expected\n\t%#v\nto match\n\t%#v\n", actual, m.expected) -} - -func (m matchCondition) NegatedFailureMessage(actual interface{}) (message string) { - return fmt.Sprintf("expected\n\t%#v\nto not match\n\t%#v\n", actual, m.expected) -} diff --git a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go b/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go deleted file mode 100644 index 5f72d1e15..000000000 --- a/vendor/github.com/openshift/machine-api-operator/pkg/util/conditions/wrap.go +++ /dev/null @@ -1,41 +0,0 @@ -package conditions - -import ( - machinev1 "github.com/openshift/api/machine/v1beta1" -) - -type MachineWrapper struct { - *machinev1.Machine -} - -func (m *MachineWrapper) GetConditions() []machinev1.Condition { - return m.Status.Conditions -} - -func (m *MachineWrapper) SetConditions(conditions []machinev1.Condition) { - m.Status.Conditions = conditions -} - -type MachineHealthCheckWrapper struct { - *machinev1.MachineHealthCheck -} - -func (m *MachineHealthCheckWrapper) GetConditions() []machinev1.Condition { - return m.Status.Conditions -} - -func (m *MachineHealthCheckWrapper) SetConditions(conditions []machinev1.Condition) { - m.Status.Conditions = conditions -} - -type MachineSetWrapper struct { - *machinev1.MachineSet -} - -func (m *MachineSetWrapper) GetConditions() []machinev1.Condition { - return m.Status.Conditions -} - -func (m *MachineSetWrapper) SetConditions(conditions []machinev1.Condition) { - m.Status.Conditions = conditions -} diff --git a/vendor/modules.txt b/vendor/modules.txt index a349c5790..78c6a7b7d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -926,6 +926,8 @@ github.com/openshift/client-go/config/informers/externalversions/config/v1alpha1 github.com/openshift/client-go/config/informers/externalversions/internalinterfaces github.com/openshift/client-go/config/listers/config/v1 github.com/openshift/client-go/config/listers/config/v1alpha1 +github.com/openshift/client-go/machine/applyconfigurations/internal +github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1 github.com/openshift/client-go/operator/applyconfigurations/internal github.com/openshift/client-go/operator/applyconfigurations/operator/v1 # github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20241024095219-086923b9d3fd @@ -960,9 +962,6 @@ github.com/openshift/library-go/pkg/operator/resource/resourcemerge github.com/openshift/library-go/pkg/operator/resource/resourceread github.com/openshift/library-go/pkg/operator/resourcesynccontroller github.com/openshift/library-go/pkg/operator/v1helpers -# github.com/openshift/machine-api-operator v0.2.1-0.20241009125928-52a965a42fac -## explicit; go 1.22.1 -github.com/openshift/machine-api-operator/pkg/util/conditions # github.com/pelletier/go-toml/v2 v2.2.3 ## explicit; go 1.21.0 github.com/pelletier/go-toml/v2 @@ -2361,7 +2360,7 @@ sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/optional # sigs.k8s.io/cluster-api-provider-vsphere v1.10.0 ## explicit; go 1.21 sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1 -# sigs.k8s.io/controller-runtime v0.19.0 +# sigs.k8s.io/controller-runtime v0.19.1 ## explicit; go 1.22.0 sigs.k8s.io/controller-runtime sigs.k8s.io/controller-runtime/pkg/builder diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/client/fake/client.go b/vendor/sigs.k8s.io/controller-runtime/pkg/client/fake/client.go index 7366a1852..54f5b5d25 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/client/fake/client.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/client/fake/client.go @@ -68,16 +68,21 @@ type versionedTracker struct { } type fakeClient struct { - tracker versionedTracker - scheme *runtime.Scheme + // trackerWriteLock must be acquired before writing to + // the tracker or performing reads that affect a following + // write. + trackerWriteLock sync.Mutex + tracker versionedTracker + + schemeWriteLock sync.Mutex + scheme *runtime.Scheme + restMapper meta.RESTMapper withStatusSubresource sets.Set[schema.GroupVersionKind] // indexes maps each GroupVersionKind (GVK) to the indexes registered for that GVK. // The inner map maps from index name to IndexerFunc. indexes map[schema.GroupVersionKind]map[string]client.IndexerFunc - - schemeWriteLock sync.Mutex } var _ client.WithWatch = &fakeClient{} @@ -467,6 +472,11 @@ func (t versionedTracker) updateObject(gvr schema.GroupVersionResource, obj runt switch { case allowsUnconditionalUpdate(gvk): accessor.SetResourceVersion(oldAccessor.GetResourceVersion()) + // This is needed because if the patch explicitly sets the RV to null, the client-go reaction we use + // to apply it and whose output we process here will have it unset. It is not clear why the Kubernetes + // apiserver accepts such a patch, but it does so we just copy that behavior. + // Kubernetes apiserver behavior can be checked like this: + // `kubectl patch configmap foo --patch '{"metadata":{"annotations":{"foo":"bar"},"resourceVersion":null}}' -v=9` case bytes. Contains(debug.Stack(), []byte("sigs.k8s.io/controller-runtime/pkg/client/fake.(*fakeClient).Patch")): // We apply patches using a client-go reaction that ends up calling the trackers Update. As we can't change @@ -508,7 +518,10 @@ func (c *fakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.O return err } - if _, isUnstructured := obj.(runtime.Unstructured); isUnstructured { + _, isUnstructured := obj.(runtime.Unstructured) + _, isPartialObject := obj.(*metav1.PartialObjectMetadata) + + if isUnstructured || isPartialObject { gvk, err := apiutil.GVKForObject(obj, c.scheme) if err != nil { return err @@ -729,6 +742,8 @@ func (c *fakeClient) Create(ctx context.Context, obj client.Object, opts ...clie accessor.SetDeletionTimestamp(nil) } + c.trackerWriteLock.Lock() + defer c.trackerWriteLock.Unlock() return c.tracker.Create(gvr, obj, accessor.GetNamespace()) } @@ -750,6 +765,8 @@ func (c *fakeClient) Delete(ctx context.Context, obj client.Object, opts ...clie } } + c.trackerWriteLock.Lock() + defer c.trackerWriteLock.Unlock() // Check the ResourceVersion if that Precondition was specified. if delOptions.Preconditions != nil && delOptions.Preconditions.ResourceVersion != nil { name := accessor.GetName() @@ -772,7 +789,7 @@ func (c *fakeClient) Delete(ctx context.Context, obj client.Object, opts ...clie } } - return c.deleteObject(gvr, accessor) + return c.deleteObjectLocked(gvr, accessor) } func (c *fakeClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error { @@ -790,6 +807,9 @@ func (c *fakeClient) DeleteAllOf(ctx context.Context, obj client.Object, opts .. } } + c.trackerWriteLock.Lock() + defer c.trackerWriteLock.Unlock() + gvr, _ := meta.UnsafeGuessKindToResource(gvk) o, err := c.tracker.List(gvr, gvk, dcOptions.Namespace) if err != nil { @@ -809,7 +829,7 @@ func (c *fakeClient) DeleteAllOf(ctx context.Context, obj client.Object, opts .. if err != nil { return err } - err = c.deleteObject(gvr, accessor) + err = c.deleteObjectLocked(gvr, accessor) if err != nil { return err } @@ -839,6 +859,9 @@ func (c *fakeClient) update(obj client.Object, isStatus bool, opts ...client.Upd if err != nil { return err } + + c.trackerWriteLock.Lock() + defer c.trackerWriteLock.Unlock() return c.tracker.update(gvr, obj, accessor.GetNamespace(), isStatus, false, *updateOptions.AsUpdateOptions()) } @@ -874,6 +897,8 @@ func (c *fakeClient) patch(obj client.Object, patch client.Patch, opts ...client return err } + c.trackerWriteLock.Lock() + defer c.trackerWriteLock.Unlock() oldObj, err := c.tracker.Get(gvr, accessor.GetNamespace(), accessor.GetName()) if err != nil { return err @@ -1082,7 +1107,7 @@ func (c *fakeClient) SubResource(subResource string) client.SubResourceClient { return &fakeSubResourceClient{client: c, subResource: subResource} } -func (c *fakeClient) deleteObject(gvr schema.GroupVersionResource, accessor metav1.Object) error { +func (c *fakeClient) deleteObjectLocked(gvr schema.GroupVersionResource, accessor metav1.Object) error { old, err := c.tracker.Get(gvr, accessor.GetNamespace(), accessor.GetName()) if err == nil { oldAccessor, err := meta.Accessor(old) @@ -1164,7 +1189,7 @@ func (sw *fakeSubResourceClient) Update(ctx context.Context, obj client.Object, switch sw.subResource { case subResourceScale: - if err := sw.client.Get(ctx, client.ObjectKeyFromObject(obj), obj); err != nil { + if err := sw.client.Get(ctx, client.ObjectKeyFromObject(obj), obj.DeepCopyObject().(client.Object)); err != nil { return err } if updateOptions.SubResourceBody == nil { From cf279856233d92613447c924308e0a06623a93d3 Mon Sep 17 00:00:00 2001 From: Theo Barber-Bany Date: Wed, 23 Oct 2024 19:40:19 +0100 Subject: [PATCH 3/4] Updates tests --- .../machineset_sync_controller_test.go | 138 ++++++++++++++---- 1 file changed, 106 insertions(+), 32 deletions(-) diff --git a/pkg/controllers/machinesetsync/machineset_sync_controller_test.go b/pkg/controllers/machinesetsync/machineset_sync_controller_test.go index a835922c2..a5e06bba3 100644 --- a/pkg/controllers/machinesetsync/machineset_sync_controller_test.go +++ b/pkg/controllers/machinesetsync/machineset_sync_controller_test.go @@ -21,29 +21,48 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + configv1 "github.com/openshift/api/config/v1" machinev1beta1 "github.com/openshift/api/machine/v1beta1" + capiv1resourcebuilder "github.com/openshift/cluster-api-actuator-pkg/testutils/resourcebuilder/cluster-api/core/v1beta1" + capav1builder "github.com/openshift/cluster-api-actuator-pkg/testutils/resourcebuilder/cluster-api/infrastructure/v1beta2" corev1resourcebuilder "github.com/openshift/cluster-api-actuator-pkg/testutils/resourcebuilder/core/v1" machinev1resourcebuilder "github.com/openshift/cluster-api-actuator-pkg/testutils/resourcebuilder/machine/v1beta1" corev1 "k8s.io/api/core/v1" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/manager" + capav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2" + capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" consts "github.com/openshift/cluster-capi-operator/pkg/controllers" "github.com/openshift/cluster-capi-operator/pkg/test" + "k8s.io/utils/ptr" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/config" + "sigs.k8s.io/controller-runtime/pkg/envtest/komega" + "sigs.k8s.io/controller-runtime/pkg/manager" ) -var _ = Describe("MachineSetSync Reconciler", func() { +var _ = Describe("With a running controller", func() { var mgrCancel context.CancelFunc var mgrDone chan struct{} var mgr manager.Manager + var k komega.Komega var reconciler *MachineSetSyncReconciler - var namespace *corev1.Namespace - var namespaceName string + var syncControllerNamespace *corev1.Namespace + var capiNamespace *corev1.Namespace + var MapiNamespace *corev1.Namespace + + var mapiMachineSetBuilder machinev1resourcebuilder.MachineSetBuilder + var mapiMachineSet *machinev1beta1.MachineSet - var machineSetBuilder machinev1resourcebuilder.MachineSetBuilder - var machineset *machinev1beta1.MachineSet + var capiMachineSetBuilder capiv1resourcebuilder.MachineSetBuilder + var capiMachineSet *capiv1beta1.MachineSet + + var capaMachineTemplateBuilder capav1builder.AWSMachineTemplateBuilder + var capaMachineTemplate *capav1.AWSMachineTemplate + + var capaClusterBuilder capav1builder.AWSClusterBuilder + var capaCluster *capav1.AWSCluster startManager := func(mgr *manager.Manager) (context.CancelFunc, chan struct{}) { mgrCtx, mgrCancel := context.WithCancel(context.Background()) @@ -67,32 +86,82 @@ var _ = Describe("MachineSetSync Reconciler", func() { BeforeEach(func() { By("Setting up a namespace for the test") - namespace = corev1resourcebuilder.Namespace().WithGenerateName("machineset-sync-controller-").Build() - Expect(k8sClient.Create(ctx, namespace)).To(Succeed()) - namespaceName = namespace.GetName() - - By("Setting up the machineset builder") - machineSetBuilder = machinev1resourcebuilder.MachineSet(). - WithNamespace(namespaceName). - WithGenerateName("foo-"). + syncControllerNamespace = corev1resourcebuilder.Namespace(). + WithGenerateName("machineset-sync-controller-").Build() + Expect(k8sClient.Create(ctx, syncControllerNamespace)).To(Succeed()) + + MapiNamespace = corev1resourcebuilder.Namespace(). + WithGenerateName("openshift-machine-api-").Build() + Expect(k8sClient.Create(ctx, MapiNamespace)).To(Succeed()) + + capiNamespace = corev1resourcebuilder.Namespace(). + WithGenerateName("openshift-cluster-api-").Build() + Expect(k8sClient.Create(ctx, capiNamespace)).To(Succeed()) + + By("Setting up the builders") + mapiMachineSetBuilder = machinev1resourcebuilder.MachineSet(). + WithNamespace(MapiNamespace.GetName()). + WithName("foo"). WithProviderSpecBuilder(machinev1resourcebuilder.AWSProviderSpec()) + // We need to build and create the CAPA MachineTemplate in order to + // reference it on the CAPI MachineSet + capaMachineTemplateBuilder = capav1builder.AWSMachineTemplate(). + WithNamespace(capiNamespace.GetName()). + WithGenerateName("machine-template-") + + capaMachineTemplate = capaMachineTemplateBuilder.Build() + Expect(k8sClient.Create(ctx, capaMachineTemplate)).To(Succeed()) + + capiMachineTemplate := capiv1beta1.MachineTemplateSpec{ + Spec: capiv1beta1.MachineSpec{ + InfrastructureRef: corev1.ObjectReference{ + Kind: capaMachineTemplate.Kind, + Name: capaMachineTemplate.GetName(), + Namespace: capaMachineTemplate.GetNamespace(), + }, + }, + } + + capaClusterBuilder = capav1builder.AWSCluster(). + WithNamespace(capiNamespace.GetName()). + WithGenerateName("foo-") + + capaCluster = capaClusterBuilder.Build() + Expect(k8sClient.Create(ctx, capaCluster)).To(Succeed()) + + capiMachineSetBuilder = capiv1resourcebuilder.MachineSet(). + WithNamespace(capiNamespace.GetName()). + WithName("foo"). + WithTemplate(capiMachineTemplate). + WithClusterName(capaCluster.GetName()) + By("Setting up a manager and controller") var err error mgr, err = ctrl.NewManager(cfg, ctrl.Options{ Scheme: testScheme, + Controller: config.Controller{ + SkipNameValidation: ptr.To(true), + }, }) Expect(err).ToNot(HaveOccurred(), "Manager should be able to be created") reconciler = &MachineSetSyncReconciler{ - Client: mgr.GetClient(), - Platform: configv1.AWSPlatformType, + Client: mgr.GetClient(), + Platform: configv1.AWSPlatformType, + CAPINamespace: capiNamespace.GetName(), + MAPINamespace: MapiNamespace.GetName(), } - Expect(reconciler.SetupWithManager(mgr)).To(Succeed(), "Reconciler should be able to setup with manager") + Expect(reconciler.SetupWithManager(mgr)).To(Succeed(), + "Reconciler should be able to setup with manager") + + k = komega.New(k8sClient) }) AfterEach(func() { - Expect(test.CleanupAndWait(ctx, k8sClient, machineset)).To(Succeed()) + Expect(test.CleanupAndWait( + ctx, k8sClient, mapiMachineSet, capiMachineSet, capaMachineTemplate, capaCluster, + )).To(Succeed()) }) JustBeforeEach(func() { @@ -106,32 +175,37 @@ var _ = Describe("MachineSetSync Reconciler", func() { }) Context("when the MAPI machine set has MachineAuthority set to Cluster API", func() { - JustBeforeEach(func() { + BeforeEach(func() { By("Creating the CAPI and MAPI MachineSets") mapiMachineSet = mapiMachineSetBuilder.Build() - capiMachineSet = capiMachineSetBuilder.Build() + capiMachineSet = capiMachineSetBuilder.WithReplicas(int32(4)).Build() Expect(k8sClient.Create(ctx, capiMachineSet)).Should(Succeed()) Expect(k8sClient.Create(ctx, mapiMachineSet)).Should(Succeed()) - }) - - // For now only happy path - It("should update the synchronized condition", func() { - By("Setting the AuthoritativeAPI to ClusterAPI") Eventually(k.UpdateStatus(mapiMachineSet, func() { mapiMachineSet.Status.AuthoritativeAPI = machinev1beta1.MachineAuthorityClusterAPI })).Should(Succeed()) + }) + // For now only happy path + It("should update the synchronized condition on the MAPI MachineSet", func() { Eventually(k.Object(mapiMachineSet), timeout).Should( - HaveField("Status.Conditions", ContainElement( - SatisfyAll( - HaveField("Type", Equal(consts.SynchronizedCondition)), - HaveField("Status", Equal(corev1.ConditionTrue)), - ))), - ) + SatisfyAll( + HaveField("Status.Conditions", ContainElement( + SatisfyAll( + HaveField("Type", Equal(consts.SynchronizedCondition)), + HaveField("Status", Equal(corev1.ConditionTrue)), + ))), + HaveField("Status.SynchronizedGeneration", Equal(capiMachineSet.GetGeneration())), + )) }) + It("should update the replica count", func() { + Eventually(k.Object(mapiMachineSet), timeout).Should( + HaveField("Spec.Replicas", Equal(ptr.To(int32(4)))), + ) + }) }) }) From c820cd8ce3829c10602a0a8385c52c22bceb865a Mon Sep 17 00:00:00 2001 From: Theo Barber-Bany Date: Fri, 1 Nov 2024 15:37:34 +0000 Subject: [PATCH 4/4] MachineSetSync: support multiple platforms Updates MachineSetSync controller to support multiple platforms. --- .../machineset_sync_controller.go | 143 +++++++++++------- .../machineset_sync_controller_test.go | 12 +- 2 files changed, 94 insertions(+), 61 deletions(-) diff --git a/pkg/controllers/machinesetsync/machineset_sync_controller.go b/pkg/controllers/machinesetsync/machineset_sync_controller.go index 074325031..eee147017 100644 --- a/pkg/controllers/machinesetsync/machineset_sync_controller.go +++ b/pkg/controllers/machinesetsync/machineset_sync_controller.go @@ -50,6 +50,21 @@ import ( var ( // errPlatformNotSupported is returned when the platform is not supported. errPlatformNotSupported = errors.New("error determining InfraMachineTemplate type, platform not supported") + + // errUnexpectedInfraMachineTemplateType is returned when we receive an unexpected InfraMachineTemplate type. + errUnexpectedInfraMachineTemplateType = errors.New("unexpected InfraMachineTemplate type") + + // errUnexpectedInfraClusterType is returned when we receive an unexpected InfraCluster type. + errUnexpectedInfraClusterType = errors.New("unexpected InfraCluster type") +) + +const ( + reasonFailedToGetCAPIInfraResources = "FailedToGetCAPIInfraResources" + reasonFailedToConvertCAPIMachineSetToMAPI = "FailedToConvertCAPIMachineSetToMAPI" + reasonFailedToUpdateMAPIMachineSet = "FailedToUpdateMAPIMachineSet" + reasonResourceSynchronized = "ResourceSynchronized" + + messageSuccessfullySynchronized = "Successfully synchronized CAPI MachineSet to MAPI" ) // MachineSetSyncReconciler reconciles CAPI and MAPI MachineSets. @@ -67,7 +82,7 @@ type MachineSetSyncReconciler struct { func (r *MachineSetSyncReconciler) SetupWithManager(mgr ctrl.Manager) error { infraMachineTemplate, err := getInfraMachineTemplateFromProvider(r.Platform) if err != nil { - return fmt.Errorf("failed to get InfraMachineTemplate from Provider: %w", err) + return fmt.Errorf("failed to get infrastructure machine template from Provider: %w", err) } // Allow the namespaces to be set externally for test purposes, when not set, @@ -136,6 +151,8 @@ func (r *MachineSetSyncReconciler) fetchMachineSets(ctx context.Context, name st mapiMachineSet := &machinev1beta1.MachineSet{} + capiMachineSet := &capiv1beta1.MachineSet{} + if err := r.Get(ctx, client.ObjectKey{Namespace: r.MAPINamespace, Name: name}, mapiMachineSet); apierrors.IsNotFound(err) { logger.Info("MAPI machine set not found") @@ -144,8 +161,6 @@ func (r *MachineSetSyncReconciler) fetchMachineSets(ctx context.Context, name st return nil, nil, fmt.Errorf("failed to get MAPI machine set: %w", err) } - capiMachineSet := &capiv1beta1.MachineSet{} - if err := r.Get(ctx, client.ObjectKey{Namespace: r.CAPINamespace, Name: name}, capiMachineSet); apierrors.IsNotFound(err) { logger.Info("CAPI machine set not found") @@ -157,6 +172,40 @@ func (r *MachineSetSyncReconciler) fetchMachineSets(ctx context.Context, name st return mapiMachineSet, capiMachineSet, nil } +// fetchCAPIInfraResources fetches the provider specific infrastructure resources depending on which provider is set. +func (r *MachineSetSyncReconciler) fetchCAPIInfraResources(ctx context.Context, capiMachineSet *capiv1beta1.MachineSet) (client.Object, client.Object, error) { + var infraCluster, infraMachineTemplate client.Object + + clusterKey := client.ObjectKey{ + Namespace: capiMachineSet.Namespace, + Name: capiMachineSet.Spec.ClusterName, + } + + templateRef := capiMachineSet.Spec.Template.Spec.InfrastructureRef + templateKey := client.ObjectKey{ + Namespace: templateRef.Namespace, + Name: templateRef.Name, + } + + switch r.Platform { + case configv1.AWSPlatformType: + infraCluster = &awscapiv1beta1.AWSCluster{} + infraMachineTemplate = &awscapiv1beta1.AWSMachineTemplate{} + default: + return nil, nil, fmt.Errorf("%w: %s", errPlatformNotSupported, r.Platform) + } + + if err := r.Get(ctx, clusterKey, infraCluster); err != nil { + return nil, nil, fmt.Errorf("failed to get CAPI infrastructure cluster: %w", err) + } + + if err := r.Get(ctx, templateKey, infraMachineTemplate); err != nil { + return nil, nil, fmt.Errorf("failed to get CAPI infrastructure machine template: %w", err) + } + + return infraCluster, infraMachineTemplate, nil +} + // syncMachineSets synchronizes MachineSets based on the authoritative API. func (r *MachineSetSyncReconciler) syncMachineSets(ctx context.Context, mapiMachineSet *machinev1beta1.MachineSet, capiMachineSet *capiv1beta1.MachineSet) (ctrl.Result, error) { logger := log.FromContext(ctx) @@ -170,7 +219,7 @@ func (r *MachineSetSyncReconciler) syncMachineSets(ctx context.Context, mapiMach logger.Info("machine set is currently being migrated", "machine set", mapiMachineSet.GetName()) return ctrl.Result{}, nil default: - logger.Info("Unexpected value for AuthoritativeAPI", "AuthoritativeAPI", mapiMachineSet.Status.AuthoritativeAPI) + logger.Info("unexpected value for authoritativeAPI", "AuthoritativeAPI", mapiMachineSet.Status.AuthoritativeAPI) return ctrl.Result{}, nil } } @@ -183,60 +232,27 @@ func (r *MachineSetSyncReconciler) reconcileMAPIMachineSetToCAPIMachineSet(ctx c // reconcileCAPIMachineSetToMAPIMachineSet reconciles a CAPI MachineSet to a // MAPI MachineSet. -// -// TODO: Platform specific implementation (currently this works only for AWS, -// we want a switch on platform somewhere). -// TODO: Put Gets() for Cluster + Template in helper func. -// -//nolint:funlen func (r *MachineSetSyncReconciler) reconcileCAPIMachineSetToMAPIMachineSet(ctx context.Context, capiMachineSet *capiv1beta1.MachineSet, mapiMachineSet *machinev1beta1.MachineSet) (ctrl.Result, error) { logger := log.FromContext(ctx) - infraCluster := &awscapiv1beta1.AWSCluster{} - clusterNamespacedName := client.ObjectKey{ - Namespace: capiMachineSet.GetNamespace(), - Name: capiMachineSet.Spec.ClusterName, - } - - if err := r.Get(ctx, clusterNamespacedName, infraCluster); err != nil { - getErr := fmt.Errorf("failed to get CAPI InfraCluster: %w", err) - - if condErr := r.updateSynchronizedConditionWithPatch( - ctx, mapiMachineSet, corev1.ConditionFalse, - "FailedToGetCAPIInfraCluster", err.Error(), nil); condErr != nil { - return ctrl.Result{}, utilerrors.NewAggregate([]error{getErr, condErr}) - } - - return ctrl.Result{}, getErr - } - - infraMachineTemplate := &awscapiv1beta1.AWSMachineTemplate{} - templateNamespacedName := client.ObjectKey{ - Namespace: capiMachineSet.Spec.Template.Spec.InfrastructureRef.Namespace, - Name: capiMachineSet.Spec.Template.Spec.InfrastructureRef.Name, - } - - if err := r.Get(ctx, templateNamespacedName, infraMachineTemplate); err != nil { - getErr := fmt.Errorf("failed to get InfraMachineTemplate: %w", err) + infraCluster, infraMachineTemplate, err := r.fetchCAPIInfraResources(ctx, capiMachineSet) + if err != nil { + fetchErr := fmt.Errorf("failed to fetch CAPI infra resources: %w", err) if condErr := r.updateSynchronizedConditionWithPatch( - ctx, mapiMachineSet, corev1.ConditionFalse, - "FailedToGetCAPIInfraMachineTemplate", err.Error(), nil); condErr != nil { - return ctrl.Result{}, utilerrors.NewAggregate([]error{getErr, condErr}) + ctx, mapiMachineSet, corev1.ConditionFalse, reasonFailedToGetCAPIInfraResources, fetchErr.Error(), nil); condErr != nil { + return ctrl.Result{}, utilerrors.NewAggregate([]error{fetchErr, condErr}) } - return ctrl.Result{}, getErr + return ctrl.Result{}, fetchErr } - // Convert the CAPI MachineSet and AWS resources to a MAPI MachineSet - newMapiMachineSet, warns, err := capi2mapi.FromMachineSetAndAWSMachineTemplateAndAWSCluster( - capiMachineSet, infraMachineTemplate, infraCluster).ToMachineSet() + newMapiMachineSet, warns, err := r.convertCAPIToMAPIMachineSet(capiMachineSet, infraMachineTemplate, infraCluster) if err != nil { conversionErr := fmt.Errorf("failed to convert CAPI machine set to MAPI machine set: %w", err) if condErr := r.updateSynchronizedConditionWithPatch( - ctx, mapiMachineSet, corev1.ConditionFalse, - "FailedToConvertCAPIMachineSetToMAPI", err.Error(), nil); condErr != nil { + ctx, mapiMachineSet, corev1.ConditionFalse, reasonFailedToConvertCAPIMachineSetToMAPI, conversionErr.Error(), nil); condErr != nil { return ctrl.Result{}, utilerrors.NewAggregate([]error{conversionErr, condErr}) } @@ -250,12 +266,10 @@ func (r *MachineSetSyncReconciler) reconcileCAPIMachineSetToMAPIMachineSet(ctx c newMapiMachineSet.Spec.Template.Labels = util.MergeMaps(mapiMachineSet.Spec.Template.Labels, newMapiMachineSet.Spec.Template.Labels) - // We need to change the namespace as the newMapiMachineSet will have the CAPI namespace set otherwise newMapiMachineSet.SetNamespace(mapiMachineSet.GetNamespace()) // The conversion does not set a resource version, so we must copy it over newMapiMachineSet.SetResourceVersion(mapiMachineSet.GetResourceVersion()) - // Check if there are any changes to spec or metadata if !reflect.DeepEqual(newMapiMachineSet.Spec, mapiMachineSet.Spec) || !objectMetaIsEqual(newMapiMachineSet.ObjectMeta, mapiMachineSet.ObjectMeta) { logger.Info("Updating MAPI machine set") @@ -265,8 +279,7 @@ func (r *MachineSetSyncReconciler) reconcileCAPIMachineSetToMAPIMachineSet(ctx c updateErr := fmt.Errorf("failed to update MAPI machine set: %w", err) if condErr := r.updateSynchronizedConditionWithPatch( - ctx, mapiMachineSet, corev1.ConditionFalse, - "FailedToUpdateMAPIMachineSet", err.Error(), nil); condErr != nil { + ctx, mapiMachineSet, corev1.ConditionFalse, reasonFailedToUpdateMAPIMachineSet, updateErr.Error(), nil); condErr != nil { return ctrl.Result{}, utilerrors.NewAggregate([]error{updateErr, condErr}) } @@ -279,8 +292,30 @@ func (r *MachineSetSyncReconciler) reconcileCAPIMachineSetToMAPIMachineSet(ctx c } return ctrl.Result{}, r.updateSynchronizedConditionWithPatch(ctx, mapiMachineSet, corev1.ConditionTrue, - consts.ReasonResourceSynchronized, "Successfully synchronized CAPI MachineSet to MAPI", - &capiMachineSet.Generation) + consts.ReasonResourceSynchronized, messageSuccessfullySynchronized, &capiMachineSet.Generation) +} + +// convertCAPIToMAPIMachineSet converts a CAPI MachineSet to a MAPI MachineSet, selecting the correct converter based on the platform. +func (r *MachineSetSyncReconciler) convertCAPIToMAPIMachineSet(capiMachineSet *capiv1beta1.MachineSet, infraMachineTemplate client.Object, infraCluster client.Object) (*machinev1beta1.MachineSet, []string, error) { + switch r.Platform { + case configv1.AWSPlatformType: + awsMachineTemplate, ok := infraMachineTemplate.(*awscapiv1beta1.AWSMachineTemplate) + if !ok { + return nil, nil, fmt.Errorf("%w, expected AWSMachineTemplate, got %T", errUnexpectedInfraMachineTemplateType, infraMachineTemplate) + } + + awsCluster, ok := infraCluster.(*awscapiv1beta1.AWSCluster) + if !ok { + return nil, nil, fmt.Errorf("%w, expected AWSCluster, got %T", errUnexpectedInfraClusterType, infraCluster) + } + + return capi2mapi.FromMachineSetAndAWSMachineTemplateAndAWSCluster( //nolint: wrapcheck + capiMachineSet, awsMachineTemplate, awsCluster, + ).ToMachineSet() + + default: + return nil, nil, fmt.Errorf("%w: %s", errPlatformNotSupported, r.Platform) + } } // updateSynchronizedConditionWithPatch updates the synchronized condition @@ -352,7 +387,7 @@ func setLastTransitionTime(condType machinev1beta1.ConditionType, conditions []m // hasSameState returns true if a condition has the same state as a condition // apply config; state is defined by the union of following fields: Type, -// Status, Reason, Severity and Message (it excludes LastTransitionTime). +// Status. func hasSameState(i *machinev1beta1.Condition, j *machinev1applyconfigs.ConditionApplyConfiguration) bool { return i.Type == *j.Type && i.Status == *j.Status @@ -361,9 +396,7 @@ func hasSameState(i *machinev1beta1.Condition, j *machinev1applyconfigs.Conditio // objectMetaIsEqual determines if the two ObjectMeta are equal for the fields we care about // when synchronising MAPI and CAPI MachineSets. func objectMetaIsEqual(a, b metav1.ObjectMeta) bool { - return a.DeletionTimestamp.Equal(b.DeletionTimestamp) && - a.DeletionGracePeriodSeconds == b.DeletionGracePeriodSeconds && - reflect.DeepEqual(a.Labels, b.Labels) && + return reflect.DeepEqual(a.Labels, b.Labels) && reflect.DeepEqual(a.Annotations, b.Annotations) && reflect.DeepEqual(a.Finalizers, b.Finalizers) && reflect.DeepEqual(a.OwnerReferences, b.OwnerReferences) diff --git a/pkg/controllers/machinesetsync/machineset_sync_controller_test.go b/pkg/controllers/machinesetsync/machineset_sync_controller_test.go index a5e06bba3..afb4f62ef 100644 --- a/pkg/controllers/machinesetsync/machineset_sync_controller_test.go +++ b/pkg/controllers/machinesetsync/machineset_sync_controller_test.go @@ -41,7 +41,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" ) -var _ = Describe("With a running controller", func() { +var _ = Describe("With a running MachineSetSync controller", func() { var mgrCancel context.CancelFunc var mgrDone chan struct{} var mgr manager.Manager @@ -50,7 +50,7 @@ var _ = Describe("With a running controller", func() { var syncControllerNamespace *corev1.Namespace var capiNamespace *corev1.Namespace - var MapiNamespace *corev1.Namespace + var mapiNamespace *corev1.Namespace var mapiMachineSetBuilder machinev1resourcebuilder.MachineSetBuilder var mapiMachineSet *machinev1beta1.MachineSet @@ -90,9 +90,9 @@ var _ = Describe("With a running controller", func() { WithGenerateName("machineset-sync-controller-").Build() Expect(k8sClient.Create(ctx, syncControllerNamespace)).To(Succeed()) - MapiNamespace = corev1resourcebuilder.Namespace(). + mapiNamespace = corev1resourcebuilder.Namespace(). WithGenerateName("openshift-machine-api-").Build() - Expect(k8sClient.Create(ctx, MapiNamespace)).To(Succeed()) + Expect(k8sClient.Create(ctx, mapiNamespace)).To(Succeed()) capiNamespace = corev1resourcebuilder.Namespace(). WithGenerateName("openshift-cluster-api-").Build() @@ -100,7 +100,7 @@ var _ = Describe("With a running controller", func() { By("Setting up the builders") mapiMachineSetBuilder = machinev1resourcebuilder.MachineSet(). - WithNamespace(MapiNamespace.GetName()). + WithNamespace(mapiNamespace.GetName()). WithName("foo"). WithProviderSpecBuilder(machinev1resourcebuilder.AWSProviderSpec()) @@ -150,7 +150,7 @@ var _ = Describe("With a running controller", func() { Client: mgr.GetClient(), Platform: configv1.AWSPlatformType, CAPINamespace: capiNamespace.GetName(), - MAPINamespace: MapiNamespace.GetName(), + MAPINamespace: mapiNamespace.GetName(), } Expect(reconciler.SetupWithManager(mgr)).To(Succeed(), "Reconciler should be able to setup with manager")