From 3e683005afb57ffb95c92884060c7fa4b333c96a Mon Sep 17 00:00:00 2001 From: Honza Pokorny Date: Thu, 13 Jun 2024 14:42:08 -0300 Subject: [PATCH] Add metal3 support --- cmd/cluster-capi-operator/main.go | 13 +- e2e/e2e_test.go | 2 + e2e/go.mod | 2 + e2e/go.sum | 4 + .../cluster-api-provider-metal3/api/LICENSE | 201 ++ .../api/v1beta1/common_types.go | 109 ++ .../api/v1beta1/condition_consts.go | 79 + .../api/v1beta1/conversion.go | 34 + .../api/v1beta1/doc.go | 23 + .../api/v1beta1/groupversion_info.go | 53 + .../api/v1beta1/metal3cluster_types.go | 134 ++ .../api/v1beta1/metal3cluster_webhook.go | 75 + .../api/v1beta1/metal3data_types.go | 98 + .../api/v1beta1/metal3data_webhook.go | 152 ++ .../api/v1beta1/metal3dataclaim_types.go | 77 + .../api/v1beta1/metal3dataclaim_webhook.go | 103 + .../api/v1beta1/metal3datatemplate_types.go | 580 ++++++ .../api/v1beta1/metal3datatemplate_webhook.go | 113 ++ .../api/v1beta1/metal3machine_types.go | 213 ++ .../api/v1beta1/metal3machine_webhook.go | 64 + .../v1beta1/metal3machinetemplate_types.go | 68 + .../v1beta1/metal3machinetemplate_webhook.go | 64 + .../api/v1beta1/metal3remediation_types.go | 125 ++ .../api/v1beta1/metal3remediation_webhook.go | 103 + .../metal3remediationtemplate_types.go | 70 + .../metal3remediationtemplate_webhook.go | 129 ++ .../api/v1beta1/zz_generated.deepcopy.go | 1719 +++++++++++++++++ .../metal3-io/ip-address-manager/api/LICENSE | 201 ++ .../api/v1alpha1/common_types.go | 41 + .../api/v1alpha1/conversion.go | 21 + .../ip-address-manager/api/v1alpha1/doc.go | 23 + .../api/v1alpha1/groupversion_info.go | 53 + .../api/v1alpha1/ipaddress_types.go | 77 + .../api/v1alpha1/ipaddress_webhook.go | 159 ++ .../api/v1alpha1/ipclaim_types.go | 73 + .../api/v1alpha1/ipclaim_webhook.go | 103 + .../api/v1alpha1/ippool_types.go | 120 ++ .../api/v1alpha1/ippool_webhook.go | 176 ++ .../ip-address-manager/api/v1alpha1/utils.go | 124 ++ .../api/v1alpha1/zz_generated.deepcopy.go | 380 ++++ e2e/vendor/modules.txt | 6 + go.mod | 3 + go.sum | 4 + ...30_cluster-api_00_credentials-request.yaml | 17 + ...00_30_cluster-api_01_images.configmap.yaml | 1 + manifests/image-references | 4 + pkg/webhook/cluster.go | 8 +- .../cluster-api-provider-metal3/api/LICENSE | 201 ++ .../api/v1beta1/common_types.go | 109 ++ .../api/v1beta1/condition_consts.go | 79 + .../api/v1beta1/conversion.go | 34 + .../api/v1beta1/doc.go | 23 + .../api/v1beta1/groupversion_info.go | 53 + .../api/v1beta1/metal3cluster_types.go | 134 ++ .../api/v1beta1/metal3cluster_webhook.go | 75 + .../api/v1beta1/metal3data_types.go | 98 + .../api/v1beta1/metal3data_webhook.go | 152 ++ .../api/v1beta1/metal3dataclaim_types.go | 77 + .../api/v1beta1/metal3dataclaim_webhook.go | 103 + .../api/v1beta1/metal3datatemplate_types.go | 580 ++++++ .../api/v1beta1/metal3datatemplate_webhook.go | 113 ++ .../api/v1beta1/metal3machine_types.go | 213 ++ .../api/v1beta1/metal3machine_webhook.go | 64 + .../v1beta1/metal3machinetemplate_types.go | 68 + .../v1beta1/metal3machinetemplate_webhook.go | 64 + .../api/v1beta1/metal3remediation_types.go | 125 ++ .../api/v1beta1/metal3remediation_webhook.go | 103 + .../metal3remediationtemplate_types.go | 70 + .../metal3remediationtemplate_webhook.go | 129 ++ .../api/v1beta1/zz_generated.deepcopy.go | 1719 +++++++++++++++++ .../metal3-io/ip-address-manager/api/LICENSE | 201 ++ .../api/v1alpha1/common_types.go | 41 + .../api/v1alpha1/conversion.go | 21 + .../ip-address-manager/api/v1alpha1/doc.go | 23 + .../api/v1alpha1/groupversion_info.go | 53 + .../api/v1alpha1/ipaddress_types.go | 77 + .../api/v1alpha1/ipaddress_webhook.go | 159 ++ .../api/v1alpha1/ipclaim_types.go | 73 + .../api/v1alpha1/ipclaim_webhook.go | 103 + .../api/v1alpha1/ippool_types.go | 120 ++ .../api/v1alpha1/ippool_webhook.go | 176 ++ .../ip-address-manager/api/v1alpha1/utils.go | 124 ++ .../api/v1alpha1/zz_generated.deepcopy.go | 380 ++++ vendor/modules.txt | 7 + 84 files changed, 11940 insertions(+), 5 deletions(-) create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/LICENSE create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/LICENSE create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go create mode 100644 e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/LICENSE create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go create mode 100644 vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/LICENSE create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go create mode 100644 vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go diff --git a/cmd/cluster-capi-operator/main.go b/cmd/cluster-capi-operator/main.go index df1d2d189..8de41ca78 100644 --- a/cmd/cluster-capi-operator/main.go +++ b/cmd/cluster-capi-operator/main.go @@ -7,6 +7,7 @@ import ( "os" "time" + metal3v1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1" "github.com/spf13/pflag" admissionregistrationv1 "k8s.io/api/admissionregistration/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -108,6 +109,7 @@ func init() { utilruntime.Must(clusterctlv1.AddToScheme(scheme)) utilruntime.Must(ibmpowervsv1.AddToScheme(scheme)) utilruntime.Must(vspherev1.AddToScheme(scheme)) + utilruntime.Must(metal3v1.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme } @@ -194,7 +196,8 @@ func main() { configv1.GCPPlatformType, configv1.PowerVSPlatformType, configv1.VSpherePlatformType, - configv1.OpenStackPlatformType: + configv1.OpenStackPlatformType, + configv1.BareMetalPlatformType: setupReconcilers(mgr, platform, containerImages, applyClient, apiextensionsClient) setupWebhooks(mgr) default: @@ -322,6 +325,14 @@ func setupInfraClusterReconciler(mgr manager.Manager, platform configv1.Platform klog.Error(err, "unable to create controller", "controller", "VSphereCluster") os.Exit(1) } + case configv1.BareMetalPlatformType: + if err := (&cluster.GenericInfraClusterReconciler{ + ClusterOperatorStatusClient: getClusterOperatorStatusClient(mgr, "cluster-capi-operator-infra-cluster-resource-controller"), + InfraCluster: &metal3v1.Metal3Cluster{}, + }).SetupWithManager(mgr); err != nil { + klog.Error(err, "unable to create controller", "controller", "Metal3Cluster") + os.Exit(1) + } default: klog.Infof("detected platform %q is not supported, skipping InfraCluster controller setup", platform) } diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 35bc15489..266a77e8d 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -4,6 +4,7 @@ import ( "context" "testing" + metal3v1 "github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -41,6 +42,7 @@ func init() { utilruntime.Must(mapiv1.AddToScheme(scheme.Scheme)) utilruntime.Must(ibmpowervsv1.AddToScheme(scheme.Scheme)) utilruntime.Must(vspherev1.AddToScheme(scheme.Scheme)) + utilruntime.Must(metal3v1.AddToScheme(scheme.Scheme)) } func TestAPIs(t *testing.T) { diff --git a/e2e/go.mod b/e2e/go.mod index 37b8267c9..d5085a230 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -5,6 +5,7 @@ go 1.21 require ( github.com/aws/aws-sdk-go v1.51.17 github.com/google/go-cmp v0.6.0 + github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0 github.com/onsi/ginkgo/v2 v2.19.0 github.com/onsi/gomega v1.33.1 github.com/openshift/api v0.0.0-20220921125526-1866ef90edbf @@ -59,6 +60,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/metal3-io/ip-address-manager/api v1.7.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 857ae49d3..413a3fa4a 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -98,6 +98,10 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0 h1:9ALpFlMFacUTCZVChphg49xU/urSB+vvlAlxuICWLqU= +github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0/go.mod h1:c0M3xS4zQxJpHDVNEb53wLdbYa0/kuWJHw6d9a9CjGQ= +github.com/metal3-io/ip-address-manager/api v1.7.0 h1:ie9SQPWDWTjBnnxnG+qSfoqIOs+4vp5k0tVI+/0HNGo= +github.com/metal3-io/ip-address-manager/api v1.7.0/go.mod h1:6q41s9Y1P1lGSlMxMwRbIFzfy/XBRX4stvugGx1Jp5o= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/LICENSE b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/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/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go new file mode 100644 index 000000000..a71d3a758 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go @@ -0,0 +1,109 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + "net/url" + "strings" + + "k8s.io/apimachinery/pkg/selection" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +const ( + // UnhealthyAnnotation is the annotation that sets unhealthy status of BMH. + UnhealthyAnnotation = "capi.metal3.io/unhealthy" + + LiveISODiskFormat = "live-iso" +) + +// APIEndpoint represents a reachable Kubernetes API endpoint. +type APIEndpoint struct { + // Host is the hostname on which the API server is serving. + Host string `json:"host"` + + // Port is the port on which the API server is serving. + Port int `json:"port"` +} + +// HostSelector specifies matching criteria for labels on BareMetalHosts. +// This is used to limit the set of BareMetalHost objects considered for +// claiming for a Machine. +type HostSelector struct { + // Key/value pairs of labels that must exist on a chosen BareMetalHost + // +optional + MatchLabels map[string]string `json:"matchLabels,omitempty"` + + // Label match expressions that must be true on a chosen BareMetalHost + // +optional + MatchExpressions []HostSelectorRequirement `json:"matchExpressions,omitempty"` +} + +type HostSelectorRequirement struct { + Key string `json:"key"` + Operator selection.Operator `json:"operator"` + Values []string `json:"values"` +} + +// Image holds the details of an image to use during provisioning. +type Image struct { + // URL is a location of an image to deploy. + URL string `json:"url"` + + // Checksum is a md5sum, sha256sum or sha512sum value or a URL to retrieve one. + Checksum string `json:"checksum"` + + // ChecksumType is the checksum algorithm for the image. + // e.g md5, sha256, sha512 + // +kubebuilder:validation:Enum=md5;sha256;sha512 + // +optional + ChecksumType *string `json:"checksumType,omitempty"` + + // DiskFormat contains the image disk format. + // +kubebuilder:validation:Enum=raw;qcow2;vdi;vmdk;live-iso + // +optional + DiskFormat *string `json:"format,omitempty"` +} + +// Validate performs validation on [Image], returning a list of field errors using the provided base path. +// It is intended to be used in the validation webhooks of resources containing [Image]. +func (i *Image) Validate(base field.Path) field.ErrorList { + var errors field.ErrorList + + if i.URL == "" { + errors = append(errors, field.Required(base.Child("URL"), "cannot be empty")) + } else { + _, err := url.ParseRequestURI(i.URL) + if err != nil { + errors = append(errors, field.Invalid(base.Child("URL"), i.URL, "not a valid URL")) + } + } + // Checksum is not required for live-iso. + if i.DiskFormat == nil || *i.DiskFormat != LiveISODiskFormat { + if i.Checksum == "" { + errors = append(errors, field.Required(base.Child("Checksum"), "cannot be empty")) + } + + if strings.HasPrefix(i.Checksum, "http://") || strings.HasPrefix(i.Checksum, "https://") { + _, err := url.ParseRequestURI(i.Checksum) + if err != nil { + errors = append(errors, field.Invalid(base.Child("Checksum"), i.Checksum, "not a valid URL")) + } + } + } + return errors +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go new file mode 100644 index 000000000..38c4c5e1f --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go @@ -0,0 +1,79 @@ +/* +Copyright 2021 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 v1beta1 + +import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + +// Metal3Cluster Conditions and Reasons. +const ( + // BaremetalInfrastructureReadyCondition reports the current status of + // cluster infrastructure. At the moment this is cosmetic since + // Metal3Cluster does not contain any infra setup steps. + BaremetalInfrastructureReadyCondition clusterv1.ConditionType = "BaremetalInfrastructureReady" + // ControlPlaneEndpointFailedReason is used to indicate that provided ControlPlaneEndpoint is invalid. + ControlPlaneEndpointFailedReason = "ControlPlaneEndpointFailed" + // InternalFailureReason is used to indicate that an internal failure + // occurred. The `Message` field of the Condition should be consluted for + // details on the failure. + InternalFailureReason = "InternalFailureOccured" +) + +// Metal3Machine Conditions and Reasons. +const ( + // AssociateBMHCondition documents the status of associated the Metal3Machine with a BaremetalHost. + AssociateBMHCondition clusterv1.ConditionType = "AssociateBMH" + + // WaitingForClusterInfrastructureReason used when waiting for cluster + // infrastructure to be ready before proceeding. + WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure" + // WaitingForBootstrapReadyReason used when waiting for bootstrap to be ready before proceeding. + WaitingForBootstrapReadyReason = "WaitingForBootstrapReady" + // AssociateBMHFailedReason documents any errors while associating Metal3Machine with a BaremetalHost. + AssociateBMHFailedReason = "AssociateBMHFailed" + // WaitingForMetal3MachineOwnerRefReason is used when Metal3Machine is waiting for OwnerReference to be + // set before proceeding. + WaitingForMetal3MachineOwnerRefReason = "WaitingForM3MachineOwnerRef" + // Metal3MachinePausedReason is used when Metal3Machine or Cluster is paused. + Metal3MachinePausedReason = "Metal3MachinePaused" + // WaitingforMetal3ClusterReason is used when Metal3Machine is waiting for Metal3Cluster. + WaitingforMetal3ClusterReason = "WaitingforMetal3Cluster" + // PauseAnnotationRemoveFailedReason is used when failed to remove/check pause annotation on associated bmh. + PauseAnnotationRemoveFailedReason = "PauseAnnotationRemoveFailed" + // PauseAnnotationSetFailedReason is used when failed to set pause annotation on associated bmh. + PauseAnnotationSetFailedReason = "PauseAnnotationSetFailedReason" + + // KubernetesNodeReadyCondition documents the transition of a Metal3Machine into a Kubernetes Node. + KubernetesNodeReadyCondition clusterv1.ConditionType = "KubernetesNodeReady" + // Could not find the BMH associated with the Metal3Machine. + MissingBMHReason = "MissingBMH" + // Could not set the ProviderID on the target cluster's Node object. + SettingProviderIDOnNodeFailedReason = "SettingProviderIDOnNodeFailed" + // Metal3DataReadyCondition reports a summary of Metal3Data status. + Metal3DataReadyCondition clusterv1.ConditionType = "Metal3DataReady" + // WaitingForMetal3DataReason used when waiting for Metal3Data + // to be ready before proceeding. + WaitingForMetal3DataReason = "WaitingForMetal3Data" + // AssociateM3MetaDataFailedReason is used when failed to associate Metadata to Metal3Machine. + AssociateM3MetaDataFailedReason = "AssociateM3MetaDataFailed" + // DisassociateM3MetaDataFailedReason is used when failed to remove OwnerReference of Meta3DataTemplate. + DisassociateM3MetaDataFailedReason = "DisassociateM3MetaDataFailed" + // DeletingReason (Severity=Info) documents a condition not in Status=True because the underlying object it is currently being deleted. + DeletingReason = "Deleting" + // DeletionFailedReason (Severity=Warning) documents a condition not in Status=True because the underlying object + // encountered problems during deletion. This is a warning because the reconciler will retry deletion. + DeletionFailedReason = "DeletionFailed" +) diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go new file mode 100644 index 000000000..acdbd86e5 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2021 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 v1beta1 + +func (*Metal3Cluster) Hub() {} +func (*Metal3ClusterList) Hub() {} +func (*Metal3Machine) Hub() {} +func (*Metal3MachineList) Hub() {} +func (*Metal3MachineTemplate) Hub() {} +func (*Metal3MachineTemplateList) Hub() {} +func (*Metal3DataTemplate) Hub() {} +func (*Metal3DataTemplateList) Hub() {} +func (*Metal3Data) Hub() {} +func (*Metal3DataList) Hub() {} +func (*Metal3DataClaim) Hub() {} +func (*Metal3DataClaimList) Hub() {} +func (*Metal3Remediation) Hub() {} +func (*Metal3RemediationList) Hub() {} +func (*Metal3RemediationTemplate) Hub() {} +func (*Metal3RemediationTemplateList) Hub() {} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go new file mode 100644 index 000000000..94982651f --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2021 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 v1beta1 contains API Schema definitions for the metal3 v1beta1 API group +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +kubebuilder:object:generate=true +// +groupName=infrastructure.cluster.x-k8s.io +package v1beta1 diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go new file mode 100644 index 000000000..ba88602fc --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go @@ -0,0 +1,53 @@ +/* +Copyright 2021 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 v1beta1 contains API Schema definitions for the infrastructure v1beta1 API group +// +kubebuilder:object:generate=true +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +groupName=infrastructure.cluster.x-k8s.io +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta1"} + + /// schemeBuilder is used to add go types to the GroupVersionKind scheme. + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = schemeBuilder.AddToScheme + + objectTypes = []runtime.Object{} +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, objectTypes...) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} + +// Resource is required by pkg/client/listers/... +// func Resource(resource string) schema.GroupResource { +// return SchemeGroupVersion.WithResource(resource).GroupResource() +// } diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go new file mode 100644 index 000000000..365447f2e --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go @@ -0,0 +1,134 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + "github.com/pkg/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + capierrors "sigs.k8s.io/cluster-api/errors" +) + +const ( + // ClusterFinalizer allows Metal3ClusterReconciler to clean up resources associated with Metal3Cluster before + // removing it from the apiserver. + ClusterFinalizer = "metal3cluster.infrastructure.cluster.x-k8s.io" +) + +// Metal3ClusterSpec defines the desired state of Metal3Cluster. +type Metal3ClusterSpec struct { + // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. + // +optional + ControlPlaneEndpoint APIEndpoint `json:"controlPlaneEndpoint,omitempty"` + // Determines if the cluster is not to be deployed with an external cloud provider. + // If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes. + // If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource. + // +optional + NoCloudProvider bool `json:"noCloudProvider,omitempty"` +} + +// IsValid returns an error if the object is not valid, otherwise nil. The +// string representation of the error is suitable for human consumption. +func (s *Metal3ClusterSpec) IsValid() error { + missing := []string{} + if s.ControlPlaneEndpoint.Host == "" { + missing = append(missing, "ControlPlaneEndpoint.Host") + } + + if s.ControlPlaneEndpoint.Port == 0 { + missing = append(missing, "ControlPlaneEndpoint.Host") + } + + if len(missing) > 0 { + return errors.Errorf("Missing fields from Spec: %v", missing) + } + return nil +} + +// Metal3ClusterStatus defines the observed state of Metal3Cluster. +type Metal3ClusterStatus struct { + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // FailureReason indicates that there is a fatal problem reconciling the + // state, and will be set to a token value suitable for + // programmatic interpretation. + // +optional + FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"` + + // FailureMessage indicates that there is a fatal problem reconciling the + // state, and will be set to a descriptive error message. + // +optional + FailureMessage *string `json:"failureMessage,omitempty"` + + // Ready denotes that the Metal3 cluster (infrastructure) is ready. In + // Baremetal case, it does not mean anything for now as no infrastructure + // steps need to be performed. Required by Cluster API. Set to True by the + // metal3Cluster controller after creation. + // +optional + Ready bool `json:"ready"` + // Conditions defines current service state of the Metal3Cluster. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3clusters,scope=Namespaced,categories=cluster-api,shortName=m3c;m3cluster;m3clusters;metal3c;metal3cluster +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3Cluster" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="metal3Cluster is Ready" +// +kubebuilder:printcolumn:name="Error",type="string",JSONPath=".status.failureReason",description="Most recent error" +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this BMCluster belongs" +// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.controlPlaneEndpoint",description="Control plane endpoint" + +// Metal3Cluster is the Schema for the metal3clusters API. +type Metal3Cluster struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Spec Metal3ClusterSpec `json:"spec,omitempty"` + // +optional + Status Metal3ClusterStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3ClusterList contains a list of Metal3Cluster. +type Metal3ClusterList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Cluster `json:"items"` +} + +// GetConditions returns the list of conditions for an Metal3Cluster API object. +func (c *Metal3Cluster) GetConditions() clusterv1.Conditions { + return c.Status.Conditions +} + +// SetConditions will set the given conditions on an Metal3Cluster object. +func (c *Metal3Cluster) SetConditions(conditions clusterv1.Conditions) { + c.Status.Conditions = conditions +} + +func init() { + objectTypes = append(objectTypes, &Metal3Cluster{}, &Metal3ClusterList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go new file mode 100644 index 000000000..c7aa82218 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go @@ -0,0 +1,75 @@ +/* +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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3Cluster) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3cluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3clusters,versions=v1beta1,name=validation.metal3cluster.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3cluster,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3clusters,versions=v1beta1,name=default.metal3cluster.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Cluster{} +var _ webhook.Validator = &Metal3Cluster{} + +func (c *Metal3Cluster) Default() { + if c.Spec.ControlPlaneEndpoint.Port == 0 { + c.Spec.ControlPlaneEndpoint.Port = 6443 + } +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Cluster) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Cluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Cluster) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3Cluster) validate() error { + var allErrs field.ErrorList + if c.Spec.ControlPlaneEndpoint.Host == "" { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "controlPlaneEndpoint"), + c.Spec.ControlPlaneEndpoint.Host, + "is required", + ), + ) + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Cluster").GroupKind(), c.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go new file mode 100644 index 000000000..215238862 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go @@ -0,0 +1,98 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataFinalizer allows Metal3DataReconciler to clean up resources + // associated with Metal3Data before removing it from the apiserver. + DataFinalizer = "metal3data.infrastructure.cluster.x-k8s.io" +) + +// Metal3DataSpec defines the desired state of Metal3Data. +type Metal3DataSpec struct { + // Index stores the index value of this instance in the Metal3DataTemplate. + // +optional + Index int `json:"index,omitempty"` + + // TemplateReference refers to the Template the Metal3MachineTemplate refers to. + // It can be matched against the key or it may also point to the name of the template + // Metal3Data refers to + // +optional + TemplateReference string `json:"templateReference,omitempty"` + + // MetaData points to the rendered MetaData secret. + // +optional + MetaData *corev1.SecretReference `json:"metaData,omitempty"` + + // NetworkData points to the rendered NetworkData secret. + // +optional + NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + + // DataClaim points to the Metal3DataClaim the Metal3Data was created for. + Claim corev1.ObjectReference `json:"claim"` + + // DataTemplate is the Metal3DataTemplate this was generated from. + Template corev1.ObjectReference `json:"template"` +} + +// Metal3DataStatus defines the observed state of Metal3Data. +type Metal3DataStatus struct { + // Ready is a flag set to True if the secrets were rendered properly + // +optional + Ready bool `json:"ready"` + + // ErrorMessage contains the error message + // +optional + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3datas,scope=Namespaced,categories=cluster-api,shortName=m3d;m3data;m3datas;metal3d;metal3data +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3Data" +// Metal3Data is the Schema for the metal3datas API. +type Metal3Data struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3DataSpec `json:"spec,omitempty"` + // +optional + Status Metal3DataStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3DataList contains a list of Metal3Data. +type Metal3DataList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Data `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3Data{}, &Metal3DataList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go new file mode 100644 index 000000000..9e6811846 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go @@ -0,0 +1,152 @@ +/* +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 v1beta1 + +import ( + "strconv" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3Data) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3data,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datas,versions=v1beta1,name=validation.metal3data.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3data,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datas,versions=v1beta1,name=default.metal3data.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Data{} +var _ webhook.Validator = &Metal3Data{} + +func (c *Metal3Data) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Data) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if (c.Spec.TemplateReference != "" && c.Name != c.Spec.TemplateReference+"-"+strconv.Itoa(c.Spec.Index)) || + (c.Spec.TemplateReference == "" && c.Name != c.Spec.Template.Name+"-"+strconv.Itoa(c.Spec.Index)) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("name"), + c.Name, + "should follow the convention -", + ), + ) + } + + if c.Spec.Index < 0 { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Index"), + c.Spec.Index, + "must be positive value", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Data) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldMetal3Data, ok := old.(*Metal3Data) + if !ok || oldMetal3Data == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Index != oldMetal3Data.Spec.Index { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Index"), + c.Spec.Index, + "cannot be modified", + ), + ) + } + + if c.Spec.Template.Name != oldMetal3Data.Spec.Template.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Namespace != oldMetal3Data.Spec.Template.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Kind != oldMetal3Data.Spec.Template.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } + + if c.Spec.Claim.Name != oldMetal3Data.Spec.Claim.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Namespace != oldMetal3Data.Spec.Claim.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Kind != oldMetal3Data.Spec.Claim.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Data) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go new file mode 100644 index 000000000..dd7345d84 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go @@ -0,0 +1,77 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataClaimFinalizer allows Metal3DataReconciler to clean up resources + // associated with Metal3DataClaim before removing it from the apiserver. + DataClaimFinalizer = "metal3dataclaim.infrastructure.cluster.x-k8s.io" +) + +// Metal3DataClaimSpec defines the desired state of Metal3DataClaim. +type Metal3DataClaimSpec struct { + // Template is the Metal3DataTemplate this was generated for. + Template corev1.ObjectReference `json:"template"` +} + +// Metal3DataClaimStatus defines the observed state of Metal3DataClaim. +type Metal3DataClaimStatus struct { + // RenderedData references the Metal3Data when ready + // +optional + RenderedData *corev1.ObjectReference `json:"renderedData,omitempty"` + + // ErrorMessage contains the error message + // +optional + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3dataclaims,scope=Namespaced,categories=cluster-api,shortName=m3dc;m3dataclaim;m3dataclaims;metal3dc;metal3dataclaim +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3DataClaim" +// Metal3DataClaim is the Schema for the metal3datas API. +type Metal3DataClaim struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3DataClaimSpec `json:"spec,omitempty"` + // +optional + Status Metal3DataClaimStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3DataClaimList contains a list of Metal3DataClaim. +type Metal3DataClaimList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3DataClaim `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3DataClaim{}, &Metal3DataClaimList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go new file mode 100644 index 000000000..32d7978f9 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go @@ -0,0 +1,103 @@ +/* +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 v1beta1 + +import ( + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3DataClaim) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3dataclaim,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3dataclaims,versions=v1beta1,name=validation.metal3dataclaim.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3dataclaim,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3dataclaims,versions=v1beta1,name=default.metal3dataclaim.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3DataClaim{} +var _ webhook.Validator = &Metal3DataClaim{} + +func (c *Metal3DataClaim) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataClaim) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if c.Spec.Template.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template", "name"), + c.Spec.Template.Name, + "must be set", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataClaim) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldMetal3DataClaim, ok := old.(*Metal3DataClaim) + if !ok || oldMetal3DataClaim == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Template.Name != oldMetal3DataClaim.Spec.Template.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Namespace != oldMetal3DataClaim.Spec.Template.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Kind != oldMetal3DataClaim.Spec.Template.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataClaim) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go new file mode 100644 index 000000000..4565596ed --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go @@ -0,0 +1,580 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + ipamv1 "github.com/metal3-io/ip-address-manager/api/v1alpha1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataTemplateFinalizer allows Metal3DataTemplateReconciler to clean up resources + // associated with Metal3DataTemplate before removing it from the apiserver. + DataTemplateFinalizer = "metal3datatemplate.infrastructure.cluster.x-k8s.io" +) + +// MetaDataIndex contains the information to render the index. +type MetaDataIndex struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Offset is the offset to apply to the index when rendering it + // +optional + Offset int `json:"offset,omitempty"` + // +kubebuilder:default=1 + // Step is the multiplier of the index + // +optional + Step int `json:"step,omitempty"` + // Prefix is the prefix string + // +optional + Prefix string `json:"prefix,omitempty"` + // Suffix is the suffix string + // +optional + Suffix string `json:"suffix,omitempty"` +} + +// MetaDataFromLabel contains the information to fetch a label content, if the +// label does not exist, it is rendered as empty string. +type MetaDataFromLabel struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` + // Label is the key of the label to fetch + Label string `json:"label"` +} + +// MetaDataFromAnnotation contains the information to fetch an annotation +// content, if the label does not exist, it is rendered as empty string. +type MetaDataFromAnnotation struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` + // Annotation is the key of the Annotation to fetch + Annotation string `json:"annotation"` +} + +// MetaDataString contains the information to render the string. +type MetaDataString struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Value is the string to render. + Value string `json:"value"` +} + +// MetaDataNamespace contains the information to render the namespace. +type MetaDataNamespace struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` +} + +// MetaDataObjectName contains the information to render the object name. +type MetaDataObjectName struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` +} + +// MetaDataHostInterface contains the information to render the object name. +type MetaDataHostInterface struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Interface is the name of the interface in the BareMetalHost Status Hardware + // Details list of interfaces from which to fetch the MAC address. + Interface string `json:"interface"` +} + +// MetaDataIPAddress contains the info to render th ip address. It is IP-version +// agnostic. +type MetaDataIPAddress struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Start is the first ip address that can be rendered + // +optional + Start *ipamv1.IPAddressStr `json:"start,omitempty"` + // End is the last IP address that can be rendered. It is used as a validation + // that the rendered IP is in bound. + // +optional + End *ipamv1.IPAddressStr `json:"end,omitempty"` + // Subnet is used to validate that the rendered IP is in bounds. In case the + // Start value is not given, it is derived from the subnet ip incremented by 1 + // (`192.168.0.1` for `192.168.0.0/24`) + // +optional + Subnet *ipamv1.IPSubnetStr `json:"subnet,omitempty"` + // +kubebuilder:default=1 + // Step is the step between the IP addresses rendered. + // +optional + Step int `json:"step,omitempty"` +} + +type FromPool struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + + // Name is the name of the IP pool used to fetch the value to set in the metadata map for cloud-init + Name string `json:"name"` + + // APIGroup is the api group of the IP pool. + APIGroup string `json:"apiGroup"` + + // Kind is the kind of the IP pool + Kind string `json:"kind"` +} + +// MetaData represents a keyand value of the metadata. +type MetaData struct { + // Strings is the list of metadata items to be rendered from strings + // +optional + Strings []MetaDataString `json:"strings,omitempty"` + + // ObjectNames is the list of metadata items to be rendered from the name + // of objects. + // +optional + ObjectNames []MetaDataObjectName `json:"objectNames,omitempty"` + + // Indexes is the list of metadata items to be rendered from the index of the + // Metal3Data + // +optional + Indexes []MetaDataIndex `json:"indexes,omitempty"` + + // Namespaces is the list of metadata items to be rendered from the namespace + // +optional + Namespaces []MetaDataNamespace `json:"namespaces,omitempty"` + + // IPAddressesFromPool is the list of metadata items to be rendered as ip addresses. + // +optional + IPAddressesFromPool []FromPool `json:"ipAddressesFromIPPool,omitempty"` + + // PrefixesFromPool is the list of metadata items to be rendered as network prefixes. + // +optional + PrefixesFromPool []FromPool `json:"prefixesFromIPPool,omitempty"` + + // GatewaysFromPool is the list of metadata items to be rendered as gateway addresses. + // +optional + GatewaysFromPool []FromPool `json:"gatewaysFromIPPool,omitempty"` + + // DNSServersFromPool is the list of metadata items to be rendered as dns servers. + // +optional + DNSServersFromPool []FromPool `json:"dnsServersFromIPPool,omitempty"` + + // FromHostInterfaces is the list of metadata items to be rendered as MAC + // addresses of the host interfaces. + // +optional + FromHostInterfaces []MetaDataHostInterface `json:"fromHostInterfaces,omitempty"` + + // FromLabels is the list of metadata items to be fetched from object labels + // +optional + FromLabels []MetaDataFromLabel `json:"fromLabels,omitempty"` + + // FromAnnotations is the list of metadata items to be fetched from object + // Annotations + // +optional + FromAnnotations []MetaDataFromAnnotation `json:"fromAnnotations,omitempty"` +} + +// NetworkLinkEthernetMacFromAnnotation contains the information to fetch an annotation +// content, if the label does not exist, it is rendered as empty string. +type NetworkLinkEthernetMacFromAnnotation struct { + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` + // Annotation is the key of the Annotation to fetch + Annotation string `json:"annotation"` +} + +// NetworkLinkEthernetMac represents the Mac address content. +type NetworkLinkEthernetMac struct { + // String contains the MAC address given as a string + // +optional + String *string `json:"string,omitempty"` + + // FromHostInterface contains the name of the interface in the BareMetalHost + // Introspection details from which to fetch the MAC address + // +optional + FromHostInterface *string `json:"fromHostInterface,omitempty"` + + // FromAnnotation references an object Annotation to retrieve the + // MAC address from + // +optional + FromAnnotation *NetworkLinkEthernetMacFromAnnotation `json:"fromAnnotation,omitempty"` +} + +// NetworkDataLinkEthernet represents an ethernet link object. +type NetworkDataLinkEthernet struct { + // +kubebuilder:validation:Enum=bridge;dvs;hw_veb;hyperv;ovs;tap;vhostuser;vif;phy + // Type is the type of the ethernet link. It can be one of: + // bridge, dvs, hw_veb, hyperv, ovs, tap, vhostuser, vif, phy + Type string `json:"type"` + + // Id is the ID of the interface (used for naming) + Id string `json:"id"` //nolint:revive,stylecheck + + // +kubebuilder:default=1500 + // +kubebuilder:validation:Maximum=9000 + // MTU is the MTU of the interface + // +optional + MTU int `json:"mtu,omitempty"` + + // MACAddress is the MAC address of the interface, containing the object + // used to render it. + MACAddress *NetworkLinkEthernetMac `json:"macAddress"` +} + +// NetworkDataLinkBond represents a bond link object. +type NetworkDataLinkBond struct { + // +kubebuilder:validation:Enum="balance-rr";"active-backup";"balance-xor";"broadcast";"balance-tlb";"balance-alb";"802.3ad" + // BondMode is the mode of bond used. It can be one of + // balance-rr, active-backup, balance-xor, broadcast, balance-tlb, balance-alb, 802.3ad + BondMode string `json:"bondMode"` + + // +kubebuilder:validation:Enum="layer2";"layer3+4";"layer2+3" + // Selects the transmit hash policy used for port selection in balance-xor and 802.3ad modes + // +optional + BondXmitHashPolicy string `json:"bondXmitHashPolicy"` + + // Id is the ID of the interface (used for naming) + Id string `json:"id"` //nolint:revive,stylecheck + + // +kubebuilder:default=1500 + // +kubebuilder:validation:Maximum=9000 + // MTU is the MTU of the interface + // +optional + MTU int `json:"mtu,omitempty"` + + // MACAddress is the MAC address of the interface, containing the object + // used to render it. + MACAddress *NetworkLinkEthernetMac `json:"macAddress"` + + // BondLinks is the list of links that are part of the bond. + // +optional + BondLinks []string `json:"bondLinks"` +} + +// NetworkDataLinkVlan represents a vlan link object. +type NetworkDataLinkVlan struct { + // +kubebuilder:validation:Maximum=4096 + // VlanID is the Vlan ID + VlanID int `json:"vlanID"` + + // Id is the ID of the interface (used for naming) + Id string `json:"id"` //nolint:revive,stylecheck + + // +kubebuilder:default=1500 + // +kubebuilder:validation:Maximum=9000 + // MTU is the MTU of the interface + // +optional + MTU int `json:"mtu,omitempty"` + + // MACAddress is the MAC address of the interface, containing the object + // used to render it. + MACAddress *NetworkLinkEthernetMac `json:"macAddress"` + + // VlanLink is the name of the link on which the vlan should be added + VlanLink string `json:"vlanLink"` +} + +// NetworkDataLink contains list of different link objects. +type NetworkDataLink struct { + + // Ethernets contains a list of Ethernet links + // +optional + Ethernets []NetworkDataLinkEthernet `json:"ethernets,omitempty"` + + // Bonds contains a list of Bond links + // +optional + Bonds []NetworkDataLinkBond `json:"bonds,omitempty"` + + // Vlans contains a list of Vlan links + // +optional + Vlans []NetworkDataLinkVlan `json:"vlans,omitempty"` +} + +// NetworkDataService represents a service object. +type NetworkDataService struct { + + // DNS is a list of DNS services + // +optional + DNS []ipamv1.IPAddressStr `json:"dns,omitempty"` + + // DNSFromIPPool is the name of the IPPool from which to get the DNS servers + // +optional + DNSFromIPPool *string `json:"dnsFromIPPool,omitempty"` +} + +// NetworkDataServicev4 represents a service object. +type NetworkDataServicev4 struct { + // DNS is a list of IPv4 DNS services + // +optional + DNS []ipamv1.IPAddressv4Str `json:"dns,omitempty"` + + // DNSFromIPPool is the name of the IPPool from which to get the DNS servers + // +optional + DNSFromIPPool *string `json:"dnsFromIPPool,omitempty"` +} + +// NetworkDataServicev6 represents a service object. +type NetworkDataServicev6 struct { + // DNS is a list of IPv6 DNS services + // +optional + DNS []ipamv1.IPAddressv6Str `json:"dns,omitempty"` + + // DNSFromIPPool is the name of the IPPool from which to get the DNS servers + // +optional + DNSFromIPPool *string `json:"dnsFromIPPool,omitempty"` +} + +// NetworkGatewayv4 represents a gateway, given as a string or as a reference to +// a Metal3IPPool. +type NetworkGatewayv4 struct { + + // String is the gateway given as a string + // +optional + String *ipamv1.IPAddressv4Str `json:"string,omitempty"` + + // FromIPPool is the name of the IPPool to fetch the gateway from + // +optional + FromIPPool *string `json:"fromIPPool,omitempty"` +} + +// NetworkGatewayv6 represents a gateway, given as a string or as a reference to +// a Metal3IPPool. +type NetworkGatewayv6 struct { + + // String is the gateway given as a string + // +optional + String *ipamv1.IPAddressv6Str `json:"string,omitempty"` + + // FromIPPool is the name of the IPPool to fetch the gateway from + // +optional + FromIPPool *string `json:"fromIPPool,omitempty"` +} + +// NetworkDataRoutev4 represents an ipv4 route object. +type NetworkDataRoutev4 struct { + // Network is the IPv4 network address + Network ipamv1.IPAddressv4Str `json:"network"` + + // +kubebuilder:validation:Maximum=32 + // Prefix is the mask of the network as integer (max 32) + // +optional + Prefix int `json:"prefix,omitempty"` + + // Gateway is the IPv4 address of the gateway + Gateway NetworkGatewayv4 `json:"gateway"` + + // Services is a list of IPv4 services + // +optional + Services NetworkDataServicev4 `json:"services,omitempty"` +} + +// NetworkDataRoutev6 represents an ipv6 route object. +type NetworkDataRoutev6 struct { + // Network is the IPv6 network address + Network ipamv1.IPAddressv6Str `json:"network"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + // +optional + Prefix int `json:"prefix,omitempty"` + + // Gateway is the IPv6 address of the gateway + Gateway NetworkGatewayv6 `json:"gateway"` + + // Services is a list of IPv6 services + // +optional + Services NetworkDataServicev6 `json:"services,omitempty"` +} + +// NetworkDataIPv4 represents an ipv4 static network object. +type NetworkDataIPv4 struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // IPAddressFromIPPool contains the name of the IP pool to use to get an ip address + IPAddressFromIPPool string `json:"ipAddressFromIPPool,omitempty"` + + // FromPoolRef is a reference to a IP pool to allocate an address from. + FromPoolRef *corev1.TypedLocalObjectReference `json:"fromPoolRef,omitempty"` + + // Routes contains a list of IPv4 routes + // +optional + Routes []NetworkDataRoutev4 `json:"routes,omitempty"` +} + +// NetworkDataIPv6 represents an ipv6 static network object. +type NetworkDataIPv6 struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // IPAddressFromIPPool contains the name of the IPPool to use to get an ip address + IPAddressFromIPPool string `json:"ipAddressFromIPPool"` + + // FromPoolRef is a reference to a IP pool to allocate an address from. + FromPoolRef *corev1.TypedLocalObjectReference `json:"fromPoolRef,omitempty"` + + // Routes contains a list of IPv6 routes + // +optional + Routes []NetworkDataRoutev6 `json:"routes,omitempty"` +} + +// NetworkDataIPv4DHCP represents an ipv4 DHCP network object. +type NetworkDataIPv4DHCP struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // Routes contains a list of IPv4 routes + // +optional + Routes []NetworkDataRoutev4 `json:"routes,omitempty"` +} + +// NetworkDataIPv6DHCP represents an ipv6 DHCP network object. +type NetworkDataIPv6DHCP struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // Routes contains a list of IPv6 routes + // +optional + Routes []NetworkDataRoutev6 `json:"routes,omitempty"` +} + +// NetworkDataNetwork represents a network object. +type NetworkDataNetwork struct { + + // IPv4 contains a list of IPv4 static allocations + // +optional + IPv4 []NetworkDataIPv4 `json:"ipv4,omitempty"` + + // IPv4 contains a list of IPv6 static allocations + // +optional + IPv6 []NetworkDataIPv6 `json:"ipv6,omitempty"` + + // IPv4 contains a list of IPv4 DHCP allocations + // +optional + IPv4DHCP []NetworkDataIPv4DHCP `json:"ipv4DHCP,omitempty"` + + // IPv4 contains a list of IPv6 DHCP allocations + // +optional + IPv6DHCP []NetworkDataIPv6DHCP `json:"ipv6DHCP,omitempty"` + + // IPv4 contains a list of IPv6 SLAAC allocations + // +optional + IPv6SLAAC []NetworkDataIPv6DHCP `json:"ipv6SLAAC,omitempty"` +} + +// NetworkData represents a networkData object. +type NetworkData struct { + // Links is a structure containing lists of different types objects + // +optional + Links NetworkDataLink `json:"links,omitempty"` + + // Networks is a structure containing lists of different types objects + // +optional + Networks NetworkDataNetwork `json:"networks,omitempty"` + + // Services is a structure containing lists of different types objects + // +optional + Services NetworkDataService `json:"services,omitempty"` +} + +// Metal3DataTemplateSpec defines the desired state of Metal3DataTemplate. +type Metal3DataTemplateSpec struct { + + // ClusterName is the name of the Cluster this object belongs to. + // +kubebuilder:validation:MinLength=1 + ClusterName string `json:"clusterName"` + + // TemplateReference refers to the Template the Metal3MachineTemplate refers to. + // It can be matched against the key or it may also point to the name of the template + // Metal3Data refers to + // +optional + TemplateReference string `json:"templateReference,omitempty"` + + // MetaData contains the information needed to generate the metadata secret + // +optional + MetaData *MetaData `json:"metaData,omitempty"` + + // NetworkData contains the information needed to generate the networkdata + // secret + // +optional + NetworkData *NetworkData `json:"networkData,omitempty"` +} + +// Metal3DataTemplateStatus defines the observed state of Metal3DataTemplate. +type Metal3DataTemplateStatus struct { + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // Indexes contains the map of Metal3Machine and index used + // +optional + Indexes map[string]int `json:"indexes,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3datatemplates,scope=Namespaced,categories=cluster-api,shortName=m3dt;m3datatemplate;m3datatemplates;metal3dt;metal3datatemplate +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this template belongs" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3DataTemplate" + +// Metal3DataTemplate is the Schema for the metal3datatemplates API. +type Metal3DataTemplate struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3DataTemplateSpec `json:"spec,omitempty"` + // +optional + Status Metal3DataTemplateStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3DataTemplateList contains a list of Metal3DataTemplate. +type Metal3DataTemplateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3DataTemplate `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3DataTemplate{}, &Metal3DataTemplateList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go new file mode 100644 index 000000000..7eb92753f --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go @@ -0,0 +1,113 @@ +/* +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 v1beta1 + +import ( + "reflect" + "strconv" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3DataTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3datatemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datatemplates,versions=v1beta1,name=validation.metal3datatemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1,sideEffects=None +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3datatemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datatemplates,versions=v1beta1,name=default.metal3datatemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3DataTemplate{} +var _ webhook.Validator = &Metal3DataTemplate{} + +func (c *Metal3DataTemplate) Default() {} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataTemplate) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldM3dt, ok := old.(*Metal3DataTemplate) + if !ok || oldM3dt == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if !reflect.DeepEqual(c.Spec.MetaData, oldM3dt.Spec.MetaData) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "MetaData"), + c.Spec.MetaData, + "cannot be modified", + ), + ) + } + + if !reflect.DeepEqual(c.Spec.NetworkData, oldM3dt.Spec.NetworkData) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "NetworkData"), + c.Spec.NetworkData, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataTemplate) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3DataTemplate) validate() error { + var allErrs field.ErrorList + + if c.Spec.NetworkData != nil { + for i, network := range c.Spec.NetworkData.Networks.IPv4 { + if (network.FromPoolRef == nil || network.FromPoolRef.Name == "") && network.IPAddressFromIPPool == "" { + allErrs = append(allErrs, field.Required( + field.NewPath("spec", "networkData", "networks", "ipv4", strconv.Itoa(i), "fromPoolRef", "name"), + "fromPoolRef needs to contain a reference to an IPPool", + )) + } + } + for i, network := range c.Spec.NetworkData.Networks.IPv6 { + if (network.FromPoolRef == nil || network.FromPoolRef.Name == "") && network.IPAddressFromIPPool == "" { + allErrs = append(allErrs, field.Required( + field.NewPath("spec", "networkData", "networks", "ipv6", strconv.Itoa(i), "fromPoolRef", "name"), + "fromPoolRef needs to contain a reference to an IPPool", + )) + } + } + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataTemplate").GroupKind(), c.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go new file mode 100644 index 000000000..ffad62c5d --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go @@ -0,0 +1,213 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + capierrors "sigs.k8s.io/cluster-api/errors" +) + +const ( + // MachineFinalizer allows ReconcileMetal3Machine to clean up resources associated with Metal3Machine before + // removing it from the apiserver. + MachineFinalizer = "metal3machine.infrastructure.cluster.x-k8s.io" + CleaningModeDisabled = "disabled" + CleaningModeMetadata = "metadata" + ClonedFromGroupKind = "Metal3MachineTemplate.infrastructure.cluster.x-k8s.io" + LiveIsoDiskFormat = "live-iso" +) + +// Metal3MachineSpec defines the desired state of Metal3Machine. +type Metal3MachineSpec struct { + // ProviderID will be the Metal3 machine in ProviderID format + // (metal3://) + // +optional + ProviderID *string `json:"providerID,omitempty"` + + // Image is the image to be provisioned. + Image Image `json:"image"` + + // UserData references the Secret that holds user data needed by the bare metal + // operator. The Namespace is optional; it will default to the metal3machine's + // namespace if not specified. + // +optional + UserData *corev1.SecretReference `json:"userData,omitempty"` + + // HostSelector specifies matching criteria for labels on BareMetalHosts. + // This is used to limit the set of BareMetalHost objects considered for + // claiming for a metal3machine. + // +optional + HostSelector HostSelector `json:"hostSelector,omitempty"` + + // MetadataTemplate is a reference to a Metal3DataTemplate object containing + // a template of metadata to be rendered. Metadata keys defined in the + // metadataTemplate take precedence over keys defined in metadata field. + // +optional + DataTemplate *corev1.ObjectReference `json:"dataTemplate,omitempty"` + + // MetaData is an object storing the reference to the secret containing the + // Metadata given by the user. + // +optional + MetaData *corev1.SecretReference `json:"metaData,omitempty"` + + // NetworkData is an object storing the reference to the secret containing the + // network data given by the user. + // +optional + NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + + // When set to disabled, automated cleaning of host disks will be skipped + // during provisioning and deprovisioning. + // +kubebuilder:validation:Enum:=metadata;disabled + // +optional + AutomatedCleaningMode *string `json:"automatedCleaningMode,omitempty"` +} + +// Metal3MachineStatus defines the observed state of Metal3Machine. +type Metal3MachineStatus struct { + + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // FailureReason will be set in the event that there is a terminal problem + // reconciling the metal3machine and will contain a succinct value suitable + // for machine interpretation. + // + // This field should not be set for transitive errors that a controller + // faces that are expected to be fixed automatically over + // time (like service outages), but instead indicate that something is + // fundamentally wrong with the metal3machine's spec or the configuration of + // the controller, and that manual intervention is required. Examples + // of terminal errors would be invalid combinations of settings in the + // spec, values that are unsupported by the controller, or the + // responsible controller itself being critically misconfigured. + // + // Any transient errors that occur during the reconciliation of + // metal3machines can be added as events to the metal3machine object + // and/or logged in the controller's output. + // +optional + FailureReason *capierrors.MachineStatusError `json:"failureReason,omitempty"` + + // FailureMessage will be set in the event that there is a terminal problem + // reconciling the metal3machine and will contain a more verbose string suitable + // for logging and human consumption. + // + // This field should not be set for transitive errors that a controller + // faces that are expected to be fixed automatically over + // time (like service outages), but instead indicate that something is + // fundamentally wrong with the metal3machine's spec or the configuration of + // the controller, and that manual intervention is required. Examples + // of terminal errors would be invalid combinations of settings in the + // spec, values that are unsupported by the controller, or the + // responsible controller itself being critically misconfigured. + // + // Any transient errors that occur during the reconciliation of + // metal3machines can be added as events to the metal3machine object + // and/or logged in the controller's output. + // +optional + FailureMessage *string `json:"failureMessage,omitempty"` + + // Addresses is a list of addresses assigned to the machine. + // This field is copied from the infrastructure provider reference. + // +optional + Addresses clusterv1.MachineAddresses `json:"addresses,omitempty"` + + // Phase represents the current phase of machine actuation. + // E.g. Pending, Running, Terminating, Failed etc. + // +optional + Phase string `json:"phase,omitempty"` + + // Ready is the state of the metal3. + // TODO : Document the variable : + // mhrivnak: " it would be good to document what this means, how to interpret + // it, under what circumstances the value changes, etc." + // +optional + Ready bool `json:"ready"` + + // UserData references the Secret that holds user data needed by the bare metal + // operator. The Namespace is optional; it will default to the metal3machine's + // namespace if not specified. + // +optional + UserData *corev1.SecretReference `json:"userData,omitempty"` + + // RenderedData is a reference to a rendered Metal3Data object containing + // the references to metaData and networkData secrets. + // +optional + RenderedData *corev1.ObjectReference `json:"renderedData,omitempty"` + + // MetaData is an object storing the reference to the secret containing the + // Metadata used to deploy the BareMetalHost. + // +optional + MetaData *corev1.SecretReference `json:"metaData,omitempty"` + + // NetworkData is an object storing the reference to the secret containing the + // network data used to deploy the BareMetalHost. + // +optional + NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + // Conditions defines current service state of the Metal3Machine. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3machines,scope=Namespaced,categories=cluster-api,shortName=m3m;m3machine;m3machines;metal3m;metal3machine +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3Machine" +// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="Provider ID" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="metal3machine is Ready" +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this M3Machine belongs" +// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="metal3machine current phase" + +// Metal3Machine is the Schema for the metal3machines API. +type Metal3Machine struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3MachineSpec `json:"spec,omitempty"` + // +optional + Status Metal3MachineStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3MachineList contains a list of Metal3Machine. +type Metal3MachineList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Machine `json:"items"` +} + +// GetConditions returns the list of conditions for an Metal3Machine API object. +func (c *Metal3Machine) GetConditions() clusterv1.Conditions { + return c.Status.Conditions +} + +// SetConditions will set the given conditions on an Metal3Machine object. +func (c *Metal3Machine) SetConditions(conditions clusterv1.Conditions) { + c.Status.Conditions = conditions +} + +func init() { + objectTypes = append(objectTypes, &Metal3Machine{}, &Metal3MachineList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go new file mode 100644 index 000000000..3d95a09f5 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go @@ -0,0 +1,64 @@ +/* +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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3Machine) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machine,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machines,versions=v1beta1,name=validation.metal3machine.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machine,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machines,versions=v1beta1,name=default.metal3machine.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Machine{} +var _ webhook.Validator = &Metal3Machine{} + +func (c *Metal3Machine) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Machine) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Machine) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Machine) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3Machine) validate() error { + var allErrs field.ErrorList + + allErrs = append(allErrs, c.Spec.Image.Validate(*field.NewPath("Spec", "Image"))...) + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Machine").GroupKind(), c.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go new file mode 100644 index 000000000..c6d76a7a9 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go @@ -0,0 +1,68 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Metal3MachineTemplateSpec defines the desired state of Metal3MachineTemplate. +type Metal3MachineTemplateSpec struct { + Template Metal3MachineTemplateResource `json:"template"` + + // When set to True, CAPM3 Machine controller will + // pick the same pool of BMHs' that were released during the upgrade operation. + // +kubebuilder:default=false + // +optional + NodeReuse bool `json:"nodeReuse"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3MachineTemplate" +// +kubebuilder:resource:path=metal3machinetemplates,scope=Namespaced,categories=cluster-api,shortName=m3mt;m3machinetemplate;m3machinetemplates;metal3mt;metal3machinetemplate +// +kubebuilder:storageversion + +// Metal3MachineTemplate is the Schema for the metal3machinetemplates API. +type Metal3MachineTemplate struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3MachineTemplateSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3MachineTemplateList contains a list of Metal3MachineTemplate. +type Metal3MachineTemplateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3MachineTemplate `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3MachineTemplate{}, &Metal3MachineTemplateList{}) +} + +// Metal3MachineTemplateResource describes the data needed to create a Metal3Machine from a template. +type Metal3MachineTemplateResource struct { + // Spec is the specification of the desired behavior of the machine. + Spec Metal3MachineSpec `json:"spec"` +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go new file mode 100644 index 000000000..7061189f0 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go @@ -0,0 +1,64 @@ +/* +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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3MachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machinetemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machinetemplates,versions=v1beta1,name=validation.metal3machinetemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machinetemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machinetemplates,versions=v1beta1,name=default.metal3machinetemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3MachineTemplate{} +var _ webhook.Validator = &Metal3MachineTemplate{} + +func (c *Metal3MachineTemplate) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3MachineTemplate) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3MachineTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3MachineTemplate) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3MachineTemplate) validate() error { + var allErrs field.ErrorList + + allErrs = append(allErrs, c.Spec.Template.Spec.Image.Validate(*field.NewPath("Spec", "Template", "Spec", "Image"))...) + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3MachineTemplate").GroupKind(), c.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go new file mode 100644 index 000000000..0cfeff6c2 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go @@ -0,0 +1,125 @@ +/* +Copyright 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type RemediationType string + +const ( + // RemediationFinalizer allows Metal3RemediationReconciler to clean up resources associated with Metal3Remediation before + // removing it from the apiserver. + RemediationFinalizer = "metal3remediation.infrastructure.cluster.x-k8s.io" + + // RebootRemediationStrategy sets RemediationType to Reboot. + RebootRemediationStrategy RemediationType = "Reboot" +) + +const ( + // PhaseRunning represents the running state during remediation. + PhaseRunning = "Running" + + // PhaseWaiting represents the state during remediation when the controller has done its job but still waiting for the result of the last remediation step. + PhaseWaiting = "Waiting" + + // PhaseDeleting represents the state where host remediation has failed and the controller is deleting the unhealthy Machine object from the cluster. + PhaseDeleting = "Deleting machine" + + // PhaseFailed represents the state where host will not be remediated. + // Remediation Controller will set the state to PhaseFailed when a user has set bmh.Spec.Online to false. + PhaseFailed = "Failed" +) + +// Metal3RemediationSpec defines the desired state of Metal3Remediation. +type Metal3RemediationSpec struct { + // Strategy field defines remediation strategy. + // +optional + Strategy *RemediationStrategy `json:"strategy,omitempty"` +} + +// RemediationStrategy describes how to remediate machines. +type RemediationStrategy struct { + // Type of remediation. + // +optional + Type RemediationType `json:"type,omitempty"` + + // Sets maximum number of remediation retries. + // +optional + RetryLimit int `json:"retryLimit,omitempty"` + + // Sets the timeout between remediation retries. + // +optional + Timeout *metav1.Duration `json:"timeout"` +} + +// Metal3RemediationStatus defines the observed state of Metal3Remediation. +type Metal3RemediationStatus struct { + // Phase represents the current phase of machine remediation. + // E.g. Pending, Running, Done etc. + // +optional + Phase string `json:"phase,omitempty"` + + // RetryCount can be used as a counter during the remediation. + // Field can hold number of reboots etc. + // +optional + RetryCount int `json:"retryCount,omitempty"` + + // LastRemediated identifies when the host was last remediated + // +optional + LastRemediated *metav1.Time `json:"lastRemediated,omitempty"` +} + +// +kubebuilder:object:root=true + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3remediations,scope=Namespaced,categories=cluster-api,shortName=m3r;m3remediation +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Retry limit",type=string,JSONPath=".spec.strategy.retryLimit",description="How many times remediation controller should attempt to remediate the host" +// +kubebuilder:printcolumn:name="Retry count",type=string,JSONPath=".status.retryCount",description="How many times remediation controller has tried to remediate the node" +// +kubebuilder:printcolumn:name="Last Remediated",type=string,JSONPath=".status.lastRemediated",description="Timestamp of the last remediation attempt" +// +kubebuilder:printcolumn:name="Strategy",type=string,JSONPath=".spec.strategy.type",description="Type of the remediation strategy" +// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=".status.phase",description="Phase of the remediation" + +// Metal3Remediation is the Schema for the metal3remediations API. +type Metal3Remediation struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3RemediationSpec `json:"spec,omitempty"` + // +optional + Status Metal3RemediationStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3RemediationList contains a list of Metal3Remediation. +type Metal3RemediationList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Remediation `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3Remediation{}, &Metal3RemediationList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go new file mode 100644 index 000000000..45e6011ed --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go @@ -0,0 +1,103 @@ +/* +Copyright 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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// log is for logging in this package. +var metal3remediationlog = logf.Log.WithName("metal3remediation-resource") + +func (r *Metal3Remediation) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediation,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediations,versions=v1beta1,name=validation.metal3remediation.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediation,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediations,versions=v1beta1,name=default.metal3remediation.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Remediation{} +var _ webhook.Validator = &Metal3Remediation{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type. +func (r *Metal3Remediation) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3Remediation) ValidateCreate() (admission.Warnings, error) { + return nil, r.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3Remediation) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, r.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3Remediation) ValidateDelete() (admission.Warnings, error) { + metal3remediationlog.Info("validate delete", "name", r.Name) + return nil, nil +} + +func (r *Metal3Remediation) validate() error { + var allErrs field.ErrorList + if r.Spec.Strategy.Timeout != nil && r.Spec.Strategy.Timeout.Seconds() < minTimeout.Seconds() { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "strategy", "timeout"), + r.Spec.Strategy.Timeout, + "min duration is minTimeout.Seconds()", + ), + ) + } + + if r.Spec.Strategy.Type != RebootRemediationStrategy { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "strategy", "type"), + r.Spec.Strategy.Type, + "is only supported remediation strategy", + ), + ) + } + + if r.Spec.Strategy.RetryLimit < minRetryLimit { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "strategy", "retryLimit"), + r.Spec.Strategy.RetryLimit, + "is minimum retrylimit", + ), + ) + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Remediation").GroupKind(), r.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go new file mode 100644 index 000000000..6820985af --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go @@ -0,0 +1,70 @@ +/* +Copyright 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Metal3RemediationTemplateSpec defines the desired state of Metal3RemediationTemplate. +type Metal3RemediationTemplateSpec struct { + Template Metal3RemediationTemplateResource `json:"template"` +} + +// Metal3RemediationTemplateResource describes the data needed to create a Metal3Remediation from a template. +type Metal3RemediationTemplateResource struct { + // Spec is the specification of the desired behavior of the Metal3Remediation. + Spec Metal3RemediationSpec `json:"spec"` +} + +// Metal3RemediationTemplateStatus defines the observed state of Metal3RemediationTemplate. +type Metal3RemediationTemplateStatus struct { + // Metal3RemediationStatus defines the observed state of Metal3Remediation + Status Metal3RemediationStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3remediationtemplates,scope=Namespaced,categories=cluster-api,shortName=m3rt;m3remediationtemplate;m3remediationtemplates;metal3rt;metal3remediationtemplate +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// Metal3RemediationTemplate is the Schema for the metal3remediationtemplates API. +type Metal3RemediationTemplate struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3RemediationTemplateSpec `json:"spec,omitempty"` + // +optional + Status Metal3RemediationTemplateStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3RemediationTemplateList contains a list of Metal3RemediationTemplate. +type Metal3RemediationTemplateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3RemediationTemplate `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3RemediationTemplate{}, &Metal3RemediationTemplateList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go new file mode 100644 index 000000000..902f8ba3f --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go @@ -0,0 +1,129 @@ +/* +Copyright 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 v1beta1 + +import ( + "time" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +var ( + // Default retry timeout is 600 seconds. + defaultTimeout = metav1.Duration{Duration: 600 * time.Second} + // Minimum time between remediation retries. + minTimeout = metav1.Duration{Duration: 100 * time.Second} + // Mininum remediation retry limit is 1. + // Controller will try to remediate unhealhy node at least once. + minRetryLimit = 1 +) + +// log is for logging in this package. +var metal3remediationtemplatelog = logf.Log.WithName("metal3remediationtemplate-resource") + +func (r *Metal3RemediationTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediationtemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediationtemplates,versions=v1beta1,name=validation.metal3remediationtemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediationtemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediationtemplates,versions=v1beta1,name=default.metal3remediationtemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3RemediationTemplate{} +var _ webhook.Validator = &Metal3RemediationTemplate{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) Default() { + if r.Spec.Template.Spec.Strategy.Type == "" { + r.Spec.Template.Spec.Strategy.Type = RebootRemediationStrategy + } + + if r.Spec.Template.Spec.Strategy.Timeout == nil { + r.Spec.Template.Spec.Strategy.Timeout = &defaultTimeout + } + + if r.Spec.Template.Spec.Strategy.RetryLimit == 0 || r.Spec.Template.Spec.Strategy.RetryLimit < minRetryLimit { + r.Spec.Template.Spec.Strategy.RetryLimit = minRetryLimit + } +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) ValidateCreate() (admission.Warnings, error) { + metal3remediationtemplatelog.Info("validate create", "name", r.Name) + return nil, r.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + metal3remediationtemplatelog.Info("validate update", "name", r.Name) + return nil, r.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) ValidateDelete() (admission.Warnings, error) { + metal3remediationtemplatelog.Info("validate delete", "name", r.Name) + return nil, nil +} + +func (r *Metal3RemediationTemplate) validate() error { + var allErrs field.ErrorList + if r.Spec.Template.Spec.Strategy.Timeout != nil && r.Spec.Template.Spec.Strategy.Timeout.Seconds() < minTimeout.Seconds() { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "template", "spec", "strategy", "timeout"), + r.Spec.Template.Spec.Strategy.Timeout, + "min duration is 100s", + ), + ) + } + + if r.Spec.Template.Spec.Strategy.Type != RebootRemediationStrategy { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "template", "spec", "strategy", "type"), + r.Spec.Template.Spec.Strategy.Type, + "only supported remediation strategy is reboot", + ), + ) + } + + if r.Spec.Template.Spec.Strategy.RetryLimit < minRetryLimit { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "template", "spec", "strategy", "retryLimit"), + r.Spec.Template.Spec.Strategy.RetryLimit, + "minimun retrylimit is 1", + ), + ) + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Remediation").GroupKind(), r.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 000000000..0bf45443f --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,1719 @@ +//go:build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "github.com/metal3-io/ip-address-manager/api/v1alpha1" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/errors" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIEndpoint) DeepCopyInto(out *APIEndpoint) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIEndpoint. +func (in *APIEndpoint) DeepCopy() *APIEndpoint { + if in == nil { + return nil + } + out := new(APIEndpoint) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FromPool) DeepCopyInto(out *FromPool) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FromPool. +func (in *FromPool) DeepCopy() *FromPool { + if in == nil { + return nil + } + out := new(FromPool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostSelector) DeepCopyInto(out *HostSelector) { + *out = *in + if in.MatchLabels != nil { + in, out := &in.MatchLabels, &out.MatchLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.MatchExpressions != nil { + in, out := &in.MatchExpressions, &out.MatchExpressions + *out = make([]HostSelectorRequirement, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostSelector. +func (in *HostSelector) DeepCopy() *HostSelector { + if in == nil { + return nil + } + out := new(HostSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostSelectorRequirement) DeepCopyInto(out *HostSelectorRequirement) { + *out = *in + if in.Values != nil { + in, out := &in.Values, &out.Values + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostSelectorRequirement. +func (in *HostSelectorRequirement) DeepCopy() *HostSelectorRequirement { + if in == nil { + return nil + } + out := new(HostSelectorRequirement) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Image) DeepCopyInto(out *Image) { + *out = *in + if in.ChecksumType != nil { + in, out := &in.ChecksumType, &out.ChecksumType + *out = new(string) + **out = **in + } + if in.DiskFormat != nil { + in, out := &in.DiskFormat, &out.DiskFormat + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. +func (in *Image) DeepCopy() *Image { + if in == nil { + return nil + } + out := new(Image) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaData) DeepCopyInto(out *MetaData) { + *out = *in + if in.Strings != nil { + in, out := &in.Strings, &out.Strings + *out = make([]MetaDataString, len(*in)) + copy(*out, *in) + } + if in.ObjectNames != nil { + in, out := &in.ObjectNames, &out.ObjectNames + *out = make([]MetaDataObjectName, len(*in)) + copy(*out, *in) + } + if in.Indexes != nil { + in, out := &in.Indexes, &out.Indexes + *out = make([]MetaDataIndex, len(*in)) + copy(*out, *in) + } + if in.Namespaces != nil { + in, out := &in.Namespaces, &out.Namespaces + *out = make([]MetaDataNamespace, len(*in)) + copy(*out, *in) + } + if in.IPAddressesFromPool != nil { + in, out := &in.IPAddressesFromPool, &out.IPAddressesFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.PrefixesFromPool != nil { + in, out := &in.PrefixesFromPool, &out.PrefixesFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.GatewaysFromPool != nil { + in, out := &in.GatewaysFromPool, &out.GatewaysFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.DNSServersFromPool != nil { + in, out := &in.DNSServersFromPool, &out.DNSServersFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.FromHostInterfaces != nil { + in, out := &in.FromHostInterfaces, &out.FromHostInterfaces + *out = make([]MetaDataHostInterface, len(*in)) + copy(*out, *in) + } + if in.FromLabels != nil { + in, out := &in.FromLabels, &out.FromLabels + *out = make([]MetaDataFromLabel, len(*in)) + copy(*out, *in) + } + if in.FromAnnotations != nil { + in, out := &in.FromAnnotations, &out.FromAnnotations + *out = make([]MetaDataFromAnnotation, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaData. +func (in *MetaData) DeepCopy() *MetaData { + if in == nil { + return nil + } + out := new(MetaData) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataFromAnnotation) DeepCopyInto(out *MetaDataFromAnnotation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataFromAnnotation. +func (in *MetaDataFromAnnotation) DeepCopy() *MetaDataFromAnnotation { + if in == nil { + return nil + } + out := new(MetaDataFromAnnotation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataFromLabel) DeepCopyInto(out *MetaDataFromLabel) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataFromLabel. +func (in *MetaDataFromLabel) DeepCopy() *MetaDataFromLabel { + if in == nil { + return nil + } + out := new(MetaDataFromLabel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataHostInterface) DeepCopyInto(out *MetaDataHostInterface) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataHostInterface. +func (in *MetaDataHostInterface) DeepCopy() *MetaDataHostInterface { + if in == nil { + return nil + } + out := new(MetaDataHostInterface) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataIPAddress) DeepCopyInto(out *MetaDataIPAddress) { + *out = *in + if in.Start != nil { + in, out := &in.Start, &out.Start + *out = new(v1alpha1.IPAddressStr) + **out = **in + } + if in.End != nil { + in, out := &in.End, &out.End + *out = new(v1alpha1.IPAddressStr) + **out = **in + } + if in.Subnet != nil { + in, out := &in.Subnet, &out.Subnet + *out = new(v1alpha1.IPSubnetStr) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataIPAddress. +func (in *MetaDataIPAddress) DeepCopy() *MetaDataIPAddress { + if in == nil { + return nil + } + out := new(MetaDataIPAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataIndex) DeepCopyInto(out *MetaDataIndex) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataIndex. +func (in *MetaDataIndex) DeepCopy() *MetaDataIndex { + if in == nil { + return nil + } + out := new(MetaDataIndex) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataNamespace) DeepCopyInto(out *MetaDataNamespace) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataNamespace. +func (in *MetaDataNamespace) DeepCopy() *MetaDataNamespace { + if in == nil { + return nil + } + out := new(MetaDataNamespace) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataObjectName) DeepCopyInto(out *MetaDataObjectName) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataObjectName. +func (in *MetaDataObjectName) DeepCopy() *MetaDataObjectName { + if in == nil { + return nil + } + out := new(MetaDataObjectName) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataString) DeepCopyInto(out *MetaDataString) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataString. +func (in *MetaDataString) DeepCopy() *MetaDataString { + if in == nil { + return nil + } + out := new(MetaDataString) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Cluster) DeepCopyInto(out *Metal3Cluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Cluster. +func (in *Metal3Cluster) DeepCopy() *Metal3Cluster { + if in == nil { + return nil + } + out := new(Metal3Cluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Cluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ClusterList) DeepCopyInto(out *Metal3ClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Cluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ClusterList. +func (in *Metal3ClusterList) DeepCopy() *Metal3ClusterList { + if in == nil { + return nil + } + out := new(Metal3ClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3ClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ClusterSpec) DeepCopyInto(out *Metal3ClusterSpec) { + *out = *in + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ClusterSpec. +func (in *Metal3ClusterSpec) DeepCopy() *Metal3ClusterSpec { + if in == nil { + return nil + } + out := new(Metal3ClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ClusterStatus) DeepCopyInto(out *Metal3ClusterStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.ClusterStatusError) + **out = **in + } + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ClusterStatus. +func (in *Metal3ClusterStatus) DeepCopy() *Metal3ClusterStatus { + if in == nil { + return nil + } + out := new(Metal3ClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Data) DeepCopyInto(out *Metal3Data) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Data. +func (in *Metal3Data) DeepCopy() *Metal3Data { + if in == nil { + return nil + } + out := new(Metal3Data) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Data) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaim) DeepCopyInto(out *Metal3DataClaim) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaim. +func (in *Metal3DataClaim) DeepCopy() *Metal3DataClaim { + if in == nil { + return nil + } + out := new(Metal3DataClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataClaim) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaimList) DeepCopyInto(out *Metal3DataClaimList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3DataClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaimList. +func (in *Metal3DataClaimList) DeepCopy() *Metal3DataClaimList { + if in == nil { + return nil + } + out := new(Metal3DataClaimList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataClaimList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaimSpec) DeepCopyInto(out *Metal3DataClaimSpec) { + *out = *in + out.Template = in.Template +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaimSpec. +func (in *Metal3DataClaimSpec) DeepCopy() *Metal3DataClaimSpec { + if in == nil { + return nil + } + out := new(Metal3DataClaimSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaimStatus) DeepCopyInto(out *Metal3DataClaimStatus) { + *out = *in + if in.RenderedData != nil { + in, out := &in.RenderedData, &out.RenderedData + *out = new(v1.ObjectReference) + **out = **in + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaimStatus. +func (in *Metal3DataClaimStatus) DeepCopy() *Metal3DataClaimStatus { + if in == nil { + return nil + } + out := new(Metal3DataClaimStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataList) DeepCopyInto(out *Metal3DataList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Data, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataList. +func (in *Metal3DataList) DeepCopy() *Metal3DataList { + if in == nil { + return nil + } + out := new(Metal3DataList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataSpec) DeepCopyInto(out *Metal3DataSpec) { + *out = *in + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(v1.SecretReference) + **out = **in + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(v1.SecretReference) + **out = **in + } + out.Claim = in.Claim + out.Template = in.Template +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataSpec. +func (in *Metal3DataSpec) DeepCopy() *Metal3DataSpec { + if in == nil { + return nil + } + out := new(Metal3DataSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataStatus) DeepCopyInto(out *Metal3DataStatus) { + *out = *in + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataStatus. +func (in *Metal3DataStatus) DeepCopy() *Metal3DataStatus { + if in == nil { + return nil + } + out := new(Metal3DataStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplate) DeepCopyInto(out *Metal3DataTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplate. +func (in *Metal3DataTemplate) DeepCopy() *Metal3DataTemplate { + if in == nil { + return nil + } + out := new(Metal3DataTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplateList) DeepCopyInto(out *Metal3DataTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3DataTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplateList. +func (in *Metal3DataTemplateList) DeepCopy() *Metal3DataTemplateList { + if in == nil { + return nil + } + out := new(Metal3DataTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplateSpec) DeepCopyInto(out *Metal3DataTemplateSpec) { + *out = *in + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(MetaData) + (*in).DeepCopyInto(*out) + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(NetworkData) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplateSpec. +func (in *Metal3DataTemplateSpec) DeepCopy() *Metal3DataTemplateSpec { + if in == nil { + return nil + } + out := new(Metal3DataTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplateStatus) DeepCopyInto(out *Metal3DataTemplateStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.Indexes != nil { + in, out := &in.Indexes, &out.Indexes + *out = make(map[string]int, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplateStatus. +func (in *Metal3DataTemplateStatus) DeepCopy() *Metal3DataTemplateStatus { + if in == nil { + return nil + } + out := new(Metal3DataTemplateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Machine) DeepCopyInto(out *Metal3Machine) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Machine. +func (in *Metal3Machine) DeepCopy() *Metal3Machine { + if in == nil { + return nil + } + out := new(Metal3Machine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Machine) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineList) DeepCopyInto(out *Metal3MachineList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Machine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineList. +func (in *Metal3MachineList) DeepCopy() *Metal3MachineList { + if in == nil { + return nil + } + out := new(Metal3MachineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3MachineList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineSpec) DeepCopyInto(out *Metal3MachineSpec) { + *out = *in + if in.ProviderID != nil { + in, out := &in.ProviderID, &out.ProviderID + *out = new(string) + **out = **in + } + in.Image.DeepCopyInto(&out.Image) + if in.UserData != nil { + in, out := &in.UserData, &out.UserData + *out = new(v1.SecretReference) + **out = **in + } + in.HostSelector.DeepCopyInto(&out.HostSelector) + if in.DataTemplate != nil { + in, out := &in.DataTemplate, &out.DataTemplate + *out = new(v1.ObjectReference) + **out = **in + } + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(v1.SecretReference) + **out = **in + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(v1.SecretReference) + **out = **in + } + if in.AutomatedCleaningMode != nil { + in, out := &in.AutomatedCleaningMode, &out.AutomatedCleaningMode + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineSpec. +func (in *Metal3MachineSpec) DeepCopy() *Metal3MachineSpec { + if in == nil { + return nil + } + out := new(Metal3MachineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineStatus) DeepCopyInto(out *Metal3MachineStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.MachineStatusError) + **out = **in + } + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make(apiv1beta1.MachineAddresses, len(*in)) + copy(*out, *in) + } + if in.UserData != nil { + in, out := &in.UserData, &out.UserData + *out = new(v1.SecretReference) + **out = **in + } + if in.RenderedData != nil { + in, out := &in.RenderedData, &out.RenderedData + *out = new(v1.ObjectReference) + **out = **in + } + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(v1.SecretReference) + **out = **in + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(v1.SecretReference) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineStatus. +func (in *Metal3MachineStatus) DeepCopy() *Metal3MachineStatus { + if in == nil { + return nil + } + out := new(Metal3MachineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplate) DeepCopyInto(out *Metal3MachineTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplate. +func (in *Metal3MachineTemplate) DeepCopy() *Metal3MachineTemplate { + if in == nil { + return nil + } + out := new(Metal3MachineTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3MachineTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplateList) DeepCopyInto(out *Metal3MachineTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3MachineTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplateList. +func (in *Metal3MachineTemplateList) DeepCopy() *Metal3MachineTemplateList { + if in == nil { + return nil + } + out := new(Metal3MachineTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3MachineTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplateResource) DeepCopyInto(out *Metal3MachineTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplateResource. +func (in *Metal3MachineTemplateResource) DeepCopy() *Metal3MachineTemplateResource { + if in == nil { + return nil + } + out := new(Metal3MachineTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplateSpec) DeepCopyInto(out *Metal3MachineTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplateSpec. +func (in *Metal3MachineTemplateSpec) DeepCopy() *Metal3MachineTemplateSpec { + if in == nil { + return nil + } + out := new(Metal3MachineTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Remediation) DeepCopyInto(out *Metal3Remediation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Remediation. +func (in *Metal3Remediation) DeepCopy() *Metal3Remediation { + if in == nil { + return nil + } + out := new(Metal3Remediation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Remediation) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationList) DeepCopyInto(out *Metal3RemediationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Remediation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationList. +func (in *Metal3RemediationList) DeepCopy() *Metal3RemediationList { + if in == nil { + return nil + } + out := new(Metal3RemediationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3RemediationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationSpec) DeepCopyInto(out *Metal3RemediationSpec) { + *out = *in + if in.Strategy != nil { + in, out := &in.Strategy, &out.Strategy + *out = new(RemediationStrategy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationSpec. +func (in *Metal3RemediationSpec) DeepCopy() *Metal3RemediationSpec { + if in == nil { + return nil + } + out := new(Metal3RemediationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationStatus) DeepCopyInto(out *Metal3RemediationStatus) { + *out = *in + if in.LastRemediated != nil { + in, out := &in.LastRemediated, &out.LastRemediated + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationStatus. +func (in *Metal3RemediationStatus) DeepCopy() *Metal3RemediationStatus { + if in == nil { + return nil + } + out := new(Metal3RemediationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplate) DeepCopyInto(out *Metal3RemediationTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplate. +func (in *Metal3RemediationTemplate) DeepCopy() *Metal3RemediationTemplate { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3RemediationTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateList) DeepCopyInto(out *Metal3RemediationTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3RemediationTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateList. +func (in *Metal3RemediationTemplateList) DeepCopy() *Metal3RemediationTemplateList { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3RemediationTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateResource) DeepCopyInto(out *Metal3RemediationTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateResource. +func (in *Metal3RemediationTemplateResource) DeepCopy() *Metal3RemediationTemplateResource { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateSpec) DeepCopyInto(out *Metal3RemediationTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateSpec. +func (in *Metal3RemediationTemplateSpec) DeepCopy() *Metal3RemediationTemplateSpec { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateStatus) DeepCopyInto(out *Metal3RemediationTemplateStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateStatus. +func (in *Metal3RemediationTemplateStatus) DeepCopy() *Metal3RemediationTemplateStatus { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkData) DeepCopyInto(out *NetworkData) { + *out = *in + in.Links.DeepCopyInto(&out.Links) + in.Networks.DeepCopyInto(&out.Networks) + in.Services.DeepCopyInto(&out.Services) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkData. +func (in *NetworkData) DeepCopy() *NetworkData { + if in == nil { + return nil + } + out := new(NetworkData) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv4) DeepCopyInto(out *NetworkDataIPv4) { + *out = *in + if in.FromPoolRef != nil { + in, out := &in.FromPoolRef, &out.FromPoolRef + *out = new(v1.TypedLocalObjectReference) + (*in).DeepCopyInto(*out) + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev4, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv4. +func (in *NetworkDataIPv4) DeepCopy() *NetworkDataIPv4 { + if in == nil { + return nil + } + out := new(NetworkDataIPv4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv4DHCP) DeepCopyInto(out *NetworkDataIPv4DHCP) { + *out = *in + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev4, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv4DHCP. +func (in *NetworkDataIPv4DHCP) DeepCopy() *NetworkDataIPv4DHCP { + if in == nil { + return nil + } + out := new(NetworkDataIPv4DHCP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv6) DeepCopyInto(out *NetworkDataIPv6) { + *out = *in + if in.FromPoolRef != nil { + in, out := &in.FromPoolRef, &out.FromPoolRef + *out = new(v1.TypedLocalObjectReference) + (*in).DeepCopyInto(*out) + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev6, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv6. +func (in *NetworkDataIPv6) DeepCopy() *NetworkDataIPv6 { + if in == nil { + return nil + } + out := new(NetworkDataIPv6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv6DHCP) DeepCopyInto(out *NetworkDataIPv6DHCP) { + *out = *in + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev6, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv6DHCP. +func (in *NetworkDataIPv6DHCP) DeepCopy() *NetworkDataIPv6DHCP { + if in == nil { + return nil + } + out := new(NetworkDataIPv6DHCP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLink) DeepCopyInto(out *NetworkDataLink) { + *out = *in + if in.Ethernets != nil { + in, out := &in.Ethernets, &out.Ethernets + *out = make([]NetworkDataLinkEthernet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Bonds != nil { + in, out := &in.Bonds, &out.Bonds + *out = make([]NetworkDataLinkBond, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Vlans != nil { + in, out := &in.Vlans, &out.Vlans + *out = make([]NetworkDataLinkVlan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLink. +func (in *NetworkDataLink) DeepCopy() *NetworkDataLink { + if in == nil { + return nil + } + out := new(NetworkDataLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLinkBond) DeepCopyInto(out *NetworkDataLinkBond) { + *out = *in + if in.MACAddress != nil { + in, out := &in.MACAddress, &out.MACAddress + *out = new(NetworkLinkEthernetMac) + (*in).DeepCopyInto(*out) + } + if in.BondLinks != nil { + in, out := &in.BondLinks, &out.BondLinks + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLinkBond. +func (in *NetworkDataLinkBond) DeepCopy() *NetworkDataLinkBond { + if in == nil { + return nil + } + out := new(NetworkDataLinkBond) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLinkEthernet) DeepCopyInto(out *NetworkDataLinkEthernet) { + *out = *in + if in.MACAddress != nil { + in, out := &in.MACAddress, &out.MACAddress + *out = new(NetworkLinkEthernetMac) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLinkEthernet. +func (in *NetworkDataLinkEthernet) DeepCopy() *NetworkDataLinkEthernet { + if in == nil { + return nil + } + out := new(NetworkDataLinkEthernet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLinkVlan) DeepCopyInto(out *NetworkDataLinkVlan) { + *out = *in + if in.MACAddress != nil { + in, out := &in.MACAddress, &out.MACAddress + *out = new(NetworkLinkEthernetMac) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLinkVlan. +func (in *NetworkDataLinkVlan) DeepCopy() *NetworkDataLinkVlan { + if in == nil { + return nil + } + out := new(NetworkDataLinkVlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataNetwork) DeepCopyInto(out *NetworkDataNetwork) { + *out = *in + if in.IPv4 != nil { + in, out := &in.IPv4, &out.IPv4 + *out = make([]NetworkDataIPv4, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv6 != nil { + in, out := &in.IPv6, &out.IPv6 + *out = make([]NetworkDataIPv6, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv4DHCP != nil { + in, out := &in.IPv4DHCP, &out.IPv4DHCP + *out = make([]NetworkDataIPv4DHCP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv6DHCP != nil { + in, out := &in.IPv6DHCP, &out.IPv6DHCP + *out = make([]NetworkDataIPv6DHCP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv6SLAAC != nil { + in, out := &in.IPv6SLAAC, &out.IPv6SLAAC + *out = make([]NetworkDataIPv6DHCP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataNetwork. +func (in *NetworkDataNetwork) DeepCopy() *NetworkDataNetwork { + if in == nil { + return nil + } + out := new(NetworkDataNetwork) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataRoutev4) DeepCopyInto(out *NetworkDataRoutev4) { + *out = *in + in.Gateway.DeepCopyInto(&out.Gateway) + in.Services.DeepCopyInto(&out.Services) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataRoutev4. +func (in *NetworkDataRoutev4) DeepCopy() *NetworkDataRoutev4 { + if in == nil { + return nil + } + out := new(NetworkDataRoutev4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataRoutev6) DeepCopyInto(out *NetworkDataRoutev6) { + *out = *in + in.Gateway.DeepCopyInto(&out.Gateway) + in.Services.DeepCopyInto(&out.Services) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataRoutev6. +func (in *NetworkDataRoutev6) DeepCopy() *NetworkDataRoutev6 { + if in == nil { + return nil + } + out := new(NetworkDataRoutev6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataService) DeepCopyInto(out *NetworkDataService) { + *out = *in + if in.DNS != nil { + in, out := &in.DNS, &out.DNS + *out = make([]v1alpha1.IPAddressStr, len(*in)) + copy(*out, *in) + } + if in.DNSFromIPPool != nil { + in, out := &in.DNSFromIPPool, &out.DNSFromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataService. +func (in *NetworkDataService) DeepCopy() *NetworkDataService { + if in == nil { + return nil + } + out := new(NetworkDataService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataServicev4) DeepCopyInto(out *NetworkDataServicev4) { + *out = *in + if in.DNS != nil { + in, out := &in.DNS, &out.DNS + *out = make([]v1alpha1.IPAddressv4Str, len(*in)) + copy(*out, *in) + } + if in.DNSFromIPPool != nil { + in, out := &in.DNSFromIPPool, &out.DNSFromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataServicev4. +func (in *NetworkDataServicev4) DeepCopy() *NetworkDataServicev4 { + if in == nil { + return nil + } + out := new(NetworkDataServicev4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataServicev6) DeepCopyInto(out *NetworkDataServicev6) { + *out = *in + if in.DNS != nil { + in, out := &in.DNS, &out.DNS + *out = make([]v1alpha1.IPAddressv6Str, len(*in)) + copy(*out, *in) + } + if in.DNSFromIPPool != nil { + in, out := &in.DNSFromIPPool, &out.DNSFromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataServicev6. +func (in *NetworkDataServicev6) DeepCopy() *NetworkDataServicev6 { + if in == nil { + return nil + } + out := new(NetworkDataServicev6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkGatewayv4) DeepCopyInto(out *NetworkGatewayv4) { + *out = *in + if in.String != nil { + in, out := &in.String, &out.String + *out = new(v1alpha1.IPAddressv4Str) + **out = **in + } + if in.FromIPPool != nil { + in, out := &in.FromIPPool, &out.FromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkGatewayv4. +func (in *NetworkGatewayv4) DeepCopy() *NetworkGatewayv4 { + if in == nil { + return nil + } + out := new(NetworkGatewayv4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkGatewayv6) DeepCopyInto(out *NetworkGatewayv6) { + *out = *in + if in.String != nil { + in, out := &in.String, &out.String + *out = new(v1alpha1.IPAddressv6Str) + **out = **in + } + if in.FromIPPool != nil { + in, out := &in.FromIPPool, &out.FromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkGatewayv6. +func (in *NetworkGatewayv6) DeepCopy() *NetworkGatewayv6 { + if in == nil { + return nil + } + out := new(NetworkGatewayv6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkLinkEthernetMac) DeepCopyInto(out *NetworkLinkEthernetMac) { + *out = *in + if in.String != nil { + in, out := &in.String, &out.String + *out = new(string) + **out = **in + } + if in.FromHostInterface != nil { + in, out := &in.FromHostInterface, &out.FromHostInterface + *out = new(string) + **out = **in + } + if in.FromAnnotation != nil { + in, out := &in.FromAnnotation, &out.FromAnnotation + *out = new(NetworkLinkEthernetMacFromAnnotation) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkLinkEthernetMac. +func (in *NetworkLinkEthernetMac) DeepCopy() *NetworkLinkEthernetMac { + if in == nil { + return nil + } + out := new(NetworkLinkEthernetMac) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkLinkEthernetMacFromAnnotation) DeepCopyInto(out *NetworkLinkEthernetMacFromAnnotation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkLinkEthernetMacFromAnnotation. +func (in *NetworkLinkEthernetMacFromAnnotation) DeepCopy() *NetworkLinkEthernetMacFromAnnotation { + if in == nil { + return nil + } + out := new(NetworkLinkEthernetMacFromAnnotation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemediationStrategy) DeepCopyInto(out *RemediationStrategy) { + *out = *in + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(metav1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemediationStrategy. +func (in *RemediationStrategy) DeepCopy() *RemediationStrategy { + if in == nil { + return nil + } + out := new(RemediationStrategy) + in.DeepCopyInto(out) + return out +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/LICENSE b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/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/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go new file mode 100644 index 000000000..78292d9b6 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go @@ -0,0 +1,41 @@ +/* +Copyright 2019 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 v1alpha1 + +// +kubebuilder:validation:Pattern="((^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$))" +// IPAddress is used for validation of an IP address. +type IPAddressStr string + +// +kubebuilder:validation:Pattern="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$" +// IPAddressv6 is used for validation of an IPv6 address. +type IPAddressv6Str string + +// +kubebuilder:validation:Pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))$" +// IPAddressv4 is used for validation of an IPv6 address. +type IPAddressv4Str string + +// +kubebuilder:validation:Pattern="((^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))/([0-9]|[1-2][0-9]|3[0-2])$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/([0-9]|[0-9][0-9]|1[0-1][0-9]|12[0-8])$))" +// IPSubnet is used for validation of an IP subnet. +type IPSubnetStr string + +// +kubebuilder:validation:Pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))/([0-9]|[1-2][0-9]|3[0-2])$" +// IPSubnetv4 is used for validation of an IP subnet. +type IPSubnetv4Str string + +// +kubebuilder:validation:Pattern="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/([0-9]|[0-9][0-9]|1[0-1][0-9]|12[0-8])$" +// IPSubnetv6 is used for validation of an IP subnet. +type IPSubnetv6Str string diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go new file mode 100644 index 000000000..0d67430db --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go @@ -0,0 +1,21 @@ +/* +Copyright 2019 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 v1alpha1 + +func (*IPPool) Hub() {} +func (*IPAddress) Hub() {} +func (*IPClaim) Hub() {} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go new file mode 100644 index 000000000..ca3b14718 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2019 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 v1alpha1 contains API Schema definitions for the metal3 v1alpha1 API group +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +kubebuilder:object:generate=true +// +groupName=ipam.metal3.io +package v1alpha1 diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go new file mode 100644 index 000000000..967b4b18c --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go @@ -0,0 +1,53 @@ +/* +Copyright 2019 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 v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group +// +kubebuilder:object:generate=true +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +groupName=ipam.metal3.io +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "ipam.metal3.io", Version: "v1alpha1"} + + /// schemeBuilder is used to add go types to the GroupVersionKind scheme. + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = schemeBuilder.AddToScheme + + objectTypes = []runtime.Object{} +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, objectTypes...) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} + +// Resource is required by pkg/client/listers/... +// func Resource(resource string) schema.GroupResource { +// return SchemeGroupVersion.WithResource(resource).GroupResource() +// } diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go new file mode 100644 index 000000000..d2b0be4f3 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go @@ -0,0 +1,77 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataFinalizer allows IPAddressReconciler to clean up resources + // associated with IPAddress before removing it from the apiserver. + IPAddressFinalizer = "ipaddress.ipam.metal3.io" +) + +// IPAddressSpec defines the desired state of IPAddress. +type IPAddressSpec struct { + + // Claim points to the object the IPClaim was created for. + Claim corev1.ObjectReference `json:"claim"` + + // Pool is the IPPool this was generated from. + Pool corev1.ObjectReference `json:"pool"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + Prefix int `json:"prefix,omitempty"` + + // Gateway is the gateway ip address + Gateway *IPAddressStr `json:"gateway,omitempty"` + + // Address contains the IP address + Address IPAddressStr `json:"address"` + + // DNSServers is the list of dns servers + DNSServers []IPAddressStr `json:"dnsServers,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=ipaddresses,scope=Namespaced,categories=metal3,shortName=ipa;ipaddress;m3ipa;m3ipaddress;m3ipaddresses;metal3ipa;metal3ipaddress;metal3ipaddresses +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3IPAddress" +// +kubebuilder:storageversion +// +kubebuilder:object:root=true +// IPAddress is the Schema for the ipaddresses API. +type IPAddress struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPAddressSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// IPAddressList contains a list of IPAddress. +type IPAddressList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPAddress `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &IPAddress{}, &IPAddressList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go new file mode 100644 index 000000000..8ff60e3af --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go @@ -0,0 +1,159 @@ +/* +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 v1alpha1 + +import ( + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *IPAddress) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-ipam-metal3-io-v1alpha1-ipaddress,mutating=false,failurePolicy=fail,groups=ipam.metal3.io,resources=ipaddresses,versions=v1alpha1,name=validation.ipaddress.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-ipam-metal3-io-v1alpha1-ipaddress,mutating=true,failurePolicy=fail,groups=ipam.metal3.io,resources=ipaddresses,versions=v1alpha1,name=default.ipaddress.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &IPAddress{} +var _ webhook.Validator = &IPAddress{} + +func (c *IPAddress) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPAddress) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if c.Spec.Pool.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool", "name"), + c.Spec.Pool.Name, + "cannot be empty", + ), + ) + } + + if c.Spec.Claim.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim", "name"), + c.Spec.Claim.Name, + "cannot be empty", + ), + ) + } + + if c.Spec.Address == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "address"), + c.Spec.Address, + "cannot be empty", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPAddress").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPAddress) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldIPAddress, ok := old.(*IPAddress) + if !ok || oldIPAddress == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Address != oldIPAddress.Spec.Address { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "address"), + c.Spec.Address, + "cannot be modified", + ), + ) + } + + if c.Spec.Pool.Name != oldIPAddress.Spec.Pool.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Namespace != oldIPAddress.Spec.Pool.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Kind != oldIPAddress.Spec.Pool.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } + + if c.Spec.Claim.Name != oldIPAddress.Spec.Claim.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Namespace != oldIPAddress.Spec.Claim.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Kind != oldIPAddress.Spec.Claim.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPAddress").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *IPAddress) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go new file mode 100644 index 000000000..938108960 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go @@ -0,0 +1,73 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // IPClaimFinalizer allows IPClaimReconciler to clean up resources + // associated with IPClaim before removing it from the apiserver. + IPClaimFinalizer = "ipclaim.ipam.metal3.io" +) + +// IPClaimSpec defines the desired state of IPClaim. +type IPClaimSpec struct { + + // Pool is the IPPool this was generated from. + Pool corev1.ObjectReference `json:"pool"` +} + +// IPClaimStatus defines the observed state of IPClaim. +type IPClaimStatus struct { + + // Address is the IPAddress that was generated for this claim. + Address *corev1.ObjectReference `json:"address,omitempty"` + + // ErrorMessage contains the error message + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=ipclaims,scope=Namespaced,categories=cluster-api,shortName=ipc;ipclaim;m3ipc;m3ipclaim;m3ipclaims;metal3ipc;metal3ipclaim;metal3ipclaims +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3IPClaim" +// IPClaim is the Schema for the ipclaims API. +type IPClaim struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPClaimSpec `json:"spec,omitempty"` + Status IPClaimStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// IPClaimList contains a list of IPClaim. +type IPClaimList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPClaim `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &IPClaim{}, &IPClaimList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go new file mode 100644 index 000000000..ea5d0858d --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go @@ -0,0 +1,103 @@ +/* +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 v1alpha1 + +import ( + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *IPClaim) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-ipam-metal3-io-v1alpha1-ipclaim,mutating=false,failurePolicy=fail,groups=ipam.metal3.io,resources=ipclaims,versions=v1alpha1,name=validation.ipclaim.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-ipam-metal3-io-v1alpha1-ipclaim,mutating=true,failurePolicy=fail,groups=ipam.metal3.io,resources=ipclaims,versions=v1alpha1,name=default.ipclaim.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &IPClaim{} +var _ webhook.Validator = &IPClaim{} + +func (c *IPClaim) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPClaim) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if c.Spec.Pool.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool", "name"), + c.Spec.Pool.Name, + "cannot be empty", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPClaim) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldIPClaim, ok := old.(*IPClaim) + if !ok || oldIPClaim == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Pool.Name != oldIPClaim.Spec.Pool.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Namespace != oldIPClaim.Spec.Pool.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Kind != oldIPClaim.Spec.Pool.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *IPClaim) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go new file mode 100644 index 000000000..4b41dd533 --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go @@ -0,0 +1,120 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // IPPoolFinalizer allows IPPoolReconciler to clean up resources + // associated with IPPool before removing it from the apiserver. + IPPoolFinalizer = "ippool.ipam.metal3.io" +) + +// MetaDataIPAddress contains the info to render th ip address. It is IP-version +// agnostic. +type Pool struct { + + // Start is the first ip address that can be rendered + Start *IPAddressStr `json:"start,omitempty"` + + // End is the last IP address that can be rendered. It is used as a validation + // that the rendered IP is in bound. + End *IPAddressStr `json:"end,omitempty"` + + // Subnet is used to validate that the rendered IP is in bounds. In case the + // Start value is not given, it is derived from the subnet ip incremented by 1 + // (`192.168.0.1` for `192.168.0.0/24`) + Subnet *IPSubnetStr `json:"subnet,omitempty"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + Prefix int `json:"prefix,omitempty"` + + // Gateway is the gateway ip address + Gateway *IPAddressStr `json:"gateway,omitempty"` + + // DNSServers is the list of dns servers + DNSServers []IPAddressStr `json:"dnsServers,omitempty"` +} + +// IPPoolSpec defines the desired state of IPPool. +type IPPoolSpec struct { + + // ClusterName is the name of the Cluster this object belongs to. + ClusterName *string `json:"clusterName,omitempty"` + + // Pools contains the list of IP addresses pools + Pools []Pool `json:"pools,omitempty"` + + // PreAllocations contains the preallocated IP addresses + PreAllocations map[string]IPAddressStr `json:"preAllocations,omitempty"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + Prefix int `json:"prefix,omitempty"` + + // Gateway is the gateway ip address + Gateway *IPAddressStr `json:"gateway,omitempty"` + + // DNSServers is the list of dns servers + DNSServers []IPAddressStr `json:"dnsServers,omitempty"` + + // +kubebuilder:validation:MinLength=1 + // namePrefix is the prefix used to generate the IPAddress object names + NamePrefix string `json:"namePrefix"` +} + +// IPPoolStatus defines the observed state of IPPool. +type IPPoolStatus struct { + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // Allocations contains the map of objects and IP addresses they have + Allocations map[string]IPAddressStr `json:"indexes,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=ippools,scope=Namespaced,categories=cluster-api,shortName=ipp;ippool;m3ipp;m3ippool;m3ippools;metal3ipp;metal3ippool;metal3ippools +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this template belongs" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3IPPool" +// IPPool is the Schema for the ippools API. +type IPPool struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPPoolSpec `json:"spec,omitempty"` + Status IPPoolStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// IPPoolList contains a list of IPPool. +type IPPoolList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPPool `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &IPPool{}, &IPPoolList{}) +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go new file mode 100644 index 000000000..78991455a --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go @@ -0,0 +1,176 @@ +/* +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 v1alpha1 + +import ( + "net" + "net/netip" + "reflect" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *IPPool) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-ipam-metal3-io-v1alpha1-ippool,mutating=false,failurePolicy=fail,groups=ipam.metal3.io,resources=ippools,versions=v1alpha1,name=validation.ippool.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-ipam-metal3-io-v1alpha1-ippool,mutating=true,failurePolicy=fail,groups=ipam.metal3.io,resources=ippools,versions=v1alpha1,name=default.ippool.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &IPPool{} +var _ webhook.Validator = &IPPool{} + +func (c *IPPool) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPPool) ValidateCreate() (admission.Warnings, error) { + return c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPPool) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldM3ipp, ok := old.(*IPPool) + if !ok || oldM3ipp == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if !reflect.DeepEqual(c.Spec.NamePrefix, oldM3ipp.Spec.NamePrefix) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "NamePrefix"), + c.Spec.NamePrefix, + "cannot be modified", + ), + ) + } + allocationOutOfBonds, inUseOutOfBonds := c.checkPoolBonds(oldM3ipp) + if len(allocationOutOfBonds) != 0 { + for _, address := range allocationOutOfBonds { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "preAllocations"), + address, + "is out of bonds of the pools given", + ), + ) + } + } + if len(inUseOutOfBonds) != 0 { + for _, address := range inUseOutOfBonds { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pools"), + address, + "is in use but out of bonds of the pools given", + ), + ) + } + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +func (c *IPPool) checkPoolBonds(old *IPPool) ([]IPAddressStr, []IPAddressStr) { + allocationOutOfBonds := []IPAddressStr{} + inUseOutOfBonds := []IPAddressStr{} + for _, address := range c.Spec.PreAllocations { + inBonds := c.isAddressInBonds(address) + + if !inBonds { + allocationOutOfBonds = append(allocationOutOfBonds, address) + } + } + for _, address := range old.Status.Allocations { + inBonds := c.isAddressInBonds(address) + + if !inBonds { + inUseOutOfBonds = append(inUseOutOfBonds, address) + } + } + return allocationOutOfBonds, inUseOutOfBonds +} + +func (c *IPPool) isAddressInBonds(address IPAddressStr) bool { + ip, err := netip.ParseAddr(string(address)) + if err != nil { + return false + } + + for _, pool := range c.Spec.Pools { + if pool.Start != nil { + startIP, err := netip.ParseAddr(string(*pool.Start)) + if err != nil { + // skip this invalid pool, as the validation error should be caught somewhere else + continue + } + if startIP.Compare(ip) > 0 { + continue + } + } + + if pool.End != nil { + endIP, err := netip.ParseAddr(string(*pool.End)) + if err != nil { + // skip this invalid pool, as the validation error should be caught somewhere else + continue + } + if endIP.Compare(ip) < 0 { + continue + } + } + + if pool.Subnet != nil { + _, subnet, err := net.ParseCIDR(string(*pool.Subnet)) + if err != nil { + // skip this invalid pool, as the validation error should be caught somewhere else + continue + } + if !subnet.Contains(net.ParseIP(ip.String())) { + continue + } + } + + return true + } + + return false +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *IPPool) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +// No further validation for now. +func (c *IPPool) validate() (admission.Warnings, error) { + var allErrs field.ErrorList + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPPool").GroupKind(), c.Name, allErrs) +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go new file mode 100644 index 000000000..63909d1fd --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go @@ -0,0 +1,124 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + "fmt" + "math/big" + "net" + + "github.com/pkg/errors" +) + +// GetIPAddress renders the IP address, taking the index, offset and step into +// account, it is IP version agnostic. +func GetIPAddress(entry Pool, index int) (IPAddressStr, error) { + if entry.Start == nil && entry.Subnet == nil { + return "", errors.New("Either Start or Subnet is required for ipAddress") + } + var ip net.IP + var err error + var ipNet *net.IPNet + offset := index + + // If start is given, use it to add the offset. + if entry.Start != nil { + var endIP net.IP + if entry.End != nil { + endIP = net.ParseIP(string(*entry.End)) + } + ip, err = addOffsetToIP(net.ParseIP(string(*entry.Start)), endIP, offset) + if err != nil { + return "", err + } + + // Verify that the IP is in the subnet. + if entry.Subnet != nil { + _, ipNet, err = net.ParseCIDR(string(*entry.Subnet)) + if err != nil { + return "", err + } + if !ipNet.Contains(ip) { + return "", errors.New("IP address out of bonds") + } + } + + // If it is not given, use the CIDR ip address and increment the offset by 1. + } else { + ip, ipNet, err = net.ParseCIDR(string(*entry.Subnet)) + if err != nil { + return "", err + } + offset++ + ip, err = addOffsetToIP(ip, nil, offset) + if err != nil { + return "", err + } + + // Verify that the ip is in the subnet. + if !ipNet.Contains(ip) { + return "", errors.New("IP address out of bonds") + } + } + return IPAddressStr(ip.String()), nil +} + +// addOffsetToIP computes the value of the IP address with the offset. It is +// IP version agnostic +// Note that if the resulting IP address is in the format ::ffff:xxxx:xxxx then +// ip.String will fail to select the correct type of ip. +func addOffsetToIP(ip, endIP net.IP, offset int) (net.IP, error) { + ip4 := false + if ip.To4() != nil { + ip4 = true + } + + // Create big integers. + IPInt := big.NewInt(0) + OffsetInt := big.NewInt(int64(offset)) + + // Transform the ip into an int. (big endian function). + IPInt = IPInt.SetBytes(ip) + + // add the two integers. + IPInt = IPInt.Add(IPInt, OffsetInt) + + // return the bytes list. + IPBytes := IPInt.Bytes() + + IPBytesLen := len(IPBytes) + + // Verify that the IPv4 or IPv6 fulfills theirs constraints. + if (ip4 && IPBytesLen > 6 && IPBytes[4] != 255 && IPBytes[5] != 255) || + (!ip4 && IPBytesLen > 16) { + return nil, fmt.Errorf("IP address overflow for : %s", ip.String()) + } + + // transform the end ip into an Int to compare. + if endIP != nil { + endIPInt := big.NewInt(0) + endIPInt = endIPInt.SetBytes(endIP) + // Computed IP is higher than the end IP. + if IPInt.Cmp(endIPInt) > 0 { + return nil, fmt.Errorf("IP address out of bonds for : %s", ip.String()) + } + } + + // COpy the output back into an ip. + copy(ip[16-IPBytesLen:], IPBytes) + return ip, nil +} diff --git a/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..39be4327a --- /dev/null +++ b/e2e/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,380 @@ +//go:build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddress) DeepCopyInto(out *IPAddress) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddress. +func (in *IPAddress) DeepCopy() *IPAddress { + if in == nil { + return nil + } + out := new(IPAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddress) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressList) DeepCopyInto(out *IPAddressList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddress, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressList. +func (in *IPAddressList) DeepCopy() *IPAddressList { + if in == nil { + return nil + } + out := new(IPAddressList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressSpec) DeepCopyInto(out *IPAddressSpec) { + *out = *in + out.Claim = in.Claim + out.Pool = in.Pool + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(IPAddressStr) + **out = **in + } + if in.DNSServers != nil { + in, out := &in.DNSServers, &out.DNSServers + *out = make([]IPAddressStr, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressSpec. +func (in *IPAddressSpec) DeepCopy() *IPAddressSpec { + if in == nil { + return nil + } + out := new(IPAddressSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaim) DeepCopyInto(out *IPClaim) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaim. +func (in *IPClaim) DeepCopy() *IPClaim { + if in == nil { + return nil + } + out := new(IPClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPClaim) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaimList) DeepCopyInto(out *IPClaimList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimList. +func (in *IPClaimList) DeepCopy() *IPClaimList { + if in == nil { + return nil + } + out := new(IPClaimList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPClaimList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaimSpec) DeepCopyInto(out *IPClaimSpec) { + *out = *in + out.Pool = in.Pool +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimSpec. +func (in *IPClaimSpec) DeepCopy() *IPClaimSpec { + if in == nil { + return nil + } + out := new(IPClaimSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaimStatus) DeepCopyInto(out *IPClaimStatus) { + *out = *in + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(v1.ObjectReference) + **out = **in + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimStatus. +func (in *IPClaimStatus) DeepCopy() *IPClaimStatus { + if in == nil { + return nil + } + out := new(IPClaimStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPool) DeepCopyInto(out *IPPool) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPool. +func (in *IPPool) DeepCopy() *IPPool { + if in == nil { + return nil + } + out := new(IPPool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPPool) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolList) DeepCopyInto(out *IPPoolList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPPool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolList. +func (in *IPPoolList) DeepCopy() *IPPoolList { + if in == nil { + return nil + } + out := new(IPPoolList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPPoolList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec) { + *out = *in + if in.ClusterName != nil { + in, out := &in.ClusterName, &out.ClusterName + *out = new(string) + **out = **in + } + if in.Pools != nil { + in, out := &in.Pools, &out.Pools + *out = make([]Pool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PreAllocations != nil { + in, out := &in.PreAllocations, &out.PreAllocations + *out = make(map[string]IPAddressStr, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(IPAddressStr) + **out = **in + } + if in.DNSServers != nil { + in, out := &in.DNSServers, &out.DNSServers + *out = make([]IPAddressStr, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec. +func (in *IPPoolSpec) DeepCopy() *IPPoolSpec { + if in == nil { + return nil + } + out := new(IPPoolSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolStatus) DeepCopyInto(out *IPPoolStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.Allocations != nil { + in, out := &in.Allocations, &out.Allocations + *out = make(map[string]IPAddressStr, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolStatus. +func (in *IPPoolStatus) DeepCopy() *IPPoolStatus { + if in == nil { + return nil + } + out := new(IPPoolStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Pool) DeepCopyInto(out *Pool) { + *out = *in + if in.Start != nil { + in, out := &in.Start, &out.Start + *out = new(IPAddressStr) + **out = **in + } + if in.End != nil { + in, out := &in.End, &out.End + *out = new(IPAddressStr) + **out = **in + } + if in.Subnet != nil { + in, out := &in.Subnet, &out.Subnet + *out = new(IPSubnetStr) + **out = **in + } + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(IPAddressStr) + **out = **in + } + if in.DNSServers != nil { + in, out := &in.DNSServers, &out.DNSServers + *out = make([]IPAddressStr, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Pool. +func (in *Pool) DeepCopy() *Pool { + if in == nil { + return nil + } + out := new(Pool) + in.DeepCopyInto(out) + return out +} diff --git a/e2e/vendor/modules.txt b/e2e/vendor/modules.txt index cbc5c7de5..40c9bee74 100644 --- a/e2e/vendor/modules.txt +++ b/e2e/vendor/modules.txt @@ -185,6 +185,12 @@ github.com/leodido/go-urn/scim/schema github.com/mailru/easyjson/buffer github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter +# github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0 +## explicit; go 1.21 +github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1 +# github.com/metal3-io/ip-address-manager/api v1.7.0 +## explicit; go 1.21 +github.com/metal3-io/ip-address-manager/api/v1alpha1 # github.com/mitchellh/mapstructure v1.5.0 ## explicit; go 1.14 github.com/mitchellh/mapstructure diff --git a/go.mod b/go.mod index a233c4ca6..9910abf19 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ go 1.21 //) replace ( + github.com/metal3-io/cluster-api-provider-metal3 => github.com/openshift/cluster-api-provider-metal3 v0.0.0-20240529071518-ea1aa8a45bfa // controller-runtime 0.17.5 is using prometheus/client_golang to v1.18.0, which is incompatible with prometheus/common >= v0.48.0 // hence pinning them both. github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0 @@ -19,6 +20,7 @@ require ( github.com/go-logr/logr v1.4.2 github.com/gobuffalo/flect v1.0.2 github.com/golangci/golangci-lint v1.59.1 + github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0 github.com/onsi/ginkgo/v2 v2.19.0 github.com/onsi/gomega v1.33.1 github.com/openshift/api v0.0.0-20231129134630-a782d1c1541c @@ -188,6 +190,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/metal3-io/ip-address-manager/api v1.7.0 // indirect github.com/mgechev/revive v1.3.7 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect diff --git a/go.sum b/go.sum index ef6954311..7a36e3790 100644 --- a/go.sum +++ b/go.sum @@ -378,6 +378,10 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0 h1:9ALpFlMFacUTCZVChphg49xU/urSB+vvlAlxuICWLqU= +github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0/go.mod h1:c0M3xS4zQxJpHDVNEb53wLdbYa0/kuWJHw6d9a9CjGQ= +github.com/metal3-io/ip-address-manager/api v1.7.0 h1:ie9SQPWDWTjBnnxnG+qSfoqIOs+4vp5k0tVI+/0HNGo= +github.com/metal3-io/ip-address-manager/api v1.7.0/go.mod h1:6q41s9Y1P1lGSlMxMwRbIFzfy/XBRX4stvugGx1Jp5o= github.com/mgechev/revive v1.3.7 h1:502QY0vQGe9KtYJ9FpxMz9rL+Fc/P13CI5POL4uHCcE= github.com/mgechev/revive v1.3.7/go.mod h1:RJ16jUbF0OWC3co/+XTxmFNgEpUPwnnA0BRllX2aDNA= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= diff --git a/manifests/0000_30_cluster-api_00_credentials-request.yaml b/manifests/0000_30_cluster-api_00_credentials-request.yaml index fa0a93e52..f63ec6455 100644 --- a/manifests/0000_30_cluster-api_00_credentials-request.yaml +++ b/manifests/0000_30_cluster-api_00_credentials-request.yaml @@ -266,3 +266,20 @@ spec: secretRef: name: capv-manager-bootstrap-credentials namespace: openshift-cluster-api +--- +apiVersion: cloudcredential.openshift.io/v1 +kind: CredentialsRequest +metadata: + name: openshift-cluster-api-baremetal + namespace: openshift-cloud-credential-operator + annotations: + exclude.release.openshift.io/internal-openshift-hosted: "true" + include.release.openshift.io/self-managed-high-availability: "true" + release.openshift.io/feature-set: "TechPreviewNoUpgrade" +spec: + providerSpec: + apiVersion: cloudcredential.openshift.io/v1 + kind: Metal3ProviderSpec + secretRef: + name: capv-manager-bootstrap-credentials + namespace: openshift-cluster-api diff --git a/manifests/0000_30_cluster-api_01_images.configmap.yaml b/manifests/0000_30_cluster-api_01_images.configmap.yaml index d5b408799..492832ab3 100644 --- a/manifests/0000_30_cluster-api_01_images.configmap.yaml +++ b/manifests/0000_30_cluster-api_01_images.configmap.yaml @@ -19,5 +19,6 @@ data: "gcp-cluster-api-controllers": "registry.ci.openshift.org/openshift:gcp-cluster-api-controllers", "ibmcloud-cluster-api-controllers": "registry.ci.openshift.org/openshift:ibmcloud-cluster-api-controllers", "vsphere-cluster-api-controllers": "registry.ci.openshift.org/openshift:vsphere-cluster-api-controllers", + "baremetal-cluster-api-controllers": "registry.ci.openshift.org/openshift:baremetal-cluster-api-controllers", "kube-rbac-proxy": "registry.ci.openshift.org/openshift:kube-rbac-proxy" } diff --git a/manifests/image-references b/manifests/image-references index 6358bc52b..13f1de43f 100644 --- a/manifests/image-references +++ b/manifests/image-references @@ -38,3 +38,7 @@ spec: from: kind: DockerImage name: registry.ci.openshift.org/openshift:vsphere-cluster-api-controllers + - name: baremetal-cluster-api-controllers + from: + kind: DockerImage + name: registry.ci.openshift.org/openshift:baremetal-cluster-api-controllers diff --git a/pkg/webhook/cluster.go b/pkg/webhook/cluster.go index 1538f9ee4..427643ed4 100644 --- a/pkg/webhook/cluster.go +++ b/pkg/webhook/cluster.go @@ -80,10 +80,10 @@ func (r *ClusterWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) } switch cluster.Spec.InfrastructureRef.Kind { - case "AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster": + case "AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster", "Metal3Cluster": default: errs = append(errs, field.NotSupported(infrastructureRefPath.Child("kind"), - cluster.Spec.InfrastructureRef.Kind, []string{"AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster"})) + cluster.Spec.InfrastructureRef.Kind, []string{"AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster", "Metal3Cluster"})) } errs = append(errs, r.validateClusterName(ctx, cluster)) @@ -112,9 +112,9 @@ func (r *ClusterWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runt } switch newCluster.Spec.InfrastructureRef.Kind { - case "AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster": + case "AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster", "Metal3Cluster": default: - return nil, field.NotSupported(field.NewPath("spec", "infrastructureRef", "kind"), newCluster.Spec.InfrastructureRef.Kind, []string{"AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster"}) + return nil, field.NotSupported(field.NewPath("spec", "infrastructureRef", "kind"), newCluster.Spec.InfrastructureRef.Kind, []string{"AWSCluster", "AzureCluster", "GCPCluster", "IBMPowerVSCluster", "OpenStackCluster", "VSphereCluster", "Metal3Cluster"}) } return nil, nil diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/LICENSE b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/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/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go new file mode 100644 index 000000000..a71d3a758 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/common_types.go @@ -0,0 +1,109 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + "net/url" + "strings" + + "k8s.io/apimachinery/pkg/selection" + "k8s.io/apimachinery/pkg/util/validation/field" +) + +const ( + // UnhealthyAnnotation is the annotation that sets unhealthy status of BMH. + UnhealthyAnnotation = "capi.metal3.io/unhealthy" + + LiveISODiskFormat = "live-iso" +) + +// APIEndpoint represents a reachable Kubernetes API endpoint. +type APIEndpoint struct { + // Host is the hostname on which the API server is serving. + Host string `json:"host"` + + // Port is the port on which the API server is serving. + Port int `json:"port"` +} + +// HostSelector specifies matching criteria for labels on BareMetalHosts. +// This is used to limit the set of BareMetalHost objects considered for +// claiming for a Machine. +type HostSelector struct { + // Key/value pairs of labels that must exist on a chosen BareMetalHost + // +optional + MatchLabels map[string]string `json:"matchLabels,omitempty"` + + // Label match expressions that must be true on a chosen BareMetalHost + // +optional + MatchExpressions []HostSelectorRequirement `json:"matchExpressions,omitempty"` +} + +type HostSelectorRequirement struct { + Key string `json:"key"` + Operator selection.Operator `json:"operator"` + Values []string `json:"values"` +} + +// Image holds the details of an image to use during provisioning. +type Image struct { + // URL is a location of an image to deploy. + URL string `json:"url"` + + // Checksum is a md5sum, sha256sum or sha512sum value or a URL to retrieve one. + Checksum string `json:"checksum"` + + // ChecksumType is the checksum algorithm for the image. + // e.g md5, sha256, sha512 + // +kubebuilder:validation:Enum=md5;sha256;sha512 + // +optional + ChecksumType *string `json:"checksumType,omitempty"` + + // DiskFormat contains the image disk format. + // +kubebuilder:validation:Enum=raw;qcow2;vdi;vmdk;live-iso + // +optional + DiskFormat *string `json:"format,omitempty"` +} + +// Validate performs validation on [Image], returning a list of field errors using the provided base path. +// It is intended to be used in the validation webhooks of resources containing [Image]. +func (i *Image) Validate(base field.Path) field.ErrorList { + var errors field.ErrorList + + if i.URL == "" { + errors = append(errors, field.Required(base.Child("URL"), "cannot be empty")) + } else { + _, err := url.ParseRequestURI(i.URL) + if err != nil { + errors = append(errors, field.Invalid(base.Child("URL"), i.URL, "not a valid URL")) + } + } + // Checksum is not required for live-iso. + if i.DiskFormat == nil || *i.DiskFormat != LiveISODiskFormat { + if i.Checksum == "" { + errors = append(errors, field.Required(base.Child("Checksum"), "cannot be empty")) + } + + if strings.HasPrefix(i.Checksum, "http://") || strings.HasPrefix(i.Checksum, "https://") { + _, err := url.ParseRequestURI(i.Checksum) + if err != nil { + errors = append(errors, field.Invalid(base.Child("Checksum"), i.Checksum, "not a valid URL")) + } + } + } + return errors +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go new file mode 100644 index 000000000..38c4c5e1f --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/condition_consts.go @@ -0,0 +1,79 @@ +/* +Copyright 2021 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 v1beta1 + +import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + +// Metal3Cluster Conditions and Reasons. +const ( + // BaremetalInfrastructureReadyCondition reports the current status of + // cluster infrastructure. At the moment this is cosmetic since + // Metal3Cluster does not contain any infra setup steps. + BaremetalInfrastructureReadyCondition clusterv1.ConditionType = "BaremetalInfrastructureReady" + // ControlPlaneEndpointFailedReason is used to indicate that provided ControlPlaneEndpoint is invalid. + ControlPlaneEndpointFailedReason = "ControlPlaneEndpointFailed" + // InternalFailureReason is used to indicate that an internal failure + // occurred. The `Message` field of the Condition should be consluted for + // details on the failure. + InternalFailureReason = "InternalFailureOccured" +) + +// Metal3Machine Conditions and Reasons. +const ( + // AssociateBMHCondition documents the status of associated the Metal3Machine with a BaremetalHost. + AssociateBMHCondition clusterv1.ConditionType = "AssociateBMH" + + // WaitingForClusterInfrastructureReason used when waiting for cluster + // infrastructure to be ready before proceeding. + WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure" + // WaitingForBootstrapReadyReason used when waiting for bootstrap to be ready before proceeding. + WaitingForBootstrapReadyReason = "WaitingForBootstrapReady" + // AssociateBMHFailedReason documents any errors while associating Metal3Machine with a BaremetalHost. + AssociateBMHFailedReason = "AssociateBMHFailed" + // WaitingForMetal3MachineOwnerRefReason is used when Metal3Machine is waiting for OwnerReference to be + // set before proceeding. + WaitingForMetal3MachineOwnerRefReason = "WaitingForM3MachineOwnerRef" + // Metal3MachinePausedReason is used when Metal3Machine or Cluster is paused. + Metal3MachinePausedReason = "Metal3MachinePaused" + // WaitingforMetal3ClusterReason is used when Metal3Machine is waiting for Metal3Cluster. + WaitingforMetal3ClusterReason = "WaitingforMetal3Cluster" + // PauseAnnotationRemoveFailedReason is used when failed to remove/check pause annotation on associated bmh. + PauseAnnotationRemoveFailedReason = "PauseAnnotationRemoveFailed" + // PauseAnnotationSetFailedReason is used when failed to set pause annotation on associated bmh. + PauseAnnotationSetFailedReason = "PauseAnnotationSetFailedReason" + + // KubernetesNodeReadyCondition documents the transition of a Metal3Machine into a Kubernetes Node. + KubernetesNodeReadyCondition clusterv1.ConditionType = "KubernetesNodeReady" + // Could not find the BMH associated with the Metal3Machine. + MissingBMHReason = "MissingBMH" + // Could not set the ProviderID on the target cluster's Node object. + SettingProviderIDOnNodeFailedReason = "SettingProviderIDOnNodeFailed" + // Metal3DataReadyCondition reports a summary of Metal3Data status. + Metal3DataReadyCondition clusterv1.ConditionType = "Metal3DataReady" + // WaitingForMetal3DataReason used when waiting for Metal3Data + // to be ready before proceeding. + WaitingForMetal3DataReason = "WaitingForMetal3Data" + // AssociateM3MetaDataFailedReason is used when failed to associate Metadata to Metal3Machine. + AssociateM3MetaDataFailedReason = "AssociateM3MetaDataFailed" + // DisassociateM3MetaDataFailedReason is used when failed to remove OwnerReference of Meta3DataTemplate. + DisassociateM3MetaDataFailedReason = "DisassociateM3MetaDataFailed" + // DeletingReason (Severity=Info) documents a condition not in Status=True because the underlying object it is currently being deleted. + DeletingReason = "Deleting" + // DeletionFailedReason (Severity=Warning) documents a condition not in Status=True because the underlying object + // encountered problems during deletion. This is a warning because the reconciler will retry deletion. + DeletionFailedReason = "DeletionFailed" +) diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go new file mode 100644 index 000000000..acdbd86e5 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2021 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 v1beta1 + +func (*Metal3Cluster) Hub() {} +func (*Metal3ClusterList) Hub() {} +func (*Metal3Machine) Hub() {} +func (*Metal3MachineList) Hub() {} +func (*Metal3MachineTemplate) Hub() {} +func (*Metal3MachineTemplateList) Hub() {} +func (*Metal3DataTemplate) Hub() {} +func (*Metal3DataTemplateList) Hub() {} +func (*Metal3Data) Hub() {} +func (*Metal3DataList) Hub() {} +func (*Metal3DataClaim) Hub() {} +func (*Metal3DataClaimList) Hub() {} +func (*Metal3Remediation) Hub() {} +func (*Metal3RemediationList) Hub() {} +func (*Metal3RemediationTemplate) Hub() {} +func (*Metal3RemediationTemplateList) Hub() {} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go new file mode 100644 index 000000000..94982651f --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2021 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 v1beta1 contains API Schema definitions for the metal3 v1beta1 API group +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +kubebuilder:object:generate=true +// +groupName=infrastructure.cluster.x-k8s.io +package v1beta1 diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go new file mode 100644 index 000000000..ba88602fc --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/groupversion_info.go @@ -0,0 +1,53 @@ +/* +Copyright 2021 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 v1beta1 contains API Schema definitions for the infrastructure v1beta1 API group +// +kubebuilder:object:generate=true +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +groupName=infrastructure.cluster.x-k8s.io +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "infrastructure.cluster.x-k8s.io", Version: "v1beta1"} + + /// schemeBuilder is used to add go types to the GroupVersionKind scheme. + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = schemeBuilder.AddToScheme + + objectTypes = []runtime.Object{} +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, objectTypes...) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} + +// Resource is required by pkg/client/listers/... +// func Resource(resource string) schema.GroupResource { +// return SchemeGroupVersion.WithResource(resource).GroupResource() +// } diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go new file mode 100644 index 000000000..365447f2e --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_types.go @@ -0,0 +1,134 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + "github.com/pkg/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + capierrors "sigs.k8s.io/cluster-api/errors" +) + +const ( + // ClusterFinalizer allows Metal3ClusterReconciler to clean up resources associated with Metal3Cluster before + // removing it from the apiserver. + ClusterFinalizer = "metal3cluster.infrastructure.cluster.x-k8s.io" +) + +// Metal3ClusterSpec defines the desired state of Metal3Cluster. +type Metal3ClusterSpec struct { + // ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. + // +optional + ControlPlaneEndpoint APIEndpoint `json:"controlPlaneEndpoint,omitempty"` + // Determines if the cluster is not to be deployed with an external cloud provider. + // If set to true, CAPM3 will use node labels to set providerID on the kubernetes nodes. + // If set to false, providerID is set on nodes by other entities and CAPM3 uses the value of the providerID on the m3m resource. + // +optional + NoCloudProvider bool `json:"noCloudProvider,omitempty"` +} + +// IsValid returns an error if the object is not valid, otherwise nil. The +// string representation of the error is suitable for human consumption. +func (s *Metal3ClusterSpec) IsValid() error { + missing := []string{} + if s.ControlPlaneEndpoint.Host == "" { + missing = append(missing, "ControlPlaneEndpoint.Host") + } + + if s.ControlPlaneEndpoint.Port == 0 { + missing = append(missing, "ControlPlaneEndpoint.Host") + } + + if len(missing) > 0 { + return errors.Errorf("Missing fields from Spec: %v", missing) + } + return nil +} + +// Metal3ClusterStatus defines the observed state of Metal3Cluster. +type Metal3ClusterStatus struct { + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // FailureReason indicates that there is a fatal problem reconciling the + // state, and will be set to a token value suitable for + // programmatic interpretation. + // +optional + FailureReason *capierrors.ClusterStatusError `json:"failureReason,omitempty"` + + // FailureMessage indicates that there is a fatal problem reconciling the + // state, and will be set to a descriptive error message. + // +optional + FailureMessage *string `json:"failureMessage,omitempty"` + + // Ready denotes that the Metal3 cluster (infrastructure) is ready. In + // Baremetal case, it does not mean anything for now as no infrastructure + // steps need to be performed. Required by Cluster API. Set to True by the + // metal3Cluster controller after creation. + // +optional + Ready bool `json:"ready"` + // Conditions defines current service state of the Metal3Cluster. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3clusters,scope=Namespaced,categories=cluster-api,shortName=m3c;m3cluster;m3clusters;metal3c;metal3cluster +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3Cluster" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="metal3Cluster is Ready" +// +kubebuilder:printcolumn:name="Error",type="string",JSONPath=".status.failureReason",description="Most recent error" +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this BMCluster belongs" +// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.controlPlaneEndpoint",description="Control plane endpoint" + +// Metal3Cluster is the Schema for the metal3clusters API. +type Metal3Cluster struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Spec Metal3ClusterSpec `json:"spec,omitempty"` + // +optional + Status Metal3ClusterStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3ClusterList contains a list of Metal3Cluster. +type Metal3ClusterList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Cluster `json:"items"` +} + +// GetConditions returns the list of conditions for an Metal3Cluster API object. +func (c *Metal3Cluster) GetConditions() clusterv1.Conditions { + return c.Status.Conditions +} + +// SetConditions will set the given conditions on an Metal3Cluster object. +func (c *Metal3Cluster) SetConditions(conditions clusterv1.Conditions) { + c.Status.Conditions = conditions +} + +func init() { + objectTypes = append(objectTypes, &Metal3Cluster{}, &Metal3ClusterList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go new file mode 100644 index 000000000..c7aa82218 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3cluster_webhook.go @@ -0,0 +1,75 @@ +/* +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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3Cluster) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3cluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3clusters,versions=v1beta1,name=validation.metal3cluster.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3cluster,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3clusters,versions=v1beta1,name=default.metal3cluster.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Cluster{} +var _ webhook.Validator = &Metal3Cluster{} + +func (c *Metal3Cluster) Default() { + if c.Spec.ControlPlaneEndpoint.Port == 0 { + c.Spec.ControlPlaneEndpoint.Port = 6443 + } +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Cluster) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Cluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Cluster) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3Cluster) validate() error { + var allErrs field.ErrorList + if c.Spec.ControlPlaneEndpoint.Host == "" { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "controlPlaneEndpoint"), + c.Spec.ControlPlaneEndpoint.Host, + "is required", + ), + ) + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Cluster").GroupKind(), c.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go new file mode 100644 index 000000000..215238862 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_types.go @@ -0,0 +1,98 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataFinalizer allows Metal3DataReconciler to clean up resources + // associated with Metal3Data before removing it from the apiserver. + DataFinalizer = "metal3data.infrastructure.cluster.x-k8s.io" +) + +// Metal3DataSpec defines the desired state of Metal3Data. +type Metal3DataSpec struct { + // Index stores the index value of this instance in the Metal3DataTemplate. + // +optional + Index int `json:"index,omitempty"` + + // TemplateReference refers to the Template the Metal3MachineTemplate refers to. + // It can be matched against the key or it may also point to the name of the template + // Metal3Data refers to + // +optional + TemplateReference string `json:"templateReference,omitempty"` + + // MetaData points to the rendered MetaData secret. + // +optional + MetaData *corev1.SecretReference `json:"metaData,omitempty"` + + // NetworkData points to the rendered NetworkData secret. + // +optional + NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + + // DataClaim points to the Metal3DataClaim the Metal3Data was created for. + Claim corev1.ObjectReference `json:"claim"` + + // DataTemplate is the Metal3DataTemplate this was generated from. + Template corev1.ObjectReference `json:"template"` +} + +// Metal3DataStatus defines the observed state of Metal3Data. +type Metal3DataStatus struct { + // Ready is a flag set to True if the secrets were rendered properly + // +optional + Ready bool `json:"ready"` + + // ErrorMessage contains the error message + // +optional + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3datas,scope=Namespaced,categories=cluster-api,shortName=m3d;m3data;m3datas;metal3d;metal3data +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3Data" +// Metal3Data is the Schema for the metal3datas API. +type Metal3Data struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3DataSpec `json:"spec,omitempty"` + // +optional + Status Metal3DataStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3DataList contains a list of Metal3Data. +type Metal3DataList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Data `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3Data{}, &Metal3DataList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go new file mode 100644 index 000000000..9e6811846 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3data_webhook.go @@ -0,0 +1,152 @@ +/* +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 v1beta1 + +import ( + "strconv" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3Data) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3data,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datas,versions=v1beta1,name=validation.metal3data.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3data,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datas,versions=v1beta1,name=default.metal3data.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Data{} +var _ webhook.Validator = &Metal3Data{} + +func (c *Metal3Data) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Data) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if (c.Spec.TemplateReference != "" && c.Name != c.Spec.TemplateReference+"-"+strconv.Itoa(c.Spec.Index)) || + (c.Spec.TemplateReference == "" && c.Name != c.Spec.Template.Name+"-"+strconv.Itoa(c.Spec.Index)) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("name"), + c.Name, + "should follow the convention -", + ), + ) + } + + if c.Spec.Index < 0 { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Index"), + c.Spec.Index, + "must be positive value", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Data) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldMetal3Data, ok := old.(*Metal3Data) + if !ok || oldMetal3Data == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Index != oldMetal3Data.Spec.Index { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Index"), + c.Spec.Index, + "cannot be modified", + ), + ) + } + + if c.Spec.Template.Name != oldMetal3Data.Spec.Template.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Namespace != oldMetal3Data.Spec.Template.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Kind != oldMetal3Data.Spec.Template.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "Template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } + + if c.Spec.Claim.Name != oldMetal3Data.Spec.Claim.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Namespace != oldMetal3Data.Spec.Claim.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Kind != oldMetal3Data.Spec.Claim.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Data) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go new file mode 100644 index 000000000..dd7345d84 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_types.go @@ -0,0 +1,77 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataClaimFinalizer allows Metal3DataReconciler to clean up resources + // associated with Metal3DataClaim before removing it from the apiserver. + DataClaimFinalizer = "metal3dataclaim.infrastructure.cluster.x-k8s.io" +) + +// Metal3DataClaimSpec defines the desired state of Metal3DataClaim. +type Metal3DataClaimSpec struct { + // Template is the Metal3DataTemplate this was generated for. + Template corev1.ObjectReference `json:"template"` +} + +// Metal3DataClaimStatus defines the observed state of Metal3DataClaim. +type Metal3DataClaimStatus struct { + // RenderedData references the Metal3Data when ready + // +optional + RenderedData *corev1.ObjectReference `json:"renderedData,omitempty"` + + // ErrorMessage contains the error message + // +optional + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3dataclaims,scope=Namespaced,categories=cluster-api,shortName=m3dc;m3dataclaim;m3dataclaims;metal3dc;metal3dataclaim +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3DataClaim" +// Metal3DataClaim is the Schema for the metal3datas API. +type Metal3DataClaim struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3DataClaimSpec `json:"spec,omitempty"` + // +optional + Status Metal3DataClaimStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3DataClaimList contains a list of Metal3DataClaim. +type Metal3DataClaimList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3DataClaim `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3DataClaim{}, &Metal3DataClaimList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go new file mode 100644 index 000000000..32d7978f9 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3dataclaim_webhook.go @@ -0,0 +1,103 @@ +/* +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 v1beta1 + +import ( + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3DataClaim) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3dataclaim,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3dataclaims,versions=v1beta1,name=validation.metal3dataclaim.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3dataclaim,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3dataclaims,versions=v1beta1,name=default.metal3dataclaim.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3DataClaim{} +var _ webhook.Validator = &Metal3DataClaim{} + +func (c *Metal3DataClaim) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataClaim) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if c.Spec.Template.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template", "name"), + c.Spec.Template.Name, + "must be set", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataClaim) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldMetal3DataClaim, ok := old.(*Metal3DataClaim) + if !ok || oldMetal3DataClaim == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Template.Name != oldMetal3DataClaim.Spec.Template.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Namespace != oldMetal3DataClaim.Spec.Template.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } else if c.Spec.Template.Kind != oldMetal3DataClaim.Spec.Template.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "template"), + c.Spec.Template, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataClaim) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go new file mode 100644 index 000000000..4565596ed --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_types.go @@ -0,0 +1,580 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + ipamv1 "github.com/metal3-io/ip-address-manager/api/v1alpha1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataTemplateFinalizer allows Metal3DataTemplateReconciler to clean up resources + // associated with Metal3DataTemplate before removing it from the apiserver. + DataTemplateFinalizer = "metal3datatemplate.infrastructure.cluster.x-k8s.io" +) + +// MetaDataIndex contains the information to render the index. +type MetaDataIndex struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Offset is the offset to apply to the index when rendering it + // +optional + Offset int `json:"offset,omitempty"` + // +kubebuilder:default=1 + // Step is the multiplier of the index + // +optional + Step int `json:"step,omitempty"` + // Prefix is the prefix string + // +optional + Prefix string `json:"prefix,omitempty"` + // Suffix is the suffix string + // +optional + Suffix string `json:"suffix,omitempty"` +} + +// MetaDataFromLabel contains the information to fetch a label content, if the +// label does not exist, it is rendered as empty string. +type MetaDataFromLabel struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` + // Label is the key of the label to fetch + Label string `json:"label"` +} + +// MetaDataFromAnnotation contains the information to fetch an annotation +// content, if the label does not exist, it is rendered as empty string. +type MetaDataFromAnnotation struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` + // Annotation is the key of the Annotation to fetch + Annotation string `json:"annotation"` +} + +// MetaDataString contains the information to render the string. +type MetaDataString struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Value is the string to render. + Value string `json:"value"` +} + +// MetaDataNamespace contains the information to render the namespace. +type MetaDataNamespace struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` +} + +// MetaDataObjectName contains the information to render the object name. +type MetaDataObjectName struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` +} + +// MetaDataHostInterface contains the information to render the object name. +type MetaDataHostInterface struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Interface is the name of the interface in the BareMetalHost Status Hardware + // Details list of interfaces from which to fetch the MAC address. + Interface string `json:"interface"` +} + +// MetaDataIPAddress contains the info to render th ip address. It is IP-version +// agnostic. +type MetaDataIPAddress struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + // Start is the first ip address that can be rendered + // +optional + Start *ipamv1.IPAddressStr `json:"start,omitempty"` + // End is the last IP address that can be rendered. It is used as a validation + // that the rendered IP is in bound. + // +optional + End *ipamv1.IPAddressStr `json:"end,omitempty"` + // Subnet is used to validate that the rendered IP is in bounds. In case the + // Start value is not given, it is derived from the subnet ip incremented by 1 + // (`192.168.0.1` for `192.168.0.0/24`) + // +optional + Subnet *ipamv1.IPSubnetStr `json:"subnet,omitempty"` + // +kubebuilder:default=1 + // Step is the step between the IP addresses rendered. + // +optional + Step int `json:"step,omitempty"` +} + +type FromPool struct { + // Key will be used as the key to set in the metadata map for cloud-init + Key string `json:"key"` + + // Name is the name of the IP pool used to fetch the value to set in the metadata map for cloud-init + Name string `json:"name"` + + // APIGroup is the api group of the IP pool. + APIGroup string `json:"apiGroup"` + + // Kind is the kind of the IP pool + Kind string `json:"kind"` +} + +// MetaData represents a keyand value of the metadata. +type MetaData struct { + // Strings is the list of metadata items to be rendered from strings + // +optional + Strings []MetaDataString `json:"strings,omitempty"` + + // ObjectNames is the list of metadata items to be rendered from the name + // of objects. + // +optional + ObjectNames []MetaDataObjectName `json:"objectNames,omitempty"` + + // Indexes is the list of metadata items to be rendered from the index of the + // Metal3Data + // +optional + Indexes []MetaDataIndex `json:"indexes,omitempty"` + + // Namespaces is the list of metadata items to be rendered from the namespace + // +optional + Namespaces []MetaDataNamespace `json:"namespaces,omitempty"` + + // IPAddressesFromPool is the list of metadata items to be rendered as ip addresses. + // +optional + IPAddressesFromPool []FromPool `json:"ipAddressesFromIPPool,omitempty"` + + // PrefixesFromPool is the list of metadata items to be rendered as network prefixes. + // +optional + PrefixesFromPool []FromPool `json:"prefixesFromIPPool,omitempty"` + + // GatewaysFromPool is the list of metadata items to be rendered as gateway addresses. + // +optional + GatewaysFromPool []FromPool `json:"gatewaysFromIPPool,omitempty"` + + // DNSServersFromPool is the list of metadata items to be rendered as dns servers. + // +optional + DNSServersFromPool []FromPool `json:"dnsServersFromIPPool,omitempty"` + + // FromHostInterfaces is the list of metadata items to be rendered as MAC + // addresses of the host interfaces. + // +optional + FromHostInterfaces []MetaDataHostInterface `json:"fromHostInterfaces,omitempty"` + + // FromLabels is the list of metadata items to be fetched from object labels + // +optional + FromLabels []MetaDataFromLabel `json:"fromLabels,omitempty"` + + // FromAnnotations is the list of metadata items to be fetched from object + // Annotations + // +optional + FromAnnotations []MetaDataFromAnnotation `json:"fromAnnotations,omitempty"` +} + +// NetworkLinkEthernetMacFromAnnotation contains the information to fetch an annotation +// content, if the label does not exist, it is rendered as empty string. +type NetworkLinkEthernetMacFromAnnotation struct { + // +kubebuilder:validation:Enum=machine;metal3machine;baremetalhost + // Object is the type of the object from which we retrieve the name + Object string `json:"object"` + // Annotation is the key of the Annotation to fetch + Annotation string `json:"annotation"` +} + +// NetworkLinkEthernetMac represents the Mac address content. +type NetworkLinkEthernetMac struct { + // String contains the MAC address given as a string + // +optional + String *string `json:"string,omitempty"` + + // FromHostInterface contains the name of the interface in the BareMetalHost + // Introspection details from which to fetch the MAC address + // +optional + FromHostInterface *string `json:"fromHostInterface,omitempty"` + + // FromAnnotation references an object Annotation to retrieve the + // MAC address from + // +optional + FromAnnotation *NetworkLinkEthernetMacFromAnnotation `json:"fromAnnotation,omitempty"` +} + +// NetworkDataLinkEthernet represents an ethernet link object. +type NetworkDataLinkEthernet struct { + // +kubebuilder:validation:Enum=bridge;dvs;hw_veb;hyperv;ovs;tap;vhostuser;vif;phy + // Type is the type of the ethernet link. It can be one of: + // bridge, dvs, hw_veb, hyperv, ovs, tap, vhostuser, vif, phy + Type string `json:"type"` + + // Id is the ID of the interface (used for naming) + Id string `json:"id"` //nolint:revive,stylecheck + + // +kubebuilder:default=1500 + // +kubebuilder:validation:Maximum=9000 + // MTU is the MTU of the interface + // +optional + MTU int `json:"mtu,omitempty"` + + // MACAddress is the MAC address of the interface, containing the object + // used to render it. + MACAddress *NetworkLinkEthernetMac `json:"macAddress"` +} + +// NetworkDataLinkBond represents a bond link object. +type NetworkDataLinkBond struct { + // +kubebuilder:validation:Enum="balance-rr";"active-backup";"balance-xor";"broadcast";"balance-tlb";"balance-alb";"802.3ad" + // BondMode is the mode of bond used. It can be one of + // balance-rr, active-backup, balance-xor, broadcast, balance-tlb, balance-alb, 802.3ad + BondMode string `json:"bondMode"` + + // +kubebuilder:validation:Enum="layer2";"layer3+4";"layer2+3" + // Selects the transmit hash policy used for port selection in balance-xor and 802.3ad modes + // +optional + BondXmitHashPolicy string `json:"bondXmitHashPolicy"` + + // Id is the ID of the interface (used for naming) + Id string `json:"id"` //nolint:revive,stylecheck + + // +kubebuilder:default=1500 + // +kubebuilder:validation:Maximum=9000 + // MTU is the MTU of the interface + // +optional + MTU int `json:"mtu,omitempty"` + + // MACAddress is the MAC address of the interface, containing the object + // used to render it. + MACAddress *NetworkLinkEthernetMac `json:"macAddress"` + + // BondLinks is the list of links that are part of the bond. + // +optional + BondLinks []string `json:"bondLinks"` +} + +// NetworkDataLinkVlan represents a vlan link object. +type NetworkDataLinkVlan struct { + // +kubebuilder:validation:Maximum=4096 + // VlanID is the Vlan ID + VlanID int `json:"vlanID"` + + // Id is the ID of the interface (used for naming) + Id string `json:"id"` //nolint:revive,stylecheck + + // +kubebuilder:default=1500 + // +kubebuilder:validation:Maximum=9000 + // MTU is the MTU of the interface + // +optional + MTU int `json:"mtu,omitempty"` + + // MACAddress is the MAC address of the interface, containing the object + // used to render it. + MACAddress *NetworkLinkEthernetMac `json:"macAddress"` + + // VlanLink is the name of the link on which the vlan should be added + VlanLink string `json:"vlanLink"` +} + +// NetworkDataLink contains list of different link objects. +type NetworkDataLink struct { + + // Ethernets contains a list of Ethernet links + // +optional + Ethernets []NetworkDataLinkEthernet `json:"ethernets,omitempty"` + + // Bonds contains a list of Bond links + // +optional + Bonds []NetworkDataLinkBond `json:"bonds,omitempty"` + + // Vlans contains a list of Vlan links + // +optional + Vlans []NetworkDataLinkVlan `json:"vlans,omitempty"` +} + +// NetworkDataService represents a service object. +type NetworkDataService struct { + + // DNS is a list of DNS services + // +optional + DNS []ipamv1.IPAddressStr `json:"dns,omitempty"` + + // DNSFromIPPool is the name of the IPPool from which to get the DNS servers + // +optional + DNSFromIPPool *string `json:"dnsFromIPPool,omitempty"` +} + +// NetworkDataServicev4 represents a service object. +type NetworkDataServicev4 struct { + // DNS is a list of IPv4 DNS services + // +optional + DNS []ipamv1.IPAddressv4Str `json:"dns,omitempty"` + + // DNSFromIPPool is the name of the IPPool from which to get the DNS servers + // +optional + DNSFromIPPool *string `json:"dnsFromIPPool,omitempty"` +} + +// NetworkDataServicev6 represents a service object. +type NetworkDataServicev6 struct { + // DNS is a list of IPv6 DNS services + // +optional + DNS []ipamv1.IPAddressv6Str `json:"dns,omitempty"` + + // DNSFromIPPool is the name of the IPPool from which to get the DNS servers + // +optional + DNSFromIPPool *string `json:"dnsFromIPPool,omitempty"` +} + +// NetworkGatewayv4 represents a gateway, given as a string or as a reference to +// a Metal3IPPool. +type NetworkGatewayv4 struct { + + // String is the gateway given as a string + // +optional + String *ipamv1.IPAddressv4Str `json:"string,omitempty"` + + // FromIPPool is the name of the IPPool to fetch the gateway from + // +optional + FromIPPool *string `json:"fromIPPool,omitempty"` +} + +// NetworkGatewayv6 represents a gateway, given as a string or as a reference to +// a Metal3IPPool. +type NetworkGatewayv6 struct { + + // String is the gateway given as a string + // +optional + String *ipamv1.IPAddressv6Str `json:"string,omitempty"` + + // FromIPPool is the name of the IPPool to fetch the gateway from + // +optional + FromIPPool *string `json:"fromIPPool,omitempty"` +} + +// NetworkDataRoutev4 represents an ipv4 route object. +type NetworkDataRoutev4 struct { + // Network is the IPv4 network address + Network ipamv1.IPAddressv4Str `json:"network"` + + // +kubebuilder:validation:Maximum=32 + // Prefix is the mask of the network as integer (max 32) + // +optional + Prefix int `json:"prefix,omitempty"` + + // Gateway is the IPv4 address of the gateway + Gateway NetworkGatewayv4 `json:"gateway"` + + // Services is a list of IPv4 services + // +optional + Services NetworkDataServicev4 `json:"services,omitempty"` +} + +// NetworkDataRoutev6 represents an ipv6 route object. +type NetworkDataRoutev6 struct { + // Network is the IPv6 network address + Network ipamv1.IPAddressv6Str `json:"network"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + // +optional + Prefix int `json:"prefix,omitempty"` + + // Gateway is the IPv6 address of the gateway + Gateway NetworkGatewayv6 `json:"gateway"` + + // Services is a list of IPv6 services + // +optional + Services NetworkDataServicev6 `json:"services,omitempty"` +} + +// NetworkDataIPv4 represents an ipv4 static network object. +type NetworkDataIPv4 struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // IPAddressFromIPPool contains the name of the IP pool to use to get an ip address + IPAddressFromIPPool string `json:"ipAddressFromIPPool,omitempty"` + + // FromPoolRef is a reference to a IP pool to allocate an address from. + FromPoolRef *corev1.TypedLocalObjectReference `json:"fromPoolRef,omitempty"` + + // Routes contains a list of IPv4 routes + // +optional + Routes []NetworkDataRoutev4 `json:"routes,omitempty"` +} + +// NetworkDataIPv6 represents an ipv6 static network object. +type NetworkDataIPv6 struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // IPAddressFromIPPool contains the name of the IPPool to use to get an ip address + IPAddressFromIPPool string `json:"ipAddressFromIPPool"` + + // FromPoolRef is a reference to a IP pool to allocate an address from. + FromPoolRef *corev1.TypedLocalObjectReference `json:"fromPoolRef,omitempty"` + + // Routes contains a list of IPv6 routes + // +optional + Routes []NetworkDataRoutev6 `json:"routes,omitempty"` +} + +// NetworkDataIPv4DHCP represents an ipv4 DHCP network object. +type NetworkDataIPv4DHCP struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // Routes contains a list of IPv4 routes + // +optional + Routes []NetworkDataRoutev4 `json:"routes,omitempty"` +} + +// NetworkDataIPv6DHCP represents an ipv6 DHCP network object. +type NetworkDataIPv6DHCP struct { + + // ID is the network ID (name) + ID string `json:"id"` + + // Link is the link on which the network applies + Link string `json:"link"` + + // Routes contains a list of IPv6 routes + // +optional + Routes []NetworkDataRoutev6 `json:"routes,omitempty"` +} + +// NetworkDataNetwork represents a network object. +type NetworkDataNetwork struct { + + // IPv4 contains a list of IPv4 static allocations + // +optional + IPv4 []NetworkDataIPv4 `json:"ipv4,omitempty"` + + // IPv4 contains a list of IPv6 static allocations + // +optional + IPv6 []NetworkDataIPv6 `json:"ipv6,omitempty"` + + // IPv4 contains a list of IPv4 DHCP allocations + // +optional + IPv4DHCP []NetworkDataIPv4DHCP `json:"ipv4DHCP,omitempty"` + + // IPv4 contains a list of IPv6 DHCP allocations + // +optional + IPv6DHCP []NetworkDataIPv6DHCP `json:"ipv6DHCP,omitempty"` + + // IPv4 contains a list of IPv6 SLAAC allocations + // +optional + IPv6SLAAC []NetworkDataIPv6DHCP `json:"ipv6SLAAC,omitempty"` +} + +// NetworkData represents a networkData object. +type NetworkData struct { + // Links is a structure containing lists of different types objects + // +optional + Links NetworkDataLink `json:"links,omitempty"` + + // Networks is a structure containing lists of different types objects + // +optional + Networks NetworkDataNetwork `json:"networks,omitempty"` + + // Services is a structure containing lists of different types objects + // +optional + Services NetworkDataService `json:"services,omitempty"` +} + +// Metal3DataTemplateSpec defines the desired state of Metal3DataTemplate. +type Metal3DataTemplateSpec struct { + + // ClusterName is the name of the Cluster this object belongs to. + // +kubebuilder:validation:MinLength=1 + ClusterName string `json:"clusterName"` + + // TemplateReference refers to the Template the Metal3MachineTemplate refers to. + // It can be matched against the key or it may also point to the name of the template + // Metal3Data refers to + // +optional + TemplateReference string `json:"templateReference,omitempty"` + + // MetaData contains the information needed to generate the metadata secret + // +optional + MetaData *MetaData `json:"metaData,omitempty"` + + // NetworkData contains the information needed to generate the networkdata + // secret + // +optional + NetworkData *NetworkData `json:"networkData,omitempty"` +} + +// Metal3DataTemplateStatus defines the observed state of Metal3DataTemplate. +type Metal3DataTemplateStatus struct { + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // Indexes contains the map of Metal3Machine and index used + // +optional + Indexes map[string]int `json:"indexes,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3datatemplates,scope=Namespaced,categories=cluster-api,shortName=m3dt;m3datatemplate;m3datatemplates;metal3dt;metal3datatemplate +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this template belongs" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3DataTemplate" + +// Metal3DataTemplate is the Schema for the metal3datatemplates API. +type Metal3DataTemplate struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3DataTemplateSpec `json:"spec,omitempty"` + // +optional + Status Metal3DataTemplateStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3DataTemplateList contains a list of Metal3DataTemplate. +type Metal3DataTemplateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3DataTemplate `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3DataTemplate{}, &Metal3DataTemplateList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go new file mode 100644 index 000000000..7eb92753f --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3datatemplate_webhook.go @@ -0,0 +1,113 @@ +/* +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 v1beta1 + +import ( + "reflect" + "strconv" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3DataTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3datatemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datatemplates,versions=v1beta1,name=validation.metal3datatemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1,sideEffects=None +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3datatemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3datatemplates,versions=v1beta1,name=default.metal3datatemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3DataTemplate{} +var _ webhook.Validator = &Metal3DataTemplate{} + +func (c *Metal3DataTemplate) Default() {} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataTemplate) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldM3dt, ok := old.(*Metal3DataTemplate) + if !ok || oldM3dt == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if !reflect.DeepEqual(c.Spec.MetaData, oldM3dt.Spec.MetaData) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "MetaData"), + c.Spec.MetaData, + "cannot be modified", + ), + ) + } + + if !reflect.DeepEqual(c.Spec.NetworkData, oldM3dt.Spec.NetworkData) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "NetworkData"), + c.Spec.NetworkData, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3DataTemplate) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3DataTemplate) validate() error { + var allErrs field.ErrorList + + if c.Spec.NetworkData != nil { + for i, network := range c.Spec.NetworkData.Networks.IPv4 { + if (network.FromPoolRef == nil || network.FromPoolRef.Name == "") && network.IPAddressFromIPPool == "" { + allErrs = append(allErrs, field.Required( + field.NewPath("spec", "networkData", "networks", "ipv4", strconv.Itoa(i), "fromPoolRef", "name"), + "fromPoolRef needs to contain a reference to an IPPool", + )) + } + } + for i, network := range c.Spec.NetworkData.Networks.IPv6 { + if (network.FromPoolRef == nil || network.FromPoolRef.Name == "") && network.IPAddressFromIPPool == "" { + allErrs = append(allErrs, field.Required( + field.NewPath("spec", "networkData", "networks", "ipv6", strconv.Itoa(i), "fromPoolRef", "name"), + "fromPoolRef needs to contain a reference to an IPPool", + )) + } + } + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3DataTemplate").GroupKind(), c.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go new file mode 100644 index 000000000..ffad62c5d --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_types.go @@ -0,0 +1,213 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + capierrors "sigs.k8s.io/cluster-api/errors" +) + +const ( + // MachineFinalizer allows ReconcileMetal3Machine to clean up resources associated with Metal3Machine before + // removing it from the apiserver. + MachineFinalizer = "metal3machine.infrastructure.cluster.x-k8s.io" + CleaningModeDisabled = "disabled" + CleaningModeMetadata = "metadata" + ClonedFromGroupKind = "Metal3MachineTemplate.infrastructure.cluster.x-k8s.io" + LiveIsoDiskFormat = "live-iso" +) + +// Metal3MachineSpec defines the desired state of Metal3Machine. +type Metal3MachineSpec struct { + // ProviderID will be the Metal3 machine in ProviderID format + // (metal3://) + // +optional + ProviderID *string `json:"providerID,omitempty"` + + // Image is the image to be provisioned. + Image Image `json:"image"` + + // UserData references the Secret that holds user data needed by the bare metal + // operator. The Namespace is optional; it will default to the metal3machine's + // namespace if not specified. + // +optional + UserData *corev1.SecretReference `json:"userData,omitempty"` + + // HostSelector specifies matching criteria for labels on BareMetalHosts. + // This is used to limit the set of BareMetalHost objects considered for + // claiming for a metal3machine. + // +optional + HostSelector HostSelector `json:"hostSelector,omitempty"` + + // MetadataTemplate is a reference to a Metal3DataTemplate object containing + // a template of metadata to be rendered. Metadata keys defined in the + // metadataTemplate take precedence over keys defined in metadata field. + // +optional + DataTemplate *corev1.ObjectReference `json:"dataTemplate,omitempty"` + + // MetaData is an object storing the reference to the secret containing the + // Metadata given by the user. + // +optional + MetaData *corev1.SecretReference `json:"metaData,omitempty"` + + // NetworkData is an object storing the reference to the secret containing the + // network data given by the user. + // +optional + NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + + // When set to disabled, automated cleaning of host disks will be skipped + // during provisioning and deprovisioning. + // +kubebuilder:validation:Enum:=metadata;disabled + // +optional + AutomatedCleaningMode *string `json:"automatedCleaningMode,omitempty"` +} + +// Metal3MachineStatus defines the observed state of Metal3Machine. +type Metal3MachineStatus struct { + + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // FailureReason will be set in the event that there is a terminal problem + // reconciling the metal3machine and will contain a succinct value suitable + // for machine interpretation. + // + // This field should not be set for transitive errors that a controller + // faces that are expected to be fixed automatically over + // time (like service outages), but instead indicate that something is + // fundamentally wrong with the metal3machine's spec or the configuration of + // the controller, and that manual intervention is required. Examples + // of terminal errors would be invalid combinations of settings in the + // spec, values that are unsupported by the controller, or the + // responsible controller itself being critically misconfigured. + // + // Any transient errors that occur during the reconciliation of + // metal3machines can be added as events to the metal3machine object + // and/or logged in the controller's output. + // +optional + FailureReason *capierrors.MachineStatusError `json:"failureReason,omitempty"` + + // FailureMessage will be set in the event that there is a terminal problem + // reconciling the metal3machine and will contain a more verbose string suitable + // for logging and human consumption. + // + // This field should not be set for transitive errors that a controller + // faces that are expected to be fixed automatically over + // time (like service outages), but instead indicate that something is + // fundamentally wrong with the metal3machine's spec or the configuration of + // the controller, and that manual intervention is required. Examples + // of terminal errors would be invalid combinations of settings in the + // spec, values that are unsupported by the controller, or the + // responsible controller itself being critically misconfigured. + // + // Any transient errors that occur during the reconciliation of + // metal3machines can be added as events to the metal3machine object + // and/or logged in the controller's output. + // +optional + FailureMessage *string `json:"failureMessage,omitempty"` + + // Addresses is a list of addresses assigned to the machine. + // This field is copied from the infrastructure provider reference. + // +optional + Addresses clusterv1.MachineAddresses `json:"addresses,omitempty"` + + // Phase represents the current phase of machine actuation. + // E.g. Pending, Running, Terminating, Failed etc. + // +optional + Phase string `json:"phase,omitempty"` + + // Ready is the state of the metal3. + // TODO : Document the variable : + // mhrivnak: " it would be good to document what this means, how to interpret + // it, under what circumstances the value changes, etc." + // +optional + Ready bool `json:"ready"` + + // UserData references the Secret that holds user data needed by the bare metal + // operator. The Namespace is optional; it will default to the metal3machine's + // namespace if not specified. + // +optional + UserData *corev1.SecretReference `json:"userData,omitempty"` + + // RenderedData is a reference to a rendered Metal3Data object containing + // the references to metaData and networkData secrets. + // +optional + RenderedData *corev1.ObjectReference `json:"renderedData,omitempty"` + + // MetaData is an object storing the reference to the secret containing the + // Metadata used to deploy the BareMetalHost. + // +optional + MetaData *corev1.SecretReference `json:"metaData,omitempty"` + + // NetworkData is an object storing the reference to the secret containing the + // network data used to deploy the BareMetalHost. + // +optional + NetworkData *corev1.SecretReference `json:"networkData,omitempty"` + // Conditions defines current service state of the Metal3Machine. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3machines,scope=Namespaced,categories=cluster-api,shortName=m3m;m3machine;m3machines;metal3m;metal3machine +// +kubebuilder:object:root=true +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3Machine" +// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="Provider ID" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="metal3machine is Ready" +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this M3Machine belongs" +// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="metal3machine current phase" + +// Metal3Machine is the Schema for the metal3machines API. +type Metal3Machine struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3MachineSpec `json:"spec,omitempty"` + // +optional + Status Metal3MachineStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3MachineList contains a list of Metal3Machine. +type Metal3MachineList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Machine `json:"items"` +} + +// GetConditions returns the list of conditions for an Metal3Machine API object. +func (c *Metal3Machine) GetConditions() clusterv1.Conditions { + return c.Status.Conditions +} + +// SetConditions will set the given conditions on an Metal3Machine object. +func (c *Metal3Machine) SetConditions(conditions clusterv1.Conditions) { + c.Status.Conditions = conditions +} + +func init() { + objectTypes = append(objectTypes, &Metal3Machine{}, &Metal3MachineList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go new file mode 100644 index 000000000..3d95a09f5 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machine_webhook.go @@ -0,0 +1,64 @@ +/* +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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3Machine) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machine,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machines,versions=v1beta1,name=validation.metal3machine.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machine,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machines,versions=v1beta1,name=default.metal3machine.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Machine{} +var _ webhook.Validator = &Metal3Machine{} + +func (c *Metal3Machine) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Machine) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Machine) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3Machine) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3Machine) validate() error { + var allErrs field.ErrorList + + allErrs = append(allErrs, c.Spec.Image.Validate(*field.NewPath("Spec", "Image"))...) + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Machine").GroupKind(), c.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go new file mode 100644 index 000000000..c6d76a7a9 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_types.go @@ -0,0 +1,68 @@ +/* +Copyright 2021 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Metal3MachineTemplateSpec defines the desired state of Metal3MachineTemplate. +type Metal3MachineTemplateSpec struct { + Template Metal3MachineTemplateResource `json:"template"` + + // When set to True, CAPM3 Machine controller will + // pick the same pool of BMHs' that were released during the upgrade operation. + // +kubebuilder:default=false + // +optional + NodeReuse bool `json:"nodeReuse"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3MachineTemplate" +// +kubebuilder:resource:path=metal3machinetemplates,scope=Namespaced,categories=cluster-api,shortName=m3mt;m3machinetemplate;m3machinetemplates;metal3mt;metal3machinetemplate +// +kubebuilder:storageversion + +// Metal3MachineTemplate is the Schema for the metal3machinetemplates API. +type Metal3MachineTemplate struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3MachineTemplateSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3MachineTemplateList contains a list of Metal3MachineTemplate. +type Metal3MachineTemplateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3MachineTemplate `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3MachineTemplate{}, &Metal3MachineTemplateList{}) +} + +// Metal3MachineTemplateResource describes the data needed to create a Metal3Machine from a template. +type Metal3MachineTemplateResource struct { + // Spec is the specification of the desired behavior of the machine. + Spec Metal3MachineSpec `json:"spec"` +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go new file mode 100644 index 000000000..7061189f0 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3machinetemplate_webhook.go @@ -0,0 +1,64 @@ +/* +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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *Metal3MachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machinetemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machinetemplates,versions=v1beta1,name=validation.metal3machinetemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3machinetemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3machinetemplates,versions=v1beta1,name=default.metal3machinetemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3MachineTemplate{} +var _ webhook.Validator = &Metal3MachineTemplate{} + +func (c *Metal3MachineTemplate) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3MachineTemplate) ValidateCreate() (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3MachineTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, c.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *Metal3MachineTemplate) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +func (c *Metal3MachineTemplate) validate() error { + var allErrs field.ErrorList + + allErrs = append(allErrs, c.Spec.Template.Spec.Image.Validate(*field.NewPath("Spec", "Template", "Spec", "Image"))...) + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3MachineTemplate").GroupKind(), c.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go new file mode 100644 index 000000000..0cfeff6c2 --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_types.go @@ -0,0 +1,125 @@ +/* +Copyright 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type RemediationType string + +const ( + // RemediationFinalizer allows Metal3RemediationReconciler to clean up resources associated with Metal3Remediation before + // removing it from the apiserver. + RemediationFinalizer = "metal3remediation.infrastructure.cluster.x-k8s.io" + + // RebootRemediationStrategy sets RemediationType to Reboot. + RebootRemediationStrategy RemediationType = "Reboot" +) + +const ( + // PhaseRunning represents the running state during remediation. + PhaseRunning = "Running" + + // PhaseWaiting represents the state during remediation when the controller has done its job but still waiting for the result of the last remediation step. + PhaseWaiting = "Waiting" + + // PhaseDeleting represents the state where host remediation has failed and the controller is deleting the unhealthy Machine object from the cluster. + PhaseDeleting = "Deleting machine" + + // PhaseFailed represents the state where host will not be remediated. + // Remediation Controller will set the state to PhaseFailed when a user has set bmh.Spec.Online to false. + PhaseFailed = "Failed" +) + +// Metal3RemediationSpec defines the desired state of Metal3Remediation. +type Metal3RemediationSpec struct { + // Strategy field defines remediation strategy. + // +optional + Strategy *RemediationStrategy `json:"strategy,omitempty"` +} + +// RemediationStrategy describes how to remediate machines. +type RemediationStrategy struct { + // Type of remediation. + // +optional + Type RemediationType `json:"type,omitempty"` + + // Sets maximum number of remediation retries. + // +optional + RetryLimit int `json:"retryLimit,omitempty"` + + // Sets the timeout between remediation retries. + // +optional + Timeout *metav1.Duration `json:"timeout"` +} + +// Metal3RemediationStatus defines the observed state of Metal3Remediation. +type Metal3RemediationStatus struct { + // Phase represents the current phase of machine remediation. + // E.g. Pending, Running, Done etc. + // +optional + Phase string `json:"phase,omitempty"` + + // RetryCount can be used as a counter during the remediation. + // Field can hold number of reboots etc. + // +optional + RetryCount int `json:"retryCount,omitempty"` + + // LastRemediated identifies when the host was last remediated + // +optional + LastRemediated *metav1.Time `json:"lastRemediated,omitempty"` +} + +// +kubebuilder:object:root=true + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3remediations,scope=Namespaced,categories=cluster-api,shortName=m3r;m3remediation +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:printcolumn:name="Retry limit",type=string,JSONPath=".spec.strategy.retryLimit",description="How many times remediation controller should attempt to remediate the host" +// +kubebuilder:printcolumn:name="Retry count",type=string,JSONPath=".status.retryCount",description="How many times remediation controller has tried to remediate the node" +// +kubebuilder:printcolumn:name="Last Remediated",type=string,JSONPath=".status.lastRemediated",description="Timestamp of the last remediation attempt" +// +kubebuilder:printcolumn:name="Strategy",type=string,JSONPath=".spec.strategy.type",description="Type of the remediation strategy" +// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=".status.phase",description="Phase of the remediation" + +// Metal3Remediation is the Schema for the metal3remediations API. +type Metal3Remediation struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3RemediationSpec `json:"spec,omitempty"` + // +optional + Status Metal3RemediationStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3RemediationList contains a list of Metal3Remediation. +type Metal3RemediationList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3Remediation `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3Remediation{}, &Metal3RemediationList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go new file mode 100644 index 000000000..45e6011ed --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediation_webhook.go @@ -0,0 +1,103 @@ +/* +Copyright 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 v1beta1 + +import ( + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// log is for logging in this package. +var metal3remediationlog = logf.Log.WithName("metal3remediation-resource") + +func (r *Metal3Remediation) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediation,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediations,versions=v1beta1,name=validation.metal3remediation.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediation,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediations,versions=v1beta1,name=default.metal3remediation.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3Remediation{} +var _ webhook.Validator = &Metal3Remediation{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type. +func (r *Metal3Remediation) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3Remediation) ValidateCreate() (admission.Warnings, error) { + return nil, r.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3Remediation) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + return nil, r.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3Remediation) ValidateDelete() (admission.Warnings, error) { + metal3remediationlog.Info("validate delete", "name", r.Name) + return nil, nil +} + +func (r *Metal3Remediation) validate() error { + var allErrs field.ErrorList + if r.Spec.Strategy.Timeout != nil && r.Spec.Strategy.Timeout.Seconds() < minTimeout.Seconds() { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "strategy", "timeout"), + r.Spec.Strategy.Timeout, + "min duration is minTimeout.Seconds()", + ), + ) + } + + if r.Spec.Strategy.Type != RebootRemediationStrategy { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "strategy", "type"), + r.Spec.Strategy.Type, + "is only supported remediation strategy", + ), + ) + } + + if r.Spec.Strategy.RetryLimit < minRetryLimit { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "strategy", "retryLimit"), + r.Spec.Strategy.RetryLimit, + "is minimum retrylimit", + ), + ) + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Remediation").GroupKind(), r.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go new file mode 100644 index 000000000..6820985af --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_types.go @@ -0,0 +1,70 @@ +/* +Copyright 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Metal3RemediationTemplateSpec defines the desired state of Metal3RemediationTemplate. +type Metal3RemediationTemplateSpec struct { + Template Metal3RemediationTemplateResource `json:"template"` +} + +// Metal3RemediationTemplateResource describes the data needed to create a Metal3Remediation from a template. +type Metal3RemediationTemplateResource struct { + // Spec is the specification of the desired behavior of the Metal3Remediation. + Spec Metal3RemediationSpec `json:"spec"` +} + +// Metal3RemediationTemplateStatus defines the observed state of Metal3RemediationTemplate. +type Metal3RemediationTemplateStatus struct { + // Metal3RemediationStatus defines the observed state of Metal3Remediation + Status Metal3RemediationStatus `json:"status"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=metal3remediationtemplates,scope=Namespaced,categories=cluster-api,shortName=m3rt;m3remediationtemplate;m3remediationtemplates;metal3rt;metal3remediationtemplate +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// Metal3RemediationTemplate is the Schema for the metal3remediationtemplates API. +type Metal3RemediationTemplate struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec Metal3RemediationTemplateSpec `json:"spec,omitempty"` + // +optional + Status Metal3RemediationTemplateStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// Metal3RemediationTemplateList contains a list of Metal3RemediationTemplate. +type Metal3RemediationTemplateList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Metal3RemediationTemplate `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &Metal3RemediationTemplate{}, &Metal3RemediationTemplateList{}) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go new file mode 100644 index 000000000..902f8ba3f --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/metal3remediationtemplate_webhook.go @@ -0,0 +1,129 @@ +/* +Copyright 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 v1beta1 + +import ( + "time" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +var ( + // Default retry timeout is 600 seconds. + defaultTimeout = metav1.Duration{Duration: 600 * time.Second} + // Minimum time between remediation retries. + minTimeout = metav1.Duration{Duration: 100 * time.Second} + // Mininum remediation retry limit is 1. + // Controller will try to remediate unhealhy node at least once. + minRetryLimit = 1 +) + +// log is for logging in this package. +var metal3remediationtemplatelog = logf.Log.WithName("metal3remediationtemplate-resource") + +func (r *Metal3RemediationTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediationtemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediationtemplates,versions=v1beta1,name=validation.metal3remediationtemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-metal3remediationtemplate,mutating=true,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=metal3remediationtemplates,versions=v1beta1,name=default.metal3remediationtemplate.infrastructure.cluster.x-k8s.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &Metal3RemediationTemplate{} +var _ webhook.Validator = &Metal3RemediationTemplate{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) Default() { + if r.Spec.Template.Spec.Strategy.Type == "" { + r.Spec.Template.Spec.Strategy.Type = RebootRemediationStrategy + } + + if r.Spec.Template.Spec.Strategy.Timeout == nil { + r.Spec.Template.Spec.Strategy.Timeout = &defaultTimeout + } + + if r.Spec.Template.Spec.Strategy.RetryLimit == 0 || r.Spec.Template.Spec.Strategy.RetryLimit < minRetryLimit { + r.Spec.Template.Spec.Strategy.RetryLimit = minRetryLimit + } +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) ValidateCreate() (admission.Warnings, error) { + metal3remediationtemplatelog.Info("validate create", "name", r.Name) + return nil, r.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { + metal3remediationtemplatelog.Info("validate update", "name", r.Name) + return nil, r.validate() +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (r *Metal3RemediationTemplate) ValidateDelete() (admission.Warnings, error) { + metal3remediationtemplatelog.Info("validate delete", "name", r.Name) + return nil, nil +} + +func (r *Metal3RemediationTemplate) validate() error { + var allErrs field.ErrorList + if r.Spec.Template.Spec.Strategy.Timeout != nil && r.Spec.Template.Spec.Strategy.Timeout.Seconds() < minTimeout.Seconds() { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "template", "spec", "strategy", "timeout"), + r.Spec.Template.Spec.Strategy.Timeout, + "min duration is 100s", + ), + ) + } + + if r.Spec.Template.Spec.Strategy.Type != RebootRemediationStrategy { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "template", "spec", "strategy", "type"), + r.Spec.Template.Spec.Strategy.Type, + "only supported remediation strategy is reboot", + ), + ) + } + + if r.Spec.Template.Spec.Strategy.RetryLimit < minRetryLimit { + allErrs = append( + allErrs, + field.Invalid( + field.NewPath("spec", "template", "spec", "strategy", "retryLimit"), + r.Spec.Template.Spec.Strategy.RetryLimit, + "minimun retrylimit is 1", + ), + ) + } + + if len(allErrs) == 0 { + return nil + } + return apierrors.NewInvalid(GroupVersion.WithKind("Metal3Remediation").GroupKind(), r.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 000000000..0bf45443f --- /dev/null +++ b/vendor/github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,1719 @@ +//go:build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "github.com/metal3-io/ip-address-manager/api/v1alpha1" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + apiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/errors" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *APIEndpoint) DeepCopyInto(out *APIEndpoint) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new APIEndpoint. +func (in *APIEndpoint) DeepCopy() *APIEndpoint { + if in == nil { + return nil + } + out := new(APIEndpoint) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FromPool) DeepCopyInto(out *FromPool) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FromPool. +func (in *FromPool) DeepCopy() *FromPool { + if in == nil { + return nil + } + out := new(FromPool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostSelector) DeepCopyInto(out *HostSelector) { + *out = *in + if in.MatchLabels != nil { + in, out := &in.MatchLabels, &out.MatchLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.MatchExpressions != nil { + in, out := &in.MatchExpressions, &out.MatchExpressions + *out = make([]HostSelectorRequirement, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostSelector. +func (in *HostSelector) DeepCopy() *HostSelector { + if in == nil { + return nil + } + out := new(HostSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostSelectorRequirement) DeepCopyInto(out *HostSelectorRequirement) { + *out = *in + if in.Values != nil { + in, out := &in.Values, &out.Values + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostSelectorRequirement. +func (in *HostSelectorRequirement) DeepCopy() *HostSelectorRequirement { + if in == nil { + return nil + } + out := new(HostSelectorRequirement) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Image) DeepCopyInto(out *Image) { + *out = *in + if in.ChecksumType != nil { + in, out := &in.ChecksumType, &out.ChecksumType + *out = new(string) + **out = **in + } + if in.DiskFormat != nil { + in, out := &in.DiskFormat, &out.DiskFormat + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image. +func (in *Image) DeepCopy() *Image { + if in == nil { + return nil + } + out := new(Image) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaData) DeepCopyInto(out *MetaData) { + *out = *in + if in.Strings != nil { + in, out := &in.Strings, &out.Strings + *out = make([]MetaDataString, len(*in)) + copy(*out, *in) + } + if in.ObjectNames != nil { + in, out := &in.ObjectNames, &out.ObjectNames + *out = make([]MetaDataObjectName, len(*in)) + copy(*out, *in) + } + if in.Indexes != nil { + in, out := &in.Indexes, &out.Indexes + *out = make([]MetaDataIndex, len(*in)) + copy(*out, *in) + } + if in.Namespaces != nil { + in, out := &in.Namespaces, &out.Namespaces + *out = make([]MetaDataNamespace, len(*in)) + copy(*out, *in) + } + if in.IPAddressesFromPool != nil { + in, out := &in.IPAddressesFromPool, &out.IPAddressesFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.PrefixesFromPool != nil { + in, out := &in.PrefixesFromPool, &out.PrefixesFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.GatewaysFromPool != nil { + in, out := &in.GatewaysFromPool, &out.GatewaysFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.DNSServersFromPool != nil { + in, out := &in.DNSServersFromPool, &out.DNSServersFromPool + *out = make([]FromPool, len(*in)) + copy(*out, *in) + } + if in.FromHostInterfaces != nil { + in, out := &in.FromHostInterfaces, &out.FromHostInterfaces + *out = make([]MetaDataHostInterface, len(*in)) + copy(*out, *in) + } + if in.FromLabels != nil { + in, out := &in.FromLabels, &out.FromLabels + *out = make([]MetaDataFromLabel, len(*in)) + copy(*out, *in) + } + if in.FromAnnotations != nil { + in, out := &in.FromAnnotations, &out.FromAnnotations + *out = make([]MetaDataFromAnnotation, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaData. +func (in *MetaData) DeepCopy() *MetaData { + if in == nil { + return nil + } + out := new(MetaData) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataFromAnnotation) DeepCopyInto(out *MetaDataFromAnnotation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataFromAnnotation. +func (in *MetaDataFromAnnotation) DeepCopy() *MetaDataFromAnnotation { + if in == nil { + return nil + } + out := new(MetaDataFromAnnotation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataFromLabel) DeepCopyInto(out *MetaDataFromLabel) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataFromLabel. +func (in *MetaDataFromLabel) DeepCopy() *MetaDataFromLabel { + if in == nil { + return nil + } + out := new(MetaDataFromLabel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataHostInterface) DeepCopyInto(out *MetaDataHostInterface) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataHostInterface. +func (in *MetaDataHostInterface) DeepCopy() *MetaDataHostInterface { + if in == nil { + return nil + } + out := new(MetaDataHostInterface) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataIPAddress) DeepCopyInto(out *MetaDataIPAddress) { + *out = *in + if in.Start != nil { + in, out := &in.Start, &out.Start + *out = new(v1alpha1.IPAddressStr) + **out = **in + } + if in.End != nil { + in, out := &in.End, &out.End + *out = new(v1alpha1.IPAddressStr) + **out = **in + } + if in.Subnet != nil { + in, out := &in.Subnet, &out.Subnet + *out = new(v1alpha1.IPSubnetStr) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataIPAddress. +func (in *MetaDataIPAddress) DeepCopy() *MetaDataIPAddress { + if in == nil { + return nil + } + out := new(MetaDataIPAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataIndex) DeepCopyInto(out *MetaDataIndex) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataIndex. +func (in *MetaDataIndex) DeepCopy() *MetaDataIndex { + if in == nil { + return nil + } + out := new(MetaDataIndex) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataNamespace) DeepCopyInto(out *MetaDataNamespace) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataNamespace. +func (in *MetaDataNamespace) DeepCopy() *MetaDataNamespace { + if in == nil { + return nil + } + out := new(MetaDataNamespace) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataObjectName) DeepCopyInto(out *MetaDataObjectName) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataObjectName. +func (in *MetaDataObjectName) DeepCopy() *MetaDataObjectName { + if in == nil { + return nil + } + out := new(MetaDataObjectName) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetaDataString) DeepCopyInto(out *MetaDataString) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaDataString. +func (in *MetaDataString) DeepCopy() *MetaDataString { + if in == nil { + return nil + } + out := new(MetaDataString) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Cluster) DeepCopyInto(out *Metal3Cluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Cluster. +func (in *Metal3Cluster) DeepCopy() *Metal3Cluster { + if in == nil { + return nil + } + out := new(Metal3Cluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Cluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ClusterList) DeepCopyInto(out *Metal3ClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Cluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ClusterList. +func (in *Metal3ClusterList) DeepCopy() *Metal3ClusterList { + if in == nil { + return nil + } + out := new(Metal3ClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3ClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ClusterSpec) DeepCopyInto(out *Metal3ClusterSpec) { + *out = *in + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ClusterSpec. +func (in *Metal3ClusterSpec) DeepCopy() *Metal3ClusterSpec { + if in == nil { + return nil + } + out := new(Metal3ClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3ClusterStatus) DeepCopyInto(out *Metal3ClusterStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.ClusterStatusError) + **out = **in + } + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3ClusterStatus. +func (in *Metal3ClusterStatus) DeepCopy() *Metal3ClusterStatus { + if in == nil { + return nil + } + out := new(Metal3ClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Data) DeepCopyInto(out *Metal3Data) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Data. +func (in *Metal3Data) DeepCopy() *Metal3Data { + if in == nil { + return nil + } + out := new(Metal3Data) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Data) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaim) DeepCopyInto(out *Metal3DataClaim) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaim. +func (in *Metal3DataClaim) DeepCopy() *Metal3DataClaim { + if in == nil { + return nil + } + out := new(Metal3DataClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataClaim) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaimList) DeepCopyInto(out *Metal3DataClaimList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3DataClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaimList. +func (in *Metal3DataClaimList) DeepCopy() *Metal3DataClaimList { + if in == nil { + return nil + } + out := new(Metal3DataClaimList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataClaimList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaimSpec) DeepCopyInto(out *Metal3DataClaimSpec) { + *out = *in + out.Template = in.Template +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaimSpec. +func (in *Metal3DataClaimSpec) DeepCopy() *Metal3DataClaimSpec { + if in == nil { + return nil + } + out := new(Metal3DataClaimSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataClaimStatus) DeepCopyInto(out *Metal3DataClaimStatus) { + *out = *in + if in.RenderedData != nil { + in, out := &in.RenderedData, &out.RenderedData + *out = new(v1.ObjectReference) + **out = **in + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataClaimStatus. +func (in *Metal3DataClaimStatus) DeepCopy() *Metal3DataClaimStatus { + if in == nil { + return nil + } + out := new(Metal3DataClaimStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataList) DeepCopyInto(out *Metal3DataList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Data, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataList. +func (in *Metal3DataList) DeepCopy() *Metal3DataList { + if in == nil { + return nil + } + out := new(Metal3DataList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataSpec) DeepCopyInto(out *Metal3DataSpec) { + *out = *in + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(v1.SecretReference) + **out = **in + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(v1.SecretReference) + **out = **in + } + out.Claim = in.Claim + out.Template = in.Template +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataSpec. +func (in *Metal3DataSpec) DeepCopy() *Metal3DataSpec { + if in == nil { + return nil + } + out := new(Metal3DataSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataStatus) DeepCopyInto(out *Metal3DataStatus) { + *out = *in + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataStatus. +func (in *Metal3DataStatus) DeepCopy() *Metal3DataStatus { + if in == nil { + return nil + } + out := new(Metal3DataStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplate) DeepCopyInto(out *Metal3DataTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplate. +func (in *Metal3DataTemplate) DeepCopy() *Metal3DataTemplate { + if in == nil { + return nil + } + out := new(Metal3DataTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplateList) DeepCopyInto(out *Metal3DataTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3DataTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplateList. +func (in *Metal3DataTemplateList) DeepCopy() *Metal3DataTemplateList { + if in == nil { + return nil + } + out := new(Metal3DataTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3DataTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplateSpec) DeepCopyInto(out *Metal3DataTemplateSpec) { + *out = *in + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(MetaData) + (*in).DeepCopyInto(*out) + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(NetworkData) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplateSpec. +func (in *Metal3DataTemplateSpec) DeepCopy() *Metal3DataTemplateSpec { + if in == nil { + return nil + } + out := new(Metal3DataTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3DataTemplateStatus) DeepCopyInto(out *Metal3DataTemplateStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.Indexes != nil { + in, out := &in.Indexes, &out.Indexes + *out = make(map[string]int, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3DataTemplateStatus. +func (in *Metal3DataTemplateStatus) DeepCopy() *Metal3DataTemplateStatus { + if in == nil { + return nil + } + out := new(Metal3DataTemplateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Machine) DeepCopyInto(out *Metal3Machine) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Machine. +func (in *Metal3Machine) DeepCopy() *Metal3Machine { + if in == nil { + return nil + } + out := new(Metal3Machine) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Machine) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineList) DeepCopyInto(out *Metal3MachineList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Machine, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineList. +func (in *Metal3MachineList) DeepCopy() *Metal3MachineList { + if in == nil { + return nil + } + out := new(Metal3MachineList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3MachineList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineSpec) DeepCopyInto(out *Metal3MachineSpec) { + *out = *in + if in.ProviderID != nil { + in, out := &in.ProviderID, &out.ProviderID + *out = new(string) + **out = **in + } + in.Image.DeepCopyInto(&out.Image) + if in.UserData != nil { + in, out := &in.UserData, &out.UserData + *out = new(v1.SecretReference) + **out = **in + } + in.HostSelector.DeepCopyInto(&out.HostSelector) + if in.DataTemplate != nil { + in, out := &in.DataTemplate, &out.DataTemplate + *out = new(v1.ObjectReference) + **out = **in + } + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(v1.SecretReference) + **out = **in + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(v1.SecretReference) + **out = **in + } + if in.AutomatedCleaningMode != nil { + in, out := &in.AutomatedCleaningMode, &out.AutomatedCleaningMode + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineSpec. +func (in *Metal3MachineSpec) DeepCopy() *Metal3MachineSpec { + if in == nil { + return nil + } + out := new(Metal3MachineSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineStatus) DeepCopyInto(out *Metal3MachineStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.MachineStatusError) + **out = **in + } + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } + if in.Addresses != nil { + in, out := &in.Addresses, &out.Addresses + *out = make(apiv1beta1.MachineAddresses, len(*in)) + copy(*out, *in) + } + if in.UserData != nil { + in, out := &in.UserData, &out.UserData + *out = new(v1.SecretReference) + **out = **in + } + if in.RenderedData != nil { + in, out := &in.RenderedData, &out.RenderedData + *out = new(v1.ObjectReference) + **out = **in + } + if in.MetaData != nil { + in, out := &in.MetaData, &out.MetaData + *out = new(v1.SecretReference) + **out = **in + } + if in.NetworkData != nil { + in, out := &in.NetworkData, &out.NetworkData + *out = new(v1.SecretReference) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(apiv1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineStatus. +func (in *Metal3MachineStatus) DeepCopy() *Metal3MachineStatus { + if in == nil { + return nil + } + out := new(Metal3MachineStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplate) DeepCopyInto(out *Metal3MachineTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplate. +func (in *Metal3MachineTemplate) DeepCopy() *Metal3MachineTemplate { + if in == nil { + return nil + } + out := new(Metal3MachineTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3MachineTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplateList) DeepCopyInto(out *Metal3MachineTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3MachineTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplateList. +func (in *Metal3MachineTemplateList) DeepCopy() *Metal3MachineTemplateList { + if in == nil { + return nil + } + out := new(Metal3MachineTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3MachineTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplateResource) DeepCopyInto(out *Metal3MachineTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplateResource. +func (in *Metal3MachineTemplateResource) DeepCopy() *Metal3MachineTemplateResource { + if in == nil { + return nil + } + out := new(Metal3MachineTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3MachineTemplateSpec) DeepCopyInto(out *Metal3MachineTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3MachineTemplateSpec. +func (in *Metal3MachineTemplateSpec) DeepCopy() *Metal3MachineTemplateSpec { + if in == nil { + return nil + } + out := new(Metal3MachineTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3Remediation) DeepCopyInto(out *Metal3Remediation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3Remediation. +func (in *Metal3Remediation) DeepCopy() *Metal3Remediation { + if in == nil { + return nil + } + out := new(Metal3Remediation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3Remediation) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationList) DeepCopyInto(out *Metal3RemediationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3Remediation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationList. +func (in *Metal3RemediationList) DeepCopy() *Metal3RemediationList { + if in == nil { + return nil + } + out := new(Metal3RemediationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3RemediationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationSpec) DeepCopyInto(out *Metal3RemediationSpec) { + *out = *in + if in.Strategy != nil { + in, out := &in.Strategy, &out.Strategy + *out = new(RemediationStrategy) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationSpec. +func (in *Metal3RemediationSpec) DeepCopy() *Metal3RemediationSpec { + if in == nil { + return nil + } + out := new(Metal3RemediationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationStatus) DeepCopyInto(out *Metal3RemediationStatus) { + *out = *in + if in.LastRemediated != nil { + in, out := &in.LastRemediated, &out.LastRemediated + *out = (*in).DeepCopy() + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationStatus. +func (in *Metal3RemediationStatus) DeepCopy() *Metal3RemediationStatus { + if in == nil { + return nil + } + out := new(Metal3RemediationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplate) DeepCopyInto(out *Metal3RemediationTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplate. +func (in *Metal3RemediationTemplate) DeepCopy() *Metal3RemediationTemplate { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3RemediationTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateList) DeepCopyInto(out *Metal3RemediationTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metal3RemediationTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateList. +func (in *Metal3RemediationTemplateList) DeepCopy() *Metal3RemediationTemplateList { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metal3RemediationTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateResource) DeepCopyInto(out *Metal3RemediationTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateResource. +func (in *Metal3RemediationTemplateResource) DeepCopy() *Metal3RemediationTemplateResource { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateSpec) DeepCopyInto(out *Metal3RemediationTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateSpec. +func (in *Metal3RemediationTemplateSpec) DeepCopy() *Metal3RemediationTemplateSpec { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Metal3RemediationTemplateStatus) DeepCopyInto(out *Metal3RemediationTemplateStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metal3RemediationTemplateStatus. +func (in *Metal3RemediationTemplateStatus) DeepCopy() *Metal3RemediationTemplateStatus { + if in == nil { + return nil + } + out := new(Metal3RemediationTemplateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkData) DeepCopyInto(out *NetworkData) { + *out = *in + in.Links.DeepCopyInto(&out.Links) + in.Networks.DeepCopyInto(&out.Networks) + in.Services.DeepCopyInto(&out.Services) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkData. +func (in *NetworkData) DeepCopy() *NetworkData { + if in == nil { + return nil + } + out := new(NetworkData) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv4) DeepCopyInto(out *NetworkDataIPv4) { + *out = *in + if in.FromPoolRef != nil { + in, out := &in.FromPoolRef, &out.FromPoolRef + *out = new(v1.TypedLocalObjectReference) + (*in).DeepCopyInto(*out) + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev4, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv4. +func (in *NetworkDataIPv4) DeepCopy() *NetworkDataIPv4 { + if in == nil { + return nil + } + out := new(NetworkDataIPv4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv4DHCP) DeepCopyInto(out *NetworkDataIPv4DHCP) { + *out = *in + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev4, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv4DHCP. +func (in *NetworkDataIPv4DHCP) DeepCopy() *NetworkDataIPv4DHCP { + if in == nil { + return nil + } + out := new(NetworkDataIPv4DHCP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv6) DeepCopyInto(out *NetworkDataIPv6) { + *out = *in + if in.FromPoolRef != nil { + in, out := &in.FromPoolRef, &out.FromPoolRef + *out = new(v1.TypedLocalObjectReference) + (*in).DeepCopyInto(*out) + } + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev6, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv6. +func (in *NetworkDataIPv6) DeepCopy() *NetworkDataIPv6 { + if in == nil { + return nil + } + out := new(NetworkDataIPv6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataIPv6DHCP) DeepCopyInto(out *NetworkDataIPv6DHCP) { + *out = *in + if in.Routes != nil { + in, out := &in.Routes, &out.Routes + *out = make([]NetworkDataRoutev6, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataIPv6DHCP. +func (in *NetworkDataIPv6DHCP) DeepCopy() *NetworkDataIPv6DHCP { + if in == nil { + return nil + } + out := new(NetworkDataIPv6DHCP) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLink) DeepCopyInto(out *NetworkDataLink) { + *out = *in + if in.Ethernets != nil { + in, out := &in.Ethernets, &out.Ethernets + *out = make([]NetworkDataLinkEthernet, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Bonds != nil { + in, out := &in.Bonds, &out.Bonds + *out = make([]NetworkDataLinkBond, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Vlans != nil { + in, out := &in.Vlans, &out.Vlans + *out = make([]NetworkDataLinkVlan, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLink. +func (in *NetworkDataLink) DeepCopy() *NetworkDataLink { + if in == nil { + return nil + } + out := new(NetworkDataLink) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLinkBond) DeepCopyInto(out *NetworkDataLinkBond) { + *out = *in + if in.MACAddress != nil { + in, out := &in.MACAddress, &out.MACAddress + *out = new(NetworkLinkEthernetMac) + (*in).DeepCopyInto(*out) + } + if in.BondLinks != nil { + in, out := &in.BondLinks, &out.BondLinks + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLinkBond. +func (in *NetworkDataLinkBond) DeepCopy() *NetworkDataLinkBond { + if in == nil { + return nil + } + out := new(NetworkDataLinkBond) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLinkEthernet) DeepCopyInto(out *NetworkDataLinkEthernet) { + *out = *in + if in.MACAddress != nil { + in, out := &in.MACAddress, &out.MACAddress + *out = new(NetworkLinkEthernetMac) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLinkEthernet. +func (in *NetworkDataLinkEthernet) DeepCopy() *NetworkDataLinkEthernet { + if in == nil { + return nil + } + out := new(NetworkDataLinkEthernet) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataLinkVlan) DeepCopyInto(out *NetworkDataLinkVlan) { + *out = *in + if in.MACAddress != nil { + in, out := &in.MACAddress, &out.MACAddress + *out = new(NetworkLinkEthernetMac) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataLinkVlan. +func (in *NetworkDataLinkVlan) DeepCopy() *NetworkDataLinkVlan { + if in == nil { + return nil + } + out := new(NetworkDataLinkVlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataNetwork) DeepCopyInto(out *NetworkDataNetwork) { + *out = *in + if in.IPv4 != nil { + in, out := &in.IPv4, &out.IPv4 + *out = make([]NetworkDataIPv4, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv6 != nil { + in, out := &in.IPv6, &out.IPv6 + *out = make([]NetworkDataIPv6, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv4DHCP != nil { + in, out := &in.IPv4DHCP, &out.IPv4DHCP + *out = make([]NetworkDataIPv4DHCP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv6DHCP != nil { + in, out := &in.IPv6DHCP, &out.IPv6DHCP + *out = make([]NetworkDataIPv6DHCP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.IPv6SLAAC != nil { + in, out := &in.IPv6SLAAC, &out.IPv6SLAAC + *out = make([]NetworkDataIPv6DHCP, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataNetwork. +func (in *NetworkDataNetwork) DeepCopy() *NetworkDataNetwork { + if in == nil { + return nil + } + out := new(NetworkDataNetwork) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataRoutev4) DeepCopyInto(out *NetworkDataRoutev4) { + *out = *in + in.Gateway.DeepCopyInto(&out.Gateway) + in.Services.DeepCopyInto(&out.Services) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataRoutev4. +func (in *NetworkDataRoutev4) DeepCopy() *NetworkDataRoutev4 { + if in == nil { + return nil + } + out := new(NetworkDataRoutev4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataRoutev6) DeepCopyInto(out *NetworkDataRoutev6) { + *out = *in + in.Gateway.DeepCopyInto(&out.Gateway) + in.Services.DeepCopyInto(&out.Services) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataRoutev6. +func (in *NetworkDataRoutev6) DeepCopy() *NetworkDataRoutev6 { + if in == nil { + return nil + } + out := new(NetworkDataRoutev6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataService) DeepCopyInto(out *NetworkDataService) { + *out = *in + if in.DNS != nil { + in, out := &in.DNS, &out.DNS + *out = make([]v1alpha1.IPAddressStr, len(*in)) + copy(*out, *in) + } + if in.DNSFromIPPool != nil { + in, out := &in.DNSFromIPPool, &out.DNSFromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataService. +func (in *NetworkDataService) DeepCopy() *NetworkDataService { + if in == nil { + return nil + } + out := new(NetworkDataService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataServicev4) DeepCopyInto(out *NetworkDataServicev4) { + *out = *in + if in.DNS != nil { + in, out := &in.DNS, &out.DNS + *out = make([]v1alpha1.IPAddressv4Str, len(*in)) + copy(*out, *in) + } + if in.DNSFromIPPool != nil { + in, out := &in.DNSFromIPPool, &out.DNSFromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataServicev4. +func (in *NetworkDataServicev4) DeepCopy() *NetworkDataServicev4 { + if in == nil { + return nil + } + out := new(NetworkDataServicev4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkDataServicev6) DeepCopyInto(out *NetworkDataServicev6) { + *out = *in + if in.DNS != nil { + in, out := &in.DNS, &out.DNS + *out = make([]v1alpha1.IPAddressv6Str, len(*in)) + copy(*out, *in) + } + if in.DNSFromIPPool != nil { + in, out := &in.DNSFromIPPool, &out.DNSFromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkDataServicev6. +func (in *NetworkDataServicev6) DeepCopy() *NetworkDataServicev6 { + if in == nil { + return nil + } + out := new(NetworkDataServicev6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkGatewayv4) DeepCopyInto(out *NetworkGatewayv4) { + *out = *in + if in.String != nil { + in, out := &in.String, &out.String + *out = new(v1alpha1.IPAddressv4Str) + **out = **in + } + if in.FromIPPool != nil { + in, out := &in.FromIPPool, &out.FromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkGatewayv4. +func (in *NetworkGatewayv4) DeepCopy() *NetworkGatewayv4 { + if in == nil { + return nil + } + out := new(NetworkGatewayv4) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkGatewayv6) DeepCopyInto(out *NetworkGatewayv6) { + *out = *in + if in.String != nil { + in, out := &in.String, &out.String + *out = new(v1alpha1.IPAddressv6Str) + **out = **in + } + if in.FromIPPool != nil { + in, out := &in.FromIPPool, &out.FromIPPool + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkGatewayv6. +func (in *NetworkGatewayv6) DeepCopy() *NetworkGatewayv6 { + if in == nil { + return nil + } + out := new(NetworkGatewayv6) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkLinkEthernetMac) DeepCopyInto(out *NetworkLinkEthernetMac) { + *out = *in + if in.String != nil { + in, out := &in.String, &out.String + *out = new(string) + **out = **in + } + if in.FromHostInterface != nil { + in, out := &in.FromHostInterface, &out.FromHostInterface + *out = new(string) + **out = **in + } + if in.FromAnnotation != nil { + in, out := &in.FromAnnotation, &out.FromAnnotation + *out = new(NetworkLinkEthernetMacFromAnnotation) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkLinkEthernetMac. +func (in *NetworkLinkEthernetMac) DeepCopy() *NetworkLinkEthernetMac { + if in == nil { + return nil + } + out := new(NetworkLinkEthernetMac) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkLinkEthernetMacFromAnnotation) DeepCopyInto(out *NetworkLinkEthernetMacFromAnnotation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkLinkEthernetMacFromAnnotation. +func (in *NetworkLinkEthernetMacFromAnnotation) DeepCopy() *NetworkLinkEthernetMacFromAnnotation { + if in == nil { + return nil + } + out := new(NetworkLinkEthernetMacFromAnnotation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemediationStrategy) DeepCopyInto(out *RemediationStrategy) { + *out = *in + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(metav1.Duration) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemediationStrategy. +func (in *RemediationStrategy) DeepCopy() *RemediationStrategy { + if in == nil { + return nil + } + out := new(RemediationStrategy) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/LICENSE b/vendor/github.com/metal3-io/ip-address-manager/api/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/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/metal3-io/ip-address-manager/api/v1alpha1/common_types.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go new file mode 100644 index 000000000..78292d9b6 --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/common_types.go @@ -0,0 +1,41 @@ +/* +Copyright 2019 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 v1alpha1 + +// +kubebuilder:validation:Pattern="((^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$))" +// IPAddress is used for validation of an IP address. +type IPAddressStr string + +// +kubebuilder:validation:Pattern="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$" +// IPAddressv6 is used for validation of an IPv6 address. +type IPAddressv6Str string + +// +kubebuilder:validation:Pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))$" +// IPAddressv4 is used for validation of an IPv6 address. +type IPAddressv4Str string + +// +kubebuilder:validation:Pattern="((^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))/([0-9]|[1-2][0-9]|3[0-2])$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/([0-9]|[0-9][0-9]|1[0-1][0-9]|12[0-8])$))" +// IPSubnet is used for validation of an IP subnet. +type IPSubnetStr string + +// +kubebuilder:validation:Pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))/([0-9]|[1-2][0-9]|3[0-2])$" +// IPSubnetv4 is used for validation of an IP subnet. +type IPSubnetv4Str string + +// +kubebuilder:validation:Pattern="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))/([0-9]|[0-9][0-9]|1[0-1][0-9]|12[0-8])$" +// IPSubnetv6 is used for validation of an IP subnet. +type IPSubnetv6Str string diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go new file mode 100644 index 000000000..0d67430db --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/conversion.go @@ -0,0 +1,21 @@ +/* +Copyright 2019 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 v1alpha1 + +func (*IPPool) Hub() {} +func (*IPAddress) Hub() {} +func (*IPClaim) Hub() {} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go new file mode 100644 index 000000000..ca3b14718 --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2019 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 v1alpha1 contains API Schema definitions for the metal3 v1alpha1 API group +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +kubebuilder:object:generate=true +// +groupName=ipam.metal3.io +package v1alpha1 diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go new file mode 100644 index 000000000..967b4b18c --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/groupversion_info.go @@ -0,0 +1,53 @@ +/* +Copyright 2019 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 v1alpha1 contains API Schema definitions for the infrastructure v1alpha1 API group +// +kubebuilder:object:generate=true +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen=package,register +// +k8s:defaulter-gen=TypeMeta +// +groupName=ipam.metal3.io +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // GroupVersion is group version used to register these objects. + GroupVersion = schema.GroupVersion{Group: "ipam.metal3.io", Version: "v1alpha1"} + + /// schemeBuilder is used to add go types to the GroupVersionKind scheme. + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = schemeBuilder.AddToScheme + + objectTypes = []runtime.Object{} +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, objectTypes...) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} + +// Resource is required by pkg/client/listers/... +// func Resource(resource string) schema.GroupResource { +// return SchemeGroupVersion.WithResource(resource).GroupResource() +// } diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go new file mode 100644 index 000000000..d2b0be4f3 --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_types.go @@ -0,0 +1,77 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // DataFinalizer allows IPAddressReconciler to clean up resources + // associated with IPAddress before removing it from the apiserver. + IPAddressFinalizer = "ipaddress.ipam.metal3.io" +) + +// IPAddressSpec defines the desired state of IPAddress. +type IPAddressSpec struct { + + // Claim points to the object the IPClaim was created for. + Claim corev1.ObjectReference `json:"claim"` + + // Pool is the IPPool this was generated from. + Pool corev1.ObjectReference `json:"pool"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + Prefix int `json:"prefix,omitempty"` + + // Gateway is the gateway ip address + Gateway *IPAddressStr `json:"gateway,omitempty"` + + // Address contains the IP address + Address IPAddressStr `json:"address"` + + // DNSServers is the list of dns servers + DNSServers []IPAddressStr `json:"dnsServers,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=ipaddresses,scope=Namespaced,categories=metal3,shortName=ipa;ipaddress;m3ipa;m3ipaddress;m3ipaddresses;metal3ipa;metal3ipaddress;metal3ipaddresses +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3IPAddress" +// +kubebuilder:storageversion +// +kubebuilder:object:root=true +// IPAddress is the Schema for the ipaddresses API. +type IPAddress struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPAddressSpec `json:"spec,omitempty"` +} + +// +kubebuilder:object:root=true + +// IPAddressList contains a list of IPAddress. +type IPAddressList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPAddress `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &IPAddress{}, &IPAddressList{}) +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go new file mode 100644 index 000000000..8ff60e3af --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipaddress_webhook.go @@ -0,0 +1,159 @@ +/* +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 v1alpha1 + +import ( + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *IPAddress) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-ipam-metal3-io-v1alpha1-ipaddress,mutating=false,failurePolicy=fail,groups=ipam.metal3.io,resources=ipaddresses,versions=v1alpha1,name=validation.ipaddress.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-ipam-metal3-io-v1alpha1-ipaddress,mutating=true,failurePolicy=fail,groups=ipam.metal3.io,resources=ipaddresses,versions=v1alpha1,name=default.ipaddress.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &IPAddress{} +var _ webhook.Validator = &IPAddress{} + +func (c *IPAddress) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPAddress) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if c.Spec.Pool.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool", "name"), + c.Spec.Pool.Name, + "cannot be empty", + ), + ) + } + + if c.Spec.Claim.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim", "name"), + c.Spec.Claim.Name, + "cannot be empty", + ), + ) + } + + if c.Spec.Address == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "address"), + c.Spec.Address, + "cannot be empty", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPAddress").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPAddress) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldIPAddress, ok := old.(*IPAddress) + if !ok || oldIPAddress == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Address != oldIPAddress.Spec.Address { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "address"), + c.Spec.Address, + "cannot be modified", + ), + ) + } + + if c.Spec.Pool.Name != oldIPAddress.Spec.Pool.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Namespace != oldIPAddress.Spec.Pool.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Kind != oldIPAddress.Spec.Pool.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } + + if c.Spec.Claim.Name != oldIPAddress.Spec.Claim.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Namespace != oldIPAddress.Spec.Claim.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } else if c.Spec.Claim.Kind != oldIPAddress.Spec.Claim.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "claim"), + c.Spec.Claim, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPAddress").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *IPAddress) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go new file mode 100644 index 000000000..938108960 --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_types.go @@ -0,0 +1,73 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // IPClaimFinalizer allows IPClaimReconciler to clean up resources + // associated with IPClaim before removing it from the apiserver. + IPClaimFinalizer = "ipclaim.ipam.metal3.io" +) + +// IPClaimSpec defines the desired state of IPClaim. +type IPClaimSpec struct { + + // Pool is the IPPool this was generated from. + Pool corev1.ObjectReference `json:"pool"` +} + +// IPClaimStatus defines the observed state of IPClaim. +type IPClaimStatus struct { + + // Address is the IPAddress that was generated for this claim. + Address *corev1.ObjectReference `json:"address,omitempty"` + + // ErrorMessage contains the error message + ErrorMessage *string `json:"errorMessage,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=ipclaims,scope=Namespaced,categories=cluster-api,shortName=ipc;ipclaim;m3ipc;m3ipclaim;m3ipclaims;metal3ipc;metal3ipclaim;metal3ipclaims +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3IPClaim" +// IPClaim is the Schema for the ipclaims API. +type IPClaim struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPClaimSpec `json:"spec,omitempty"` + Status IPClaimStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// IPClaimList contains a list of IPClaim. +type IPClaimList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPClaim `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &IPClaim{}, &IPClaimList{}) +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go new file mode 100644 index 000000000..ea5d0858d --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ipclaim_webhook.go @@ -0,0 +1,103 @@ +/* +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 v1alpha1 + +import ( + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *IPClaim) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-ipam-metal3-io-v1alpha1-ipclaim,mutating=false,failurePolicy=fail,groups=ipam.metal3.io,resources=ipclaims,versions=v1alpha1,name=validation.ipclaim.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-ipam-metal3-io-v1alpha1-ipclaim,mutating=true,failurePolicy=fail,groups=ipam.metal3.io,resources=ipclaims,versions=v1alpha1,name=default.ipclaim.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &IPClaim{} +var _ webhook.Validator = &IPClaim{} + +func (c *IPClaim) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPClaim) ValidateCreate() (admission.Warnings, error) { + allErrs := field.ErrorList{} + if c.Spec.Pool.Name == "" { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool", "name"), + c.Spec.Pool.Name, + "cannot be empty", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPClaim) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldIPClaim, ok := old.(*IPClaim) + if !ok || oldIPClaim == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if c.Spec.Pool.Name != oldIPClaim.Spec.Pool.Name { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Namespace != oldIPClaim.Spec.Pool.Namespace { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } else if c.Spec.Pool.Kind != oldIPClaim.Spec.Pool.Kind { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pool"), + c.Spec.Pool, + "cannot be modified", + ), + ) + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPClaim").GroupKind(), c.Name, allErrs) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *IPClaim) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go new file mode 100644 index 000000000..4b41dd533 --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_types.go @@ -0,0 +1,120 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // IPPoolFinalizer allows IPPoolReconciler to clean up resources + // associated with IPPool before removing it from the apiserver. + IPPoolFinalizer = "ippool.ipam.metal3.io" +) + +// MetaDataIPAddress contains the info to render th ip address. It is IP-version +// agnostic. +type Pool struct { + + // Start is the first ip address that can be rendered + Start *IPAddressStr `json:"start,omitempty"` + + // End is the last IP address that can be rendered. It is used as a validation + // that the rendered IP is in bound. + End *IPAddressStr `json:"end,omitempty"` + + // Subnet is used to validate that the rendered IP is in bounds. In case the + // Start value is not given, it is derived from the subnet ip incremented by 1 + // (`192.168.0.1` for `192.168.0.0/24`) + Subnet *IPSubnetStr `json:"subnet,omitempty"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + Prefix int `json:"prefix,omitempty"` + + // Gateway is the gateway ip address + Gateway *IPAddressStr `json:"gateway,omitempty"` + + // DNSServers is the list of dns servers + DNSServers []IPAddressStr `json:"dnsServers,omitempty"` +} + +// IPPoolSpec defines the desired state of IPPool. +type IPPoolSpec struct { + + // ClusterName is the name of the Cluster this object belongs to. + ClusterName *string `json:"clusterName,omitempty"` + + // Pools contains the list of IP addresses pools + Pools []Pool `json:"pools,omitempty"` + + // PreAllocations contains the preallocated IP addresses + PreAllocations map[string]IPAddressStr `json:"preAllocations,omitempty"` + + // +kubebuilder:validation:Maximum=128 + // Prefix is the mask of the network as integer (max 128) + Prefix int `json:"prefix,omitempty"` + + // Gateway is the gateway ip address + Gateway *IPAddressStr `json:"gateway,omitempty"` + + // DNSServers is the list of dns servers + DNSServers []IPAddressStr `json:"dnsServers,omitempty"` + + // +kubebuilder:validation:MinLength=1 + // namePrefix is the prefix used to generate the IPAddress object names + NamePrefix string `json:"namePrefix"` +} + +// IPPoolStatus defines the observed state of IPPool. +type IPPoolStatus struct { + // LastUpdated identifies when this status was last observed. + // +optional + LastUpdated *metav1.Time `json:"lastUpdated,omitempty"` + + // Allocations contains the map of objects and IP addresses they have + Allocations map[string]IPAddressStr `json:"indexes,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:path=ippools,scope=Namespaced,categories=cluster-api,shortName=ipp;ippool;m3ipp;m3ippool;m3ippools;metal3ipp;metal3ippool;metal3ippools +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this template belongs" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Metal3IPPool" +// IPPool is the Schema for the ippools API. +type IPPool struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec IPPoolSpec `json:"spec,omitempty"` + Status IPPoolStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// IPPoolList contains a list of IPPool. +type IPPoolList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPPool `json:"items"` +} + +func init() { + objectTypes = append(objectTypes, &IPPool{}, &IPPoolList{}) +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go new file mode 100644 index 000000000..78991455a --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/ippool_webhook.go @@ -0,0 +1,176 @@ +/* +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 v1alpha1 + +import ( + "net" + "net/netip" + "reflect" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/validation/field" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +func (c *IPPool) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(c). + Complete() +} + +// +kubebuilder:webhook:verbs=create;update,path=/validate-ipam-metal3-io-v1alpha1-ippool,mutating=false,failurePolicy=fail,groups=ipam.metal3.io,resources=ippools,versions=v1alpha1,name=validation.ippool.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create;update,path=/mutate-ipam-metal3-io-v1alpha1-ippool,mutating=true,failurePolicy=fail,groups=ipam.metal3.io,resources=ippools,versions=v1alpha1,name=default.ippool.ipam.metal3.io,matchPolicy=Equivalent,sideEffects=None,admissionReviewVersions=v1;v1beta1 + +var _ webhook.Defaulter = &IPPool{} +var _ webhook.Validator = &IPPool{} + +func (c *IPPool) Default() { +} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPPool) ValidateCreate() (admission.Warnings, error) { + return c.validate() +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. +func (c *IPPool) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + allErrs := field.ErrorList{} + oldM3ipp, ok := old.(*IPPool) + if !ok || oldM3ipp == nil { + return nil, apierrors.NewInternalError(errors.New("unable to convert existing object")) + } + + if !reflect.DeepEqual(c.Spec.NamePrefix, oldM3ipp.Spec.NamePrefix) { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "NamePrefix"), + c.Spec.NamePrefix, + "cannot be modified", + ), + ) + } + allocationOutOfBonds, inUseOutOfBonds := c.checkPoolBonds(oldM3ipp) + if len(allocationOutOfBonds) != 0 { + for _, address := range allocationOutOfBonds { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "preAllocations"), + address, + "is out of bonds of the pools given", + ), + ) + } + } + if len(inUseOutOfBonds) != 0 { + for _, address := range inUseOutOfBonds { + allErrs = append(allErrs, + field.Invalid( + field.NewPath("spec", "pools"), + address, + "is in use but out of bonds of the pools given", + ), + ) + } + } + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("Metal3Data").GroupKind(), c.Name, allErrs) +} + +func (c *IPPool) checkPoolBonds(old *IPPool) ([]IPAddressStr, []IPAddressStr) { + allocationOutOfBonds := []IPAddressStr{} + inUseOutOfBonds := []IPAddressStr{} + for _, address := range c.Spec.PreAllocations { + inBonds := c.isAddressInBonds(address) + + if !inBonds { + allocationOutOfBonds = append(allocationOutOfBonds, address) + } + } + for _, address := range old.Status.Allocations { + inBonds := c.isAddressInBonds(address) + + if !inBonds { + inUseOutOfBonds = append(inUseOutOfBonds, address) + } + } + return allocationOutOfBonds, inUseOutOfBonds +} + +func (c *IPPool) isAddressInBonds(address IPAddressStr) bool { + ip, err := netip.ParseAddr(string(address)) + if err != nil { + return false + } + + for _, pool := range c.Spec.Pools { + if pool.Start != nil { + startIP, err := netip.ParseAddr(string(*pool.Start)) + if err != nil { + // skip this invalid pool, as the validation error should be caught somewhere else + continue + } + if startIP.Compare(ip) > 0 { + continue + } + } + + if pool.End != nil { + endIP, err := netip.ParseAddr(string(*pool.End)) + if err != nil { + // skip this invalid pool, as the validation error should be caught somewhere else + continue + } + if endIP.Compare(ip) < 0 { + continue + } + } + + if pool.Subnet != nil { + _, subnet, err := net.ParseCIDR(string(*pool.Subnet)) + if err != nil { + // skip this invalid pool, as the validation error should be caught somewhere else + continue + } + if !subnet.Contains(net.ParseIP(ip.String())) { + continue + } + } + + return true + } + + return false +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. +func (c *IPPool) ValidateDelete() (admission.Warnings, error) { + return nil, nil +} + +// No further validation for now. +func (c *IPPool) validate() (admission.Warnings, error) { + var allErrs field.ErrorList + + if len(allErrs) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(GroupVersion.WithKind("IPPool").GroupKind(), c.Name, allErrs) +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go new file mode 100644 index 000000000..63909d1fd --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/utils.go @@ -0,0 +1,124 @@ +/* +Copyright 2019 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 v1alpha1 + +import ( + "fmt" + "math/big" + "net" + + "github.com/pkg/errors" +) + +// GetIPAddress renders the IP address, taking the index, offset and step into +// account, it is IP version agnostic. +func GetIPAddress(entry Pool, index int) (IPAddressStr, error) { + if entry.Start == nil && entry.Subnet == nil { + return "", errors.New("Either Start or Subnet is required for ipAddress") + } + var ip net.IP + var err error + var ipNet *net.IPNet + offset := index + + // If start is given, use it to add the offset. + if entry.Start != nil { + var endIP net.IP + if entry.End != nil { + endIP = net.ParseIP(string(*entry.End)) + } + ip, err = addOffsetToIP(net.ParseIP(string(*entry.Start)), endIP, offset) + if err != nil { + return "", err + } + + // Verify that the IP is in the subnet. + if entry.Subnet != nil { + _, ipNet, err = net.ParseCIDR(string(*entry.Subnet)) + if err != nil { + return "", err + } + if !ipNet.Contains(ip) { + return "", errors.New("IP address out of bonds") + } + } + + // If it is not given, use the CIDR ip address and increment the offset by 1. + } else { + ip, ipNet, err = net.ParseCIDR(string(*entry.Subnet)) + if err != nil { + return "", err + } + offset++ + ip, err = addOffsetToIP(ip, nil, offset) + if err != nil { + return "", err + } + + // Verify that the ip is in the subnet. + if !ipNet.Contains(ip) { + return "", errors.New("IP address out of bonds") + } + } + return IPAddressStr(ip.String()), nil +} + +// addOffsetToIP computes the value of the IP address with the offset. It is +// IP version agnostic +// Note that if the resulting IP address is in the format ::ffff:xxxx:xxxx then +// ip.String will fail to select the correct type of ip. +func addOffsetToIP(ip, endIP net.IP, offset int) (net.IP, error) { + ip4 := false + if ip.To4() != nil { + ip4 = true + } + + // Create big integers. + IPInt := big.NewInt(0) + OffsetInt := big.NewInt(int64(offset)) + + // Transform the ip into an int. (big endian function). + IPInt = IPInt.SetBytes(ip) + + // add the two integers. + IPInt = IPInt.Add(IPInt, OffsetInt) + + // return the bytes list. + IPBytes := IPInt.Bytes() + + IPBytesLen := len(IPBytes) + + // Verify that the IPv4 or IPv6 fulfills theirs constraints. + if (ip4 && IPBytesLen > 6 && IPBytes[4] != 255 && IPBytes[5] != 255) || + (!ip4 && IPBytesLen > 16) { + return nil, fmt.Errorf("IP address overflow for : %s", ip.String()) + } + + // transform the end ip into an Int to compare. + if endIP != nil { + endIPInt := big.NewInt(0) + endIPInt = endIPInt.SetBytes(endIP) + // Computed IP is higher than the end IP. + if IPInt.Cmp(endIPInt) > 0 { + return nil, fmt.Errorf("IP address out of bonds for : %s", ip.String()) + } + } + + // COpy the output back into an ip. + copy(ip[16-IPBytesLen:], IPBytes) + return ip, nil +} diff --git a/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..39be4327a --- /dev/null +++ b/vendor/github.com/metal3-io/ip-address-manager/api/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,380 @@ +//go:build !ignore_autogenerated + +/* +Copyright 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. +*/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddress) DeepCopyInto(out *IPAddress) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddress. +func (in *IPAddress) DeepCopy() *IPAddress { + if in == nil { + return nil + } + out := new(IPAddress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddress) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressList) DeepCopyInto(out *IPAddressList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddress, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressList. +func (in *IPAddressList) DeepCopy() *IPAddressList { + if in == nil { + return nil + } + out := new(IPAddressList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressSpec) DeepCopyInto(out *IPAddressSpec) { + *out = *in + out.Claim = in.Claim + out.Pool = in.Pool + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(IPAddressStr) + **out = **in + } + if in.DNSServers != nil { + in, out := &in.DNSServers, &out.DNSServers + *out = make([]IPAddressStr, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressSpec. +func (in *IPAddressSpec) DeepCopy() *IPAddressSpec { + if in == nil { + return nil + } + out := new(IPAddressSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaim) DeepCopyInto(out *IPClaim) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaim. +func (in *IPClaim) DeepCopy() *IPClaim { + if in == nil { + return nil + } + out := new(IPClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPClaim) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaimList) DeepCopyInto(out *IPClaimList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimList. +func (in *IPClaimList) DeepCopy() *IPClaimList { + if in == nil { + return nil + } + out := new(IPClaimList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPClaimList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaimSpec) DeepCopyInto(out *IPClaimSpec) { + *out = *in + out.Pool = in.Pool +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimSpec. +func (in *IPClaimSpec) DeepCopy() *IPClaimSpec { + if in == nil { + return nil + } + out := new(IPClaimSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPClaimStatus) DeepCopyInto(out *IPClaimStatus) { + *out = *in + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(v1.ObjectReference) + **out = **in + } + if in.ErrorMessage != nil { + in, out := &in.ErrorMessage, &out.ErrorMessage + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPClaimStatus. +func (in *IPClaimStatus) DeepCopy() *IPClaimStatus { + if in == nil { + return nil + } + out := new(IPClaimStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPool) DeepCopyInto(out *IPPool) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPool. +func (in *IPPool) DeepCopy() *IPPool { + if in == nil { + return nil + } + out := new(IPPool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPPool) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolList) DeepCopyInto(out *IPPoolList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPPool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolList. +func (in *IPPoolList) DeepCopy() *IPPoolList { + if in == nil { + return nil + } + out := new(IPPoolList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPPoolList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec) { + *out = *in + if in.ClusterName != nil { + in, out := &in.ClusterName, &out.ClusterName + *out = new(string) + **out = **in + } + if in.Pools != nil { + in, out := &in.Pools, &out.Pools + *out = make([]Pool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PreAllocations != nil { + in, out := &in.PreAllocations, &out.PreAllocations + *out = make(map[string]IPAddressStr, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(IPAddressStr) + **out = **in + } + if in.DNSServers != nil { + in, out := &in.DNSServers, &out.DNSServers + *out = make([]IPAddressStr, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec. +func (in *IPPoolSpec) DeepCopy() *IPPoolSpec { + if in == nil { + return nil + } + out := new(IPPoolSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPPoolStatus) DeepCopyInto(out *IPPoolStatus) { + *out = *in + if in.LastUpdated != nil { + in, out := &in.LastUpdated, &out.LastUpdated + *out = (*in).DeepCopy() + } + if in.Allocations != nil { + in, out := &in.Allocations, &out.Allocations + *out = make(map[string]IPAddressStr, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolStatus. +func (in *IPPoolStatus) DeepCopy() *IPPoolStatus { + if in == nil { + return nil + } + out := new(IPPoolStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Pool) DeepCopyInto(out *Pool) { + *out = *in + if in.Start != nil { + in, out := &in.Start, &out.Start + *out = new(IPAddressStr) + **out = **in + } + if in.End != nil { + in, out := &in.End, &out.End + *out = new(IPAddressStr) + **out = **in + } + if in.Subnet != nil { + in, out := &in.Subnet, &out.Subnet + *out = new(IPSubnetStr) + **out = **in + } + if in.Gateway != nil { + in, out := &in.Gateway, &out.Gateway + *out = new(IPAddressStr) + **out = **in + } + if in.DNSServers != nil { + in, out := &in.DNSServers, &out.DNSServers + *out = make([]IPAddressStr, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Pool. +func (in *Pool) DeepCopy() *Pool { + if in == nil { + return nil + } + out := new(Pool) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1eacb5bf8..09032947d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -733,6 +733,12 @@ github.com/mattn/go-isatty # github.com/mattn/go-runewidth v0.0.14 ## explicit; go 1.9 github.com/mattn/go-runewidth +# github.com/metal3-io/cluster-api-provider-metal3/api v1.7.0 +## explicit; go 1.21 +github.com/metal3-io/cluster-api-provider-metal3/api/v1beta1 +# github.com/metal3-io/ip-address-manager/api v1.7.0 +## explicit; go 1.21 +github.com/metal3-io/ip-address-manager/api/v1alpha1 # github.com/mgechev/revive v1.3.7 ## explicit; go 1.20 github.com/mgechev/revive/config @@ -2189,5 +2195,6 @@ sigs.k8s.io/structured-merge-diff/v4/value ## explicit; go 1.12 sigs.k8s.io/yaml sigs.k8s.io/yaml/goyaml.v2 +# github.com/metal3-io/cluster-api-provider-metal3 => github.com/openshift/cluster-api-provider-metal3 v0.0.0-20240529071518-ea1aa8a45bfa # github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0 # github.com/prometheus/common => github.com/prometheus/common v0.47.0